/
AFormasPagamento.pas
211 lines (183 loc) · 7.06 KB
/
AFormasPagamento.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
unit AFormasPagamento;
{ Autor: Jorge Eduardo
Data Criação: 10/04/1999;
Função: Cadastrar uma nova forma de Pagamento
Motivo alteração:
}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, formularios,
Componentes1, ExtCtrls, PainelGradiente, BotaoCadastro,
StdCtrls, Buttons, Db, DBTables, Tabela, Mask, DBCtrls, Localizacao,
DBKeyViolation, Grids, DBGrids, Constantes;
type
TFFormasPagamento = class(TFormularioPermissao)
PainelGradiente1: TPainelGradiente;
PanelColor1: TPanelColor;
PanelColor2: TPanelColor;
MoveBasico1: TMoveBasico;
BotaoCadastrar1: TBotaoCadastrar;
BotaoAlterar1: TBotaoAlterar;
BotaoExcluir1: TBotaoExcluir;
BotaoGravar1: TBotaoGravar;
BotaoCancelar1: TBotaoCancelar;
Label1: TLabel;
DataFormas: TDataSource;
Label2: TLabel;
Descricao: TDBEditColor;
Bevel1: TBevel;
DBGridColor1: TGridIndice;
Consulta: TLocalizaEdit;
Label3: TLabel;
CadFormasPagamento: TSQL;
CadFormasPagamentoI_COD_FRM: TIntegerField;
CadFormasPagamentoC_NOM_FRM: TStringField;
BFechar: TBitBtn;
ValidaGravacao1: TValidaGravacao;
CadFormasPagamentoC_FLA_BCP: TStringField;
CadFormasPagamentoC_FLA_BCR: TStringField;
CadFormasPagamentoC_FLA_TIP: TStringField;
RPagar: TDBRadioGroup;
RReceber: TDBRadioGroup;
RTipo: TDBRadioGroup;
BBAjuda: TBitBtn;
DBCheckBox1: TDBCheckBox;
CadFormasPagamentoC_BAI_BAC: TStringField;
CadFormasPagamentoC_BAI_CON: TStringField;
DBFilialColor1: TDBFilialColor;
CadFormasPagamentoD_ULT_ALT: TDateField;
CGaveta: TDBCheckBox;
CadFormasPagamentoC_ACI_GAV: TStringField;
LSituacao: TLabel;
ENovaSituacao: TDBEditLocaliza;
SpeedButton5: TSpeedButton;
Label18: TLabel;
CadFormasPagamentoI_COD_SIT: TIntegerField;
Localiza: TConsultaPadrao;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure CadFormasPagamentoAfterInsert(DataSet: TDataSet);
procedure CadFormasPagamentoBeforePost(DataSet: TDataSet);
procedure CadFormasPagamentoAfterPost(DataSet: TDataSet);
procedure CadFormasPagamentoAfterEdit(DataSet: TDataSet);
procedure BFecharClick(Sender: TObject);
procedure DBGridColor1Ordem(Ordem: String);
procedure CadFormasPagamentoAfterCancel(DataSet: TDataSet);
procedure DBKeyViolation1Change(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BBAjudaClick(Sender: TObject);
procedure CadFormasPagamentoAfterScroll(DataSet: TDataSet);
private
procedure ConfiguraConsulta( acao : Boolean);
public
{ Public declarations }
end;
var
FFormasPagamento: TFFormasPagamento;
implementation
uses APrincipal, FunObjeto;
{$R *.DFM}
{ ****************** Na criação do Formulário ******************************** }
procedure TFFormasPagamento.FormCreate(Sender: TObject);
begin
CadFormasPagamento.open; { abre tabelas }
Self.HelpFile := Varia.PathHelp + 'FINANCEIRO.HLP>janela'; // Indica o Paph e o nome do arquivo de Help
IniciallizaCheckBox([DBCheckBox1, CGaveta], 'S', 'N');
DBFilialColor1.ACodFilial := Varia.CodigoFilCadastro;
end;
{ ******************* Quando o formulario e fechado ************************** }
procedure TFFormasPagamento.FormClose(Sender: TObject; var Action: TCloseAction);
begin
CadFormasPagamento.close; { fecha tabelas }
Action := CaFree;
end;
{(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
Ações das Tabelas
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))}
{***********************Gera o proximo codigo disponível***********************}
procedure TFFormasPagamento.CadFormasPagamentoAfterInsert(DataSet: TDataSet);
begin
DBFilialColor1.ProximoCodigo;
DBFilialColor1.ReadOnly := False;
ConfiguraConsulta(False);
CadFormasPagamentoC_BAI_CON.AsString := 'N';
CadFormasPagamentoC_ACI_GAV.AsString := 'N';
RPagar.ItemIndex := 2;
RReceber.ItemIndex := 2;
RTipo.ItemIndex := 0;
end;
{********Verifica se o codigo ja foi utilizado por algum usuario da rede*******}
procedure TFFormasPagamento.CadFormasPagamentoBeforePost(DataSet: TDataSet);
begin
CadFormasPagamentoD_ULT_ALT.AsDateTime := Date;
If CadFormasPagamento.State = dsInsert Then
DBFilialColor1.VerificaCodigoRede;
end;
{***************Caso o codigo tenha sido utilizado, efetua refresh*************}
procedure TFFormasPagamento.CadFormasPagamentoAfterPost(DataSet: TDataSet);
begin
Consulta.AtualizaTabela;
ConfiguraConsulta(true);
end;
{*********************Coloca o campo chave em read-only************************}
procedure TFFormasPagamento.CadFormasPagamentoAfterEdit(DataSet: TDataSet);
begin
DBFilialColor1.ReadOnly := True;
ConfiguraConsulta(false);
end;
{ ********************* quando cancela a operacao *************************** }
procedure TFFormasPagamento.CadFormasPagamentoAfterCancel(
DataSet: TDataSet);
begin
ConfiguraConsulta(true);
end;
{(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
Ações Diversas
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))}
{****** configura a consulta, caso edit ou insert enabled = false *********** }
procedure TFFormasPagamento.ConfiguraConsulta( acao : Boolean);
begin
Consulta.Enabled := acao;
DBGridColor1.Enabled := acao;
Label3.Enabled := acao;
end;
{***************************Fechar o Formulario corrente***********************}
procedure TFFormasPagamento.BFecharClick(Sender: TObject);
begin
close;
end;
{********** adiciona order by na tabela ************************************ }
procedure TFFormasPagamento.DBGridColor1Ordem(Ordem: String);
begin
Consulta.AOrdem := ordem;
end;
{**************** valida os campos obrigatorios ****************************** }
procedure TFFormasPagamento.DBKeyViolation1Change(Sender: TObject);
begin
if CadFormasPagamento.State in [ dsInsert, dsEdit ] then
ValidaGravacao1.execute;
end;
procedure TFFormasPagamento.FormShow(Sender: TObject);
begin
/////////////////////////////////////////////////
/////// ATIVA DE ACORDO COM OS MÓDULOS //////////
/////////////////////////////////////////////////
RPagar.Enabled := ConfigModulos.ContasAPagar;
RReceber.Enabled := ConfigModulos.ContasAReceber;
RPagar.Controls[0].Enabled := ConfigModulos.Bancario;
RReceber.Controls[0].Enabled := ConfigModulos.Bancario;
RPagar.Controls[1].Enabled := ConfigModulos.Caixa;
RReceber.Controls[1].Enabled := ConfigModulos.Caixa;
end;
procedure TFFormasPagamento.BBAjudaClick(Sender: TObject);
begin
Application.HelpCommand(HELP_CONTEXT,FFormasPagamento.HelpContext);
end;
procedure TFFormasPagamento.CadFormasPagamentoAfterScroll(
DataSet: TDataSet);
begin
ENovaSituacao.Atualiza;
end;
Initialization
RegisterClasses([TFFormasPagamento]);
end.