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.
819 lines
22 KiB
819 lines
22 KiB
unit ufrmAgenda;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, Vcl.Buttons, System.DateUtils,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, umstLista, Data.DB, Vcl.StdCtrls,
|
|
Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.ComCtrls, Vcl.Grids, Vcl.DBGrids,
|
|
System.ImageList, Vcl.ImgList, System.UITypes, Vcl.Menus;
|
|
|
|
type
|
|
THackDBNavigator = class(TDBNavigator);
|
|
|
|
type
|
|
TfrmAgenda = class(TmstLista)
|
|
cb_filtro: TCheckBox;
|
|
ImageList1: TImageList;
|
|
Panel1: TPanel;
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
Panel2: TPanel;
|
|
Label3: TLabel;
|
|
Panel3: TPanel;
|
|
Label4: TLabel;
|
|
Panel4: TPanel;
|
|
Timer1: TTimer;
|
|
cb_filtro2: TCheckBox;
|
|
Panel5: TPanel;
|
|
Label5: TLabel;
|
|
edt_filtrauser: TEdit;
|
|
lbl_filtrauser: TLabel;
|
|
spdbtn_filtrauser: TSpeedButton;
|
|
ppmu_agenda: TPopupMenu;
|
|
AgendarDevedor1: TMenuItem;
|
|
MainMenu1: TMainMenu;
|
|
main_agenda: TMenuItem;
|
|
AgendarDevedor2: TMenuItem;
|
|
DBLookupComboBox1: TDBLookupComboBox;
|
|
dtsUsuarios: TDataSource;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure cb_filtroClick(Sender: TObject);
|
|
procedure grdListaDrawColumnCell(Sender: TObject; const Rect: TRect;
|
|
DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
procedure FormDestroy(Sender: TObject);
|
|
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|
procedure dtsDBDataChange(Sender: TObject; Field: TField);
|
|
procedure grdListaDblClick(Sender: TObject);
|
|
procedure Timer1Timer(Sender: TObject);
|
|
procedure cb_filtro2Click(Sender: TObject);
|
|
procedure spdbtn_filtrauserClick(Sender: TObject);
|
|
procedure AgendarDevedor1Click(Sender: TObject);
|
|
procedure AgendarDevedor2Click(Sender: TObject);
|
|
procedure edt_filtrauserKeyDown(Sender: TObject; var Key: Word;
|
|
Shift: TShiftState);
|
|
procedure grdListaColExit(Sender: TObject);
|
|
procedure grdListaKeyPress(Sender: TObject; var Key: Char);
|
|
procedure dtsDBStateChange(Sender: TObject);
|
|
procedure navPrincipalBeforeAction(Sender: TObject; Button: TNavigateBtn);
|
|
private
|
|
procedure SetupHackedNavigator(const Navigator: TDBNavigator;
|
|
const Glyphs: TImageList; S: string);
|
|
procedure WMMoving(var Msg: TWMMoving); message WM_MOVING;
|
|
procedure FiltraUser;
|
|
procedure Agendar;
|
|
procedure ChecaPermissoes;
|
|
|
|
{ Private declarations }
|
|
public
|
|
hoje: string;
|
|
filtro: TStringList;
|
|
old_id: integer;
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frmAgenda: TfrmAgenda;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses udtmSystem, ufrmCobranca, ucadDevedores, ufrmAgendamento;
|
|
|
|
procedure TfrmAgenda.Agendar;
|
|
begin
|
|
dtmSystem.tblDevedores.Locate('ID_DEVEDOR',
|
|
dtsDB.DataSet.FieldByName('ID_DEVEDOR').AsInteger, [loCaseInsensitive]);
|
|
frmAgendamento := TfrmAgendamento.Create(self);
|
|
frmAgendamento.edt_nomefiltro.Text := dtmSystem.tblDevedoresTX_NOME.AsString;
|
|
frmAgendamento.ShowModal;
|
|
end;
|
|
|
|
procedure TfrmAgenda.AgendarDevedor1Click(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
Agendar;
|
|
end;
|
|
|
|
procedure TfrmAgenda.AgendarDevedor2Click(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
Agendar;
|
|
end;
|
|
|
|
procedure TfrmAgenda.cb_filtro2Click(Sender: TObject);
|
|
begin
|
|
DateTimeToString(hoje, 'DD/MM/YYYY', date);
|
|
if dtmSystem.id_grupo = 1 then
|
|
begin
|
|
if cb_filtro.Checked then
|
|
begin
|
|
if cb_filtro2.Checked then
|
|
begin
|
|
filtro[0] := 'TP_SITUACAO = ''A'' ';
|
|
filtro[1] := '';
|
|
filtro[2] := '';
|
|
filtro[3] := ' and ';
|
|
filtro[4] := ' DT_AGENDADA >= ' + QuotedStr(hoje);
|
|
end
|
|
else
|
|
begin
|
|
filtro[0] := 'TP_SITUACAO = ''A'' ';
|
|
filtro[1] := '';
|
|
filtro[2] := '';
|
|
filtro[3] := '';
|
|
filtro[4] := '';
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if cb_filtro2.Checked then
|
|
begin
|
|
filtro[0] := '';
|
|
filtro[1] := '';
|
|
filtro[2] := '';
|
|
filtro[3] := '';
|
|
filtro[4] := ' DT_AGENDADA >= ' + QuotedStr(hoje);
|
|
end
|
|
else
|
|
begin
|
|
filtro[0] := '';
|
|
filtro[1] := '';
|
|
filtro[2] := '';
|
|
filtro[3] := '';
|
|
filtro[4] := '';
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if cb_filtro.Checked then
|
|
begin
|
|
if cb_filtro2.Checked then
|
|
begin
|
|
filtro[0] := 'TP_SITUACAO = ''A'' ';
|
|
filtro[1] := ' and ';
|
|
filtro[2] := 'ID_COBRADOR = ' +
|
|
QuotedStr(inttostr(dtmSystem.id_usuario));
|
|
filtro[3] := ' and ';
|
|
filtro[4] := ' DT_AGENDADA >= ' + QuotedStr(hoje);
|
|
end
|
|
else
|
|
begin
|
|
filtro[0] := 'TP_SITUACAO = ''A'' ';
|
|
filtro[1] := ' and ';
|
|
filtro[2] := 'ID_COBRADOR = ' +
|
|
QuotedStr(inttostr(dtmSystem.id_usuario));
|
|
filtro[3] := '';
|
|
filtro[4] := '';
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if cb_filtro2.Checked then
|
|
begin
|
|
filtro[0] := '';
|
|
filtro[1] := '';
|
|
filtro[2] := 'ID_COBRADOR = ' +
|
|
QuotedStr(inttostr(dtmSystem.id_usuario));
|
|
filtro[3] := ' and ';
|
|
filtro[4] := ' DT_AGENDADA >= ' + QuotedStr(hoje);
|
|
end
|
|
else
|
|
begin
|
|
filtro[0] := '';
|
|
filtro[1] := '';
|
|
filtro[2] := 'ID_COBRADOR = ' +
|
|
QuotedStr(inttostr(dtmSystem.id_usuario));
|
|
filtro[3] := '';
|
|
filtro[4] := '';
|
|
end;
|
|
end;
|
|
end;
|
|
// dtsDb.DataSet.Filtered := false;
|
|
FiltraUser;
|
|
dtsDB.DataSet.Filter := filtro[0] + filtro[1] + filtro[2] + filtro[3] +
|
|
filtro[4] + filtro[5];
|
|
// dtsDb.DataSet.Filtered := true;
|
|
|
|
dtsDB.DataSet.Refresh;
|
|
dtsDB.DataSet.First;
|
|
end;
|
|
|
|
procedure TfrmAgenda.cb_filtroClick(Sender: TObject);
|
|
begin
|
|
DateTimeToString(hoje, 'DD/MM/YYYY', date);
|
|
if dtmSystem.id_grupo = 1 then
|
|
begin
|
|
if cb_filtro.Checked then
|
|
begin
|
|
if cb_filtro2.Checked then
|
|
begin
|
|
filtro[0] := 'TP_SITUACAO = ''A'' ';
|
|
filtro[1] := '';
|
|
filtro[2] := '';
|
|
filtro[3] := ' and ';
|
|
filtro[4] := ' DT_AGENDADA >= ' + QuotedStr(hoje);
|
|
end
|
|
else
|
|
begin
|
|
filtro[0] := 'TP_SITUACAO = ''A'' ';
|
|
filtro[1] := '';
|
|
filtro[2] := '';
|
|
filtro[3] := '';
|
|
filtro[4] := '';
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if cb_filtro2.Checked then
|
|
begin
|
|
filtro[0] := '';
|
|
filtro[1] := '';
|
|
filtro[2] := '';
|
|
filtro[3] := '';
|
|
filtro[4] := ' DT_AGENDADA >= ' + QuotedStr(hoje);
|
|
end
|
|
else
|
|
begin
|
|
filtro[0] := '';
|
|
filtro[1] := '';
|
|
filtro[2] := '';
|
|
filtro[3] := '';
|
|
filtro[4] := '';
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if cb_filtro.Checked then
|
|
begin
|
|
if cb_filtro2.Checked then
|
|
begin
|
|
filtro[0] := 'TP_SITUACAO = ''A'' ';
|
|
filtro[1] := ' and ';
|
|
filtro[2] := 'ID_COBRADOR = ' +
|
|
QuotedStr(inttostr(dtmSystem.id_usuario));
|
|
filtro[3] := ' and ';
|
|
filtro[4] := ' DT_AGENDADA >= ' + QuotedStr(hoje);
|
|
end
|
|
else
|
|
begin
|
|
filtro[0] := 'TP_SITUACAO = ''A'' ';
|
|
filtro[1] := ' and ';
|
|
filtro[2] := 'ID_COBRADOR = ' +
|
|
QuotedStr(inttostr(dtmSystem.id_usuario));
|
|
filtro[3] := '';
|
|
filtro[4] := '';
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if cb_filtro2.Checked then
|
|
begin
|
|
filtro[0] := '';
|
|
filtro[1] := '';
|
|
filtro[2] := 'ID_COBRADOR = ' +
|
|
QuotedStr(inttostr(dtmSystem.id_usuario));
|
|
filtro[3] := ' and ';
|
|
filtro[4] := ' DT_AGENDADA >= ' + QuotedStr(hoje);
|
|
end
|
|
else
|
|
begin
|
|
filtro[0] := '';
|
|
filtro[1] := '';
|
|
filtro[2] := 'ID_COBRADOR = ' +
|
|
QuotedStr(inttostr(dtmSystem.id_usuario));
|
|
filtro[3] := '';
|
|
filtro[4] := '';
|
|
end;
|
|
end;
|
|
end;
|
|
// dtsDb.DataSet.Filtered := false;
|
|
FiltraUser;
|
|
dtsDB.DataSet.Filter := filtro[0] + filtro[1] + filtro[2] + filtro[3] +
|
|
filtro[4] + filtro[5];
|
|
// dtsDb.DataSet.Filtered := true;
|
|
|
|
dtsDB.DataSet.Refresh;
|
|
dtsDB.DataSet.First;
|
|
end;
|
|
|
|
procedure TfrmAgenda.ChecaPermissoes;
|
|
begin
|
|
with dtmSystem do
|
|
begin
|
|
if not dtmSystem.id_grupo = 1 then
|
|
begin
|
|
navPrincipal.VisibleButtons := navPrincipal.VisibleButtons - [nbEdit];
|
|
lbl_filtrauser.Visible := false;
|
|
edt_filtrauser.Visible := false;
|
|
spdbtn_filtrauser.Visible := false;
|
|
grdLista.Columns[0].Visible := false;
|
|
grdLista.Options := grdLista.Options - [dgEditing];
|
|
end
|
|
else
|
|
begin
|
|
lbl_filtrauser.Visible := true;
|
|
edt_filtrauser.Visible := true;
|
|
spdbtn_filtrauser.Visible := true;
|
|
grdLista.Columns[0].Visible := true;
|
|
grdLista.Columns[0].Width := 100;
|
|
end;
|
|
if not dtmSystem.id_grupo = 1 then
|
|
begin
|
|
navPrincipal.VisibleButtons := navPrincipal.VisibleButtons - [nbDelete];
|
|
end;
|
|
if not dtmSystem.id_grupo = 1 then
|
|
begin
|
|
lbl_filtrauser.Visible := false;
|
|
edt_filtrauser.Visible := false;
|
|
spdbtn_filtrauser.Visible := false;
|
|
grdLista.Columns[0].Visible := false;
|
|
grdLista.Options := grdLista.Options - [dgEditing];
|
|
filtro.Add('TP_SITUACAO = ''A'' ');
|
|
filtro.Add(' and ');
|
|
filtro.Add('ID_COBRADOR = ' + QuotedStr(inttostr(dtmSystem.id_usuario)));
|
|
filtro.Add(' and ');
|
|
filtro.Add(' DT_AGENDADA >= ' + QuotedStr(hoje));
|
|
filtro.Add('');
|
|
end
|
|
else
|
|
begin
|
|
filtro.Add('TP_SITUACAO = ''A'' ');
|
|
filtro.Add('');
|
|
filtro.Add('');
|
|
filtro.Add(' and ');
|
|
filtro.Add(' DT_AGENDADA >= ' + QuotedStr(hoje));
|
|
filtro.Add('');
|
|
lbl_filtrauser.Visible := true;
|
|
edt_filtrauser.Visible := true;
|
|
spdbtn_filtrauser.Visible := true;
|
|
grdLista.Columns[0].Visible := true;
|
|
grdLista.Columns[0].Width := 100;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAgenda.dtsDBDataChange(Sender: TObject; Field: TField);
|
|
var
|
|
new_id: Integer;
|
|
begin
|
|
// inherited;
|
|
new_id := dtsDB.DataSet.FieldByName('ID_AGENDA').AsInteger;
|
|
if old_id <> new_id then
|
|
begin
|
|
old_id := new_id;
|
|
DBLookupComboBox1.Visible := false;
|
|
end;
|
|
grdLista.Repaint;
|
|
end;
|
|
|
|
procedure TfrmAgenda.dtsDBStateChange(Sender: TObject);
|
|
begin
|
|
// inherited;
|
|
if dtsDB.DataSet.State in [dsEdit, dsInsert] then
|
|
begin
|
|
DBLookupComboBox1.Visible := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAgenda.edt_filtrauserKeyDown(Sender: TObject; var Key: Word;
|
|
Shift: TShiftState);
|
|
begin
|
|
// inherited;
|
|
if Key = VK_RETURN then
|
|
begin
|
|
FiltraUser;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAgenda.FiltraUser;
|
|
begin
|
|
if edt_filtrauser.Text <> '' then
|
|
begin
|
|
if (dtmSystem.tblUsuariosConsulta.Locate('TX_NOME', edt_filtrauser.Text,
|
|
[loCaseInsensitive, loPartialKey])) then
|
|
begin
|
|
if (cb_filtro.Checked) or (cb_filtro2.Checked) then
|
|
begin
|
|
filtro[5] := 'and ID_COBRADOR = ' +
|
|
dtmSystem.tblUsuariosConsultaID_USUARIO.AsString;
|
|
end
|
|
else
|
|
begin
|
|
filtro[5] := 'ID_COBRADOR = ' +
|
|
dtmSystem.tblUsuariosConsultaID_USUARIO.AsString;
|
|
end;
|
|
end
|
|
else if (dtmSystem.tblUsuariosConsulta.Locate('TX_USUARIO',
|
|
edt_filtrauser.Text, [loCaseInsensitive, loPartialKey])) then
|
|
begin
|
|
if (cb_filtro.Checked) or (cb_filtro2.Checked) then
|
|
begin
|
|
filtro[5] := 'and ID_COBRADOR = ' +
|
|
dtmSystem.tblUsuariosConsultaID_USUARIO.AsString;
|
|
end
|
|
else
|
|
begin
|
|
filtro[5] := 'ID_COBRADOR = ' +
|
|
dtmSystem.tblUsuariosConsultaID_USUARIO.AsString;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
filtro[5] := '';
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
filtro[5] := '';
|
|
end;
|
|
dtsDB.DataSet.Filter := filtro[0] + filtro[1] + filtro[2] + filtro[3] +
|
|
filtro[4] + filtro[5];
|
|
dtsDB.DataSet.Refresh;
|
|
end;
|
|
|
|
procedure TfrmAgenda.FormClose(Sender: TObject; var Action: TCloseAction);
|
|
begin
|
|
inherited;
|
|
dtsDB.DataSet.Filtered := false;
|
|
Action := caFree;
|
|
end;
|
|
|
|
procedure TfrmAgenda.FormCreate(Sender: TObject);
|
|
begin
|
|
// old_id := -1;
|
|
// if not dtmSystem.tblUsuariosConsulta.Active then
|
|
// begin
|
|
// dtmSystem.tblUsuariosConsulta.Open;
|
|
// end;
|
|
// if not dtmSystem.tblDevedores.Active then
|
|
// begin
|
|
// dtmSystem.tblDevedores.Open;
|
|
// end;
|
|
// filtro := TStringList.Create;
|
|
// dtsDB.DataSet.Open;
|
|
// dtsDB.DataSet.Filtered := false;
|
|
// DateTimeToString(hoje, 'DD/MM/YYYY', date);
|
|
// if dtmSystem.id_grupo = 1 then
|
|
// begin
|
|
// if not dtmSystem.tblUsuariosConsulta.Active then
|
|
// begin
|
|
// dtmSystem.tblUsuariosConsulta.Open;
|
|
// end;
|
|
// grdLista.Columns[0].Visible := true;
|
|
// grdLista.Columns[0].Width := 100;
|
|
// grdLista.Columns[2].ReadOnly := false;
|
|
// grdLista.Columns[3].ReadOnly := false;
|
|
// grdLista.Columns[4].Visible := true;
|
|
// spdbtn_filtrauser.Visible := true;
|
|
// edt_filtrauser.Visible := true;
|
|
// lbl_filtrauser.Visible := true;
|
|
// // grdLista.PopupMenu := ppmu_agenda;
|
|
// main_agenda.Visible := true;
|
|
// filtro.Add('TP_SITUACAO = ''A'' ');
|
|
// filtro.Add('');
|
|
// filtro.Add('');
|
|
// filtro.Add(' and ');
|
|
// filtro.Add(' DT_AGENDADA >= ' + QuotedStr(hoje));
|
|
// filtro.Add('');
|
|
// // dtsDB.DataSet.Filter := 'TP_SITUACAO = ''A''';
|
|
// dtsDB.DataSet.Filter := filtro[0] + filtro[1] + filtro[2] + filtro[3] +
|
|
// filtro[4] + filtro[5];
|
|
// grdLista.Options := grdLista.Options - [dgrowSelect] + [dgEditing];
|
|
// navPrincipal.VisibleButtons := navPrincipal.VisibleButtons + [nbEdit] +
|
|
// [nbPost] + [nbDelete];
|
|
// end
|
|
// else
|
|
// begin
|
|
// // dtsDB.DataSet.Filter := 'TP_SITUACAO = ''A'' and ID_COBRADOR = ' +
|
|
// // QuotedStr(inttostr(dtmSystem.id_usuario));
|
|
// filtro.Add('TP_SITUACAO = ''A'' ');
|
|
// filtro.Add(' and ');
|
|
// filtro.Add('ID_COBRADOR = ' + QuotedStr(inttostr(dtmSystem.id_usuario)));
|
|
// filtro.Add(' and ');
|
|
// filtro.Add(' DT_AGENDADA >= ' + QuotedStr(hoje));
|
|
// filtro.Add('');
|
|
// dtsDB.DataSet.Filter := filtro[0] + filtro[1] + filtro[2] + filtro[3] +
|
|
// filtro[4] + filtro[5];
|
|
// // dtsDB.DataSet.Filter := 'TP_SITUACAO = ''A'' and ID_COBRADOR = ' +
|
|
// // QuotedStr(inttostr(dtmSystem.id_usuario)) + ' and DT_AGENDADA >= ' +
|
|
// // QuotedStr(hoje);
|
|
// end;
|
|
// dtsDB.DataSet.Filtered := true;
|
|
// SetupHackedNavigator(navPrincipal, ImageList1, 's');
|
|
// stbStatus.Panels[0].Text := 'Usuário: ' + dtmSystem.tx_usuario;
|
|
// stbStatus.Panels[1].Text := 'Banco de dados: ' +
|
|
// dtmSystem.ZConnection.Database;
|
|
|
|
old_id := -1;
|
|
if not dtmSystem.tblUsuariosConsulta.Active then
|
|
begin
|
|
dtmSystem.tblUsuariosConsulta.Open;
|
|
end;
|
|
if not dtmSystem.tblDevedores.Active then
|
|
begin
|
|
dtmSystem.tblDevedores.Open;
|
|
end;
|
|
filtro := TStringList.Create;
|
|
dtsDB.DataSet.Open;
|
|
dtsDB.DataSet.Filtered := false;
|
|
DateTimeToString(hoje, 'DD/MM/YYYY', date);
|
|
if not dtmSystem.tblUsuariosConsulta.Active then
|
|
begin
|
|
dtmSystem.tblUsuariosConsulta.Open;
|
|
end;
|
|
|
|
ChecaPermissoes;
|
|
// if dtmSystem.id_grupo = 1 then
|
|
// begin
|
|
// grdLista.Columns[0].Visible := true;
|
|
// grdLista.Columns[0].Width := 100;
|
|
// grdLista.Columns[2].ReadOnly := false;
|
|
// grdLista.Columns[3].ReadOnly := false;
|
|
// grdLista.Columns[4].Visible := true;
|
|
// spdbtn_filtrauser.Visible := true;
|
|
// edt_filtrauser.Visible := true;
|
|
// lbl_filtrauser.Visible := true;
|
|
//
|
|
// dtsDB.DataSet.Filter := filtro[0] + filtro[1] + filtro[2] + filtro[3] +
|
|
// filtro[4] + filtro[5];
|
|
// grdLista.Options := grdLista.Options - [dgrowSelect] + [dgEditing];
|
|
// navPrincipal.VisibleButtons := navPrincipal.VisibleButtons + [nbEdit] +
|
|
// [nbPost] + [nbDelete];
|
|
// end;
|
|
|
|
dtsDB.DataSet.Filter := filtro[0] + filtro[1] + filtro[2] + filtro[3] +
|
|
filtro[4] + filtro[5];
|
|
dtsDB.DataSet.Filtered := true;
|
|
SetupHackedNavigator(navPrincipal, ImageList1, 's');
|
|
stbStatus.Panels[0].Text := 'Usuário: ' + dtmSystem.tx_usuario;
|
|
stbStatus.Panels[1].Text := 'Banco de dados: ' +
|
|
dtmSystem.ZConnection.Database;
|
|
|
|
|
|
end;
|
|
|
|
procedure TfrmAgenda.FormDestroy(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frmAgenda := nil;
|
|
end;
|
|
|
|
procedure TfrmAgenda.FormKeyDown(Sender: TObject; var Key: Word;
|
|
Shift: TShiftState);
|
|
begin
|
|
if Key = VK_ESCAPE then
|
|
begin
|
|
Key := 0;
|
|
Close;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAgenda.grdListaColExit(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if grdLista.SelectedField.FieldName = 'NOME_COBRADOR' then
|
|
DBLookupComboBox1.Visible := false
|
|
end;
|
|
|
|
procedure TfrmAgenda.grdListaDblClick(Sender: TObject);
|
|
var
|
|
helper: Integer;
|
|
begin
|
|
if not(dtsDB.State in [dsInsert, dsEdit]) then
|
|
begin
|
|
if not dtmSystem.tblDevedores.Active then
|
|
begin
|
|
dtmSystem.tblDevedores.Open;
|
|
end;
|
|
if dtmSystem.tblDevedores.Locate('ID_DEVEDOR',
|
|
dtsDB.DataSet.FieldByName('ID_DEVEDOR').AsString, []) then
|
|
begin
|
|
helper := dtmSystem.tblDevedores.recno;
|
|
|
|
cadDevedores := TcadDevedores.Create(self);
|
|
cadDevedores.pesquisa := helper;
|
|
timer1.Enabled := false;
|
|
cadDevedores.ShowModal;
|
|
timer1.Enabled := true;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAgenda.grdListaDrawColumnCell(Sender: TObject; const Rect: TRect;
|
|
DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
var
|
|
tempo1, tempo2, tempo3, hora_marcada, agora, quanto_falta: TTime;
|
|
dia_marcado, hoje: TDate;
|
|
dia_atrasado, tempo_atrasado, eh_hoje: boolean;
|
|
begin
|
|
if not(dtmSystem.tblAgenda.isempty) then
|
|
begin
|
|
dia_atrasado := false;
|
|
tempo_atrasado := false;
|
|
eh_hoje := false;
|
|
tempo1 := StrToTime('00:45:00');
|
|
tempo2 := StrToTime('00:15:00');
|
|
tempo3 := StrToTime('00:00:00');
|
|
hora_marcada := StrToTime(FormatDateTime('t',
|
|
dtmSystem.tblAgendaHR_AGENDADA.AsDateTime));
|
|
dia_marcado := dtmSystem.tblAgendaDT_AGENDADA.AsDateTime;
|
|
agora := StrToTime(FormatDateTime('t', now));
|
|
quanto_falta := hora_marcada - agora;
|
|
hoje := date;
|
|
if (hoje > dia_marcado) then
|
|
begin
|
|
dia_atrasado := true;
|
|
end;
|
|
if (agora >= hora_marcada) then
|
|
begin
|
|
tempo_atrasado := true;
|
|
end;
|
|
if dia_marcado = date then
|
|
begin
|
|
eh_hoje := true;
|
|
end;
|
|
if dia_atrasado then
|
|
begin
|
|
if dtmSystem.tblAgendaTP_SITUACAO.AsString = 'B' then
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clSilver;
|
|
end
|
|
else
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clRed;
|
|
end;
|
|
end
|
|
else if (tempo_atrasado) and (eh_hoje) then
|
|
begin
|
|
if CompareTime(quanto_falta, tempo1) > 0 then
|
|
begin
|
|
if dtmSystem.tblAgendaTP_SITUACAO.AsString = 'B' then
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clSilver;
|
|
end
|
|
else
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clRed;
|
|
end;
|
|
end
|
|
else if (CompareTime(quanto_falta, tempo1) < 0) and
|
|
(CompareTime(quanto_falta, tempo2) >= 0) then
|
|
begin
|
|
if dtmSystem.tblAgendaTP_SITUACAO.AsString = 'B' then
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clSilver;
|
|
end
|
|
else
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clYellow;
|
|
end;
|
|
end
|
|
else if (CompareTime(quanto_falta, tempo2) < 0) and
|
|
(CompareTime(quanto_falta, tempo3) >= 0) then
|
|
begin
|
|
if dtmSystem.tblAgendaTP_SITUACAO.AsString = 'B' then
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clSilver;
|
|
end
|
|
else
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clGreen;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if dtmSystem.tblAgendaTP_SITUACAO.AsString = 'B' then
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clSilver;
|
|
end
|
|
else
|
|
begin
|
|
grdLista.Canvas.Brush.Color := clSkyBlue;
|
|
end;
|
|
end;
|
|
grdLista.DefaultDrawColumnCell(Rect, DataCol, Column, State);
|
|
end;
|
|
if (gdFocused in State) and (dtsDB.DataSet.State in [dsEdit, dsInsert]) then
|
|
begin
|
|
if (Column.Field.FieldName = 'NOME_COBRADOR') then
|
|
begin
|
|
with DBLookupComboBox1 do
|
|
begin
|
|
Left := Rect.Left + grdLista.Left + 2;
|
|
Top := Rect.Top + grdLista.Top + 2;
|
|
Width := Rect.Right - Rect.Left;
|
|
Width := Rect.Right - Rect.Left;
|
|
Height := Rect.Bottom - Rect.Top;
|
|
Visible := true;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TfrmAgenda.grdListaKeyPress(Sender: TObject; var Key: Char);
|
|
begin
|
|
inherited;
|
|
if (Key = Chr(9)) then
|
|
Exit;
|
|
if (grdLista.SelectedField.FieldName = 'NOME_COBRADOR') then
|
|
begin
|
|
DBLookupComboBox1.SetFocus;
|
|
SendMessage(DBLookupComboBox1.Handle, WM_Char, Word(Key), 0);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAgenda.navPrincipalBeforeAction(Sender: TObject;
|
|
Button: TNavigateBtn);
|
|
begin
|
|
DBLookupComboBox1.Visible := false;
|
|
// inherited;
|
|
end;
|
|
|
|
procedure TfrmAgenda.SetupHackedNavigator(const Navigator: TDBNavigator;
|
|
const Glyphs: TImageList; S: string);
|
|
const
|
|
Captions: array [TNavigateBtn] of string = ('Primeiro', 'Anterior', 'Próximo',
|
|
'Último', 'Adicionar', 'Excluir', 'Alterar', 'Confirmar', 'Cancelar',
|
|
'Atualizar', 'Aplicar Atualizações', 'Cancelar Atualizãções');
|
|
(* Captions : array[TNavigateBtn] of string =
|
|
('First', 'Prior', 'Next', 'Last', 'Insert',
|
|
'Delete', 'Edit', 'Post', 'Cancel', 'Refresh'); *)
|
|
Hints: array [TNavigateBtn] of string = ('Primeiro', 'Anterior', 'Próximo',
|
|
'Último', 'Adicionar', 'Apagar', 'Modificar', 'Confirmar', 'Cancelar',
|
|
'Atualizar', 'Aplicar Atualizações', 'Cancelar Atualizãções');
|
|
var
|
|
btn: TNavigateBtn;
|
|
begin
|
|
// função propriamente dita para "hackear" o navigator
|
|
for btn := Low(TNavigateBtn) to High(TNavigateBtn) do
|
|
with THackDBNavigator(Navigator).Buttons[btn] do
|
|
begin
|
|
// from the Captions const array
|
|
|
|
Hint := Hints[btn];
|
|
|
|
if LowerCase(S) = 's' then
|
|
begin
|
|
Caption := Captions[btn];
|
|
end;
|
|
|
|
// the number of images in the Glyph property
|
|
NumGlyphs := 1;
|
|
// Remove the old glyph.
|
|
Glyph := nil;
|
|
// Assign the custom one
|
|
Glyphs.GetBitmap(Integer(btn), Glyph);
|
|
// gylph above text
|
|
Layout := blGlyphTop;
|
|
|
|
Font.Style := Font.Style - [fsbold];
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAgenda.spdbtn_filtrauserClick(Sender: TObject);
|
|
begin
|
|
// inherited;
|
|
FiltraUser;
|
|
end;
|
|
|
|
procedure TfrmAgenda.Timer1Timer(Sender: TObject);
|
|
begin
|
|
// if not(dtsDB.State in [dsInsert, dsEdit]) then
|
|
// begin
|
|
// FiltraUser;
|
|
// dtsDB.DataSet.Refresh;
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmAgenda.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.
|