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.
156 lines
4.0 KiB
156 lines
4.0 KiB
unit ufrmEscolheLayout;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.DBCtrls, Data.DB;
|
|
|
|
type
|
|
TfrmEscolheLayout = class(TForm)
|
|
dtsLayout: TDataSource;
|
|
DBLookupComboBox1: TDBLookupComboBox;
|
|
lbl_layout: TLabel;
|
|
btn_ok: TButton;
|
|
btn_cancel: TButton;
|
|
DBLookupComboBox2: TDBLookupComboBox;
|
|
lbl_beneficiario: TLabel;
|
|
DBLookupComboBox3: TDBLookupComboBox;
|
|
Label1: TLabel;
|
|
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|
procedure btn_okClick(Sender: TObject);
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
|
|
MousePos: TPoint; var Handled: Boolean);
|
|
procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
|
|
MousePos: TPoint; var Handled: Boolean);
|
|
private
|
|
procedure WMMoving(var Msg: TWMMoving); message WM_MOVING;
|
|
{ Private declarations }
|
|
public
|
|
id_emp: integer;
|
|
id_prov: integer;
|
|
escolheu: Boolean;
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frmEscolheLayout: TfrmEscolheLayout;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses udtmSystem, uimpDevedores, ucadDevedores;
|
|
|
|
procedure TfrmEscolheLayout.btn_okClick(Sender: TObject);
|
|
var
|
|
erro: string;
|
|
begin
|
|
// impDevedores.id_emp := DBLookupComboBox2.KeyValue;
|
|
erro := '';
|
|
// if (DBLookupComboBox1.KeyValue = -1) or (DBLookupComboBox2.KeyValue = -1) or
|
|
// (DBLookupComboBox3.KeyValue = -1) then
|
|
// begin
|
|
// MessageDlg
|
|
// ('Por favor escolha corretamente a empresa/layout/providência antes de importar.',
|
|
// mtWarning, [mbOK], 0);
|
|
// abort;
|
|
// end;
|
|
if (DBLookupComboBox1.KeyValue = Null) then
|
|
begin
|
|
erro := erro + 'Layout/';
|
|
end;
|
|
if (DBLookupComboBox2.KeyValue = Null) then
|
|
begin
|
|
erro := erro + 'Credor/';
|
|
end;
|
|
if (DBLookupComboBox3.KeyValue = Null) then
|
|
begin
|
|
erro := erro + 'Providência/';
|
|
end;
|
|
if erro <> '' then
|
|
begin
|
|
setlength(erro, length(erro) - 1);
|
|
if MessageDlg('Você está prestes a realizar uma importação sem ' + erro +
|
|
' definido/os. Deseja Continuar?', mtWarning, mbYesNo, 0) = mrno then
|
|
begin
|
|
abort;
|
|
end;
|
|
end;
|
|
dtmSystem.tblCHGEmpresa.Locate('ID_EMPRESA', DBLookupComboBox2.KeyValue, []);
|
|
dtmSystem.id_empimport := dtmSystem.tblCHGEmpresaID_EMPRESA.AsInteger;
|
|
if DBLookupComboBox3.KeyValue <> Null then
|
|
begin
|
|
id_prov := DBLookupComboBox3.KeyValue;
|
|
end;
|
|
escolheu := true;
|
|
end;
|
|
|
|
procedure TfrmEscolheLayout.FormCreate(Sender: TObject);
|
|
begin
|
|
escolheu := false;
|
|
if not(dtmSystem.tblCHGEmpresa.Active) then
|
|
begin
|
|
dtmSystem.tblCHGEmpresa.Open;
|
|
end;
|
|
if not(dtmSystem.tblProvidencias.Active) then
|
|
begin
|
|
dtmSystem.tblProvidencias.Open;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmEscolheLayout.FormKeyDown(Sender: TObject; var Key: Word;
|
|
Shift: TShiftState);
|
|
begin
|
|
if Key = VK_ESCAPE then
|
|
begin
|
|
Key := 0;
|
|
Close;
|
|
ModalResult := mrCancel;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmEscolheLayout.FormMouseWheelDown(Sender: TObject;
|
|
Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
|
|
begin
|
|
if (DBLookupComboBox1.Focused = true) then
|
|
begin
|
|
DBLookupComboBox1.Perform(WM_KEYDOWN, VK_DOWN, 0);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmEscolheLayout.FormMouseWheelUp(Sender: TObject;
|
|
Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
|
|
begin
|
|
if (DBLookupComboBox1.Focused = true) then
|
|
begin
|
|
DBLookupComboBox1.Perform(WM_KEYDOWN, VK_UP, 0);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmEscolheLayout.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.
|