You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
239 lines
7.1 KiB
239 lines
7.1 KiB
unit ufrmFechamentoAtendimento;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, System.UITypes,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, umstMaster, Vcl.StdCtrls, Vcl.ExtCtrls,
|
|
Vcl.ComCtrls, Vcl.DBCtrls, Data.DB, ZAbstractRODataset, ZDataset;
|
|
|
|
type
|
|
TfrmFechamentoAtendimento = class(TmstMaster)
|
|
cbx_quit: TCheckBox;
|
|
cbx_par: TCheckBox;
|
|
lbl_text: TLabel;
|
|
pnl_fundo: TPanel;
|
|
btn_ok: TButton;
|
|
btn_cancel: TButton;
|
|
lbl_tppagamento: TLabel;
|
|
cbx_tppagamento1: TComboBox;
|
|
lbl_tppagamento1: TLabel;
|
|
lbl_tppagamento2: TLabel;
|
|
cbx_tppagamento2: TComboBox;
|
|
cbx_empacord: TCheckBox;
|
|
cb_multi: TCheckBox;
|
|
dblucb_empsacordo: TDBLookupComboBox;
|
|
dtsAcordosEmp: TDataSource;
|
|
zroqryAcordosEmp: TZReadOnlyQuery;
|
|
zroqryAcordosEmpID_EMPRESA: TIntegerField;
|
|
zroqryAcordosEmpTX_FANTASIA: TWideStringField;
|
|
procedure cbx_quitClick(Sender: TObject);
|
|
procedure cbx_parClick(Sender: TObject);
|
|
procedure btn_okClick(Sender: TObject);
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure cbx_empacordClick(Sender: TObject);
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
private
|
|
procedure WMMoving(var Msg: TWMMoving); message WM_MOVING;
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frmFechamentoAtendimento: TfrmFechamentoAtendimento;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses ufrmAtendimento, udtmSystem;
|
|
|
|
procedure TfrmFechamentoAtendimento.btn_okClick(Sender: TObject);
|
|
begin
|
|
if (not cbx_quit.Checked) and (not cbx_par.Checked) then
|
|
begin
|
|
MessageDlg('Por favor selecione uma forma de pagamento.', mtWarning,
|
|
[mbOK], 0);
|
|
ModalResult := mrCancel;
|
|
abort;
|
|
end
|
|
else
|
|
begin
|
|
if cbx_quit.Checked then
|
|
begin
|
|
if strtoint(frmAtendimento.edt_nrparcelas.Text) > 0 then
|
|
begin
|
|
MessageDlg
|
|
('O número de parcelas selecionadas deve ser 0 para que esta opção possa ser utilizada.',
|
|
mtInformation, [mbOK], 0);
|
|
ModalResult := mrCancel;
|
|
abort;
|
|
end;
|
|
if cbx_empacord.Checked then
|
|
begin
|
|
MessageDlg
|
|
('Opção vincular acordo com outra empresa está marcada, mas o pagamento é quitação.'
|
|
+ ' Por favor verifique a forma de pagamento.', mtWarning, [mbOK], 0);
|
|
ModalResult := mrNone;
|
|
abort;
|
|
end;
|
|
frmAtendimento.forma_pagamento := 'Q';
|
|
frmAtendimento.index_pagamento := cbx_tppagamento1.ItemIndex;
|
|
frmAtendimento.parcelas_pagamento := -1;
|
|
if (cbx_tppagamento1.ItemIndex = 0) or (cbx_tppagamento1.ItemIndex = 1)
|
|
then
|
|
begin
|
|
frmAtendimento.cb_formapag.ItemIndex := cbx_tppagamento1.ItemIndex;
|
|
end
|
|
else
|
|
begin
|
|
frmAtendimento.cb_formapag.ItemIndex := 3;
|
|
end;
|
|
frmAtendimento.cb_formapagChange(self);
|
|
end;
|
|
if cbx_par.Checked then
|
|
begin
|
|
if strtoint(frmAtendimento.edt_nrparcelas.Text) < 1 then
|
|
begin
|
|
MessageDlg
|
|
('O número de parcelas selecionadas deve ser no mínimo "1" (um) para que esta opção possa ser utilizada.',
|
|
mtInformation, [mbOK], 0);
|
|
ModalResult := mrCancel;
|
|
abort;
|
|
end;
|
|
if cbx_empacord.Checked then
|
|
begin
|
|
if dblucb_empsacordo.KeyValue < 0 then
|
|
begin
|
|
MessageDlg
|
|
('Opção vincular acordo com outra empresa está marcada, mas não foi escolhida uma empresa.'
|
|
+ ' Por favor selecione uma empresa.', mtWarning, [mbOK], 0);
|
|
ModalResult := mrNone;
|
|
abort;
|
|
end
|
|
else
|
|
begin
|
|
frmAtendimento.acordo_fora := true;
|
|
frmAtendimento.acordo_emp := dblucb_empsacordo.KeyValue;
|
|
frmAtendimento.acordo_fantasia := zroqryAcordosEmpTX_FANTASIA.AsString;
|
|
end;
|
|
end;
|
|
frmAtendimento.forma_pagamento := 'P';
|
|
frmAtendimento.index_pagamento := cbx_tppagamento1.ItemIndex;
|
|
frmAtendimento.parcelas_pagamento := cbx_tppagamento2.ItemIndex;
|
|
|
|
// if (cbx_tppagamento2.ItemIndex = 3) then
|
|
// begin
|
|
// frmAtendimento.cb_formapag.ItemIndex := 3;
|
|
// end
|
|
// else if (cbx_tppagamento2.ItemIndex = 2) then
|
|
// begin
|
|
// frmAtendimento.cb_formapag.ItemIndex := 0;
|
|
// end
|
|
// else
|
|
// begin
|
|
if cbx_tppagamento2.ItemIndex = 1 then
|
|
begin
|
|
MessageDlg
|
|
('Parcelamento está marcado para ser pago no débito. Isso é inconsistente.',
|
|
mtWarning, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
frmAtendimento.cb_formapag.ItemIndex := cbx_tppagamento2.ItemIndex;
|
|
// end;
|
|
frmAtendimento.cb_formapagChange(self);
|
|
end;
|
|
frmAtendimento.edt_formarecebimento.Text :=
|
|
UpperCase(cbx_tppagamento1.Text);
|
|
frmAtendimento.multi_form_pag := cb_multi.Checked;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmFechamentoAtendimento.cbx_empacordClick(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
dblucb_empsacordo.Enabled := cbx_empacord.Checked;
|
|
end;
|
|
|
|
procedure TfrmFechamentoAtendimento.cbx_parClick(Sender: TObject);
|
|
begin
|
|
if cbx_par.Checked then
|
|
begin
|
|
cbx_quit.Checked := not cbx_par.Checked;
|
|
lbl_tppagamento1.Caption := 'Entrada:';
|
|
cbx_tppagamento1.Clear;
|
|
cbx_tppagamento1.Items.Add('Dinheiro');
|
|
cbx_tppagamento1.Items.Add('Débito');
|
|
cbx_tppagamento1.Items.Add('Cheque');
|
|
cbx_tppagamento1.Items.Add('Crédito');
|
|
cbx_tppagamento1.ItemIndex := 0;
|
|
lbl_tppagamento2.Enabled := cbx_par.Checked;
|
|
cbx_tppagamento2.Enabled := cbx_par.Checked;
|
|
cbx_tppagamento2.ItemIndex := 0;
|
|
cbx_empacord.Enabled := true;
|
|
end
|
|
else
|
|
begin
|
|
cbx_empacord.Enabled := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmFechamentoAtendimento.cbx_quitClick(Sender: TObject);
|
|
begin
|
|
if cbx_quit.Checked then
|
|
begin
|
|
cbx_par.Checked := not cbx_quit.Checked;
|
|
lbl_tppagamento1.Caption := 'À vista:';
|
|
cbx_tppagamento1.Clear;
|
|
cbx_tppagamento1.Items.Add('Dinheiro');
|
|
cbx_tppagamento1.Items.Add('Débito');
|
|
cbx_tppagamento1.Items.Add('Cheque');
|
|
cbx_tppagamento1.ItemIndex := 0;
|
|
lbl_tppagamento2.Enabled := not cbx_quit.Checked;
|
|
cbx_tppagamento2.Enabled := not cbx_quit.Checked;
|
|
cbx_tppagamento2.ItemIndex := -1;
|
|
cbx_empacord.Enabled := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmFechamentoAtendimento.FormClose(Sender: TObject;
|
|
var Action: TCloseAction);
|
|
begin
|
|
inherited;
|
|
zroqryAcordosEmp.Close;
|
|
end;
|
|
|
|
procedure TfrmFechamentoAtendimento.FormCreate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frmAtendimento.acordo_fora := false;
|
|
zroqryAcordosEmp.SQL.Text := 'SELECT ID_EMPRESA, TX_FANTASIA FROM CHG_EMPRESAS ORDER BY TX_FANTASIA';
|
|
zroqryAcordosEmp.Open;
|
|
end;
|
|
|
|
procedure TfrmFechamentoAtendimento.WMMoving(var Msg: TWMMoving);
|
|
var
|
|
workArea: TRect;
|
|
begin
|
|
workArea := Screen.WorkareaRect;
|
|
|
|
with Msg.DragRect^ do
|
|
begin
|
|
if left < workArea.left then
|
|
OffsetRect(Msg.DragRect^, workArea.left - left, 0);
|
|
|
|
if top < workArea.top then
|
|
OffsetRect(Msg.DragRect^, 0, workArea.top - top);
|
|
|
|
if Right > workArea.Right then
|
|
OffsetRect(Msg.DragRect^, workArea.Right - Right, 0);
|
|
|
|
if Bottom > workArea.Bottom then
|
|
OffsetRect(Msg.DragRect^, 0, workArea.Bottom - Bottom);
|
|
end;
|
|
|
|
end;
|
|
|
|
end.
|