unit UFRQcentral;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Calendar, dateutils, DBCtrls, StdCtrls, Grids, DBGrids, db, ComCtrls,
Buttons, PngSpeedButton,shellapi;
type
TFRQcentral = class(TForm)
DBGrid1: TDBGrid;
Label1: TLabel;
DBTevento: TDBText;
DBTcliente: TDBText;
Label3: TLabel;
EDCSID: TEdit;
Label2: TLabel;
EDCLIENTE: TEdit;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label5: TLabel;
Label6: TLabel;
Label4: TLabel;
DBTdireccion: TDBText;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
DBTtelefono: TDBText;
DBTtelefono2: TDBText;
DBTfechaent: TDBText;
DBTPanel: TDBText;
DBTtipo: TDBText;
DBTciudad: TDBText;
DBTdircom: TDBText;
DBTnotacom: TDBText;
Label12: TLabel;
DBListBox1: TDBListBox;
BitBtn1: TBitBtn;
Label13: TLabel;
Label14: TLabel;
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure EDCLIENTEEnter(Sender: TObject);
procedure EDCLIENTEExit(Sender: TObject);
procedure EDCSIDEnter(Sender: TObject);
procedure EDCSIDExit(Sender: TObject);
procedure DBGrid1TitleClick(Column: TColumn);
procedure DBGrid1EditButtonClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure DateTimePicker1CloseUp(Sender: TObject);
procedure DateTimePicker2CloseUp(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ procedure DBGrid1PillaLaRueda(var Message: TMessage);}
{ Private declarations }
public
{ Public declarations }
end;
var
FRQcentral: TFRQcentral;
inicio, fin: string;
implementation
uses UDMmonitorenred, frmmonitoreoenred, _busy, UFRMNOTAS;
{$R *.dfm}
{type
TomaInvento = class(TControl);
procedure TFRQcentral.DBGrid1PillaLaRueda(var Message: TMessage);
var
Cuanto : short;
begin
if (Message.Msg = WM_MOUSEWHEEL) then begin
Cuanto:=HIWORD(Message.WParam);
Cuanto:=Cuanto div 120;
DbGrid1.DataSource.DataSet.MoveBy(-Cuanto);
end else TomaInvento(DBGrid1).WndProc(Message);
end;}
procedure TFRQcentral.FormShow(Sender: TObject);
begin
AnimateWindow( Handle, 400, AW_ACTIVATE or AW_SLIDE or AW_HOR_POSITIVE);
RedrawWindow( Handle, nil, 0, RDW_ERASE or RDW_FRAME or
RDW_INVALIDATE or RDW_ALLCHILDREN );
ACTIVECONTROL := EDCLIENTE;
dmmonitorenred.zqconsultas.SQL.clear;
DateTimePicker1.Date := (yesterday);
DateTimePicker2.date := (tomorrow);
inicio := formatdatetime('yyyy.mm.dd', datetimepicker1.date);
fin := formatdatetime('yyyy.mm.dd', datetimepicker2.date);
DBListBox1.Items.Clear;
EDCLIENTE.Clear;
FRQcentral.ActiveCONTROL:=FRQCENTRAL.EDCSID;
FRQcentral.EDCSID.TEXT :=(dmmonitorenred.zqactivasCSID.AsString);
end;
procedure TFRQcentral.FormCreate(Sender: TObject);
//var
// alto: integer;
begin
{DBGrid1.WindowProc := DBGrid1PillaLaRueda;}
KeyPreview := true;
// for alto := 20 to 377 do
// begin
// dbgrid1.Height := alto;
//end;
end;
procedure TFRQcentral.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_escape) then
begin
if (activecontrol = edcliente) or (activecontrol = edcsid) then
begin
edcliente.clear;
edcsid.clear;
end;
end;
begin
if activecontrol = edcliente then
edcsid.Clear;
if activecontrol = edcsid then
edcliente.clear;
if ((activecontrol = edcsid) or (activecontrol = edcliente)) and (key = 13)
then
dbgrid1.SetFocus;
end;
end;
procedure TFRQcentral.DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_escape) then
begin
EDCLIENTE.SetFocus;
edcliente.Clear;
end;
end;
procedure TFRQcentral.EDCLIENTEEnter(Sender: TObject);
begin
EDCLIENTE.color := clGradientInactiveCaption;
end;
procedure TFRQcentral.EDCLIENTEExit(Sender: TObject);
begin
EDCLIENTE.Color := clWindow;
end;
procedure TFRQcentral.EDCSIDEnter(Sender: TObject);
begin
EDCSID.color := clGradientInactiveCaption;
end;
procedure TFRQcentral.EDCSIDExit(Sender: TObject);
begin
EDCSID.Color := clWindow;
end;
procedure TFRQcentral.DBGrid1TitleClick(Column: TColumn);
var
ordenando: string;
begin
ordenando := Column.Title.Caption;
if ordenando = 'CSID' then
ORDENANDO := ' CENTRAL.CSID '
else if ORDENANDO = 'DETALLE' then
ORDENANDO := ' CENTRAL.DETALLE '
else
if ORDENANDO = 'DETALLE1' then
orDENANDO := ' evento.Detalle '
else
if ORDENANDO = 'EVENTO' THEN
ordenando := ' central.evento ';
inicio := formatdatetime('yyyy.mm.dd', datetimepicker1.date);
fin := formatdatetime('yyyy.mm.dd', datetimepicker2.date);
if edcliente.Text <> '' then
begin
dmmonitorenred.zqconsultas.SQL.clear;
dmmonitorenred.zqconsultas.SQL.Add('select * from central left join acmsub on central.csid=acmsub.csid ');
dmmonitorenred.zqconsultas.SQL.Add(' left JOIN evento ON CENTRAL.EVENTO = evento.Evento');
dmmonitorenred.zqconsultas.SQL.Add(' where ' + 'ACMSUB.clientes LIKE ' + quotedstr('%' + edcliente.Text + '%'));
dmmonitorenred.zqconsultas.SQL.Add(' and CENTRAL.FECHAN between ' + quotedstr(inicio) + ' and ' + quotedstr(fin));
dmmonitorenred.zqconsultas.SQL.Add(' order by ' + (ordenando));
dmmonitorenred.zqconsultas.Open;
end
else if edcsid.text <> '' then
begin
dmmonitorenred.zqconsultas.SQL.clear;
dmmonitorenred.zqconsultas.SQL.Add('select * from central left join acmsub on central.csid = acmsub.csid ');
dmmonitorenred.zqconsultas.SQL.Add(' left JOIN evento ON CENTRAL.EVENTO = evento.Evento ');
dmmonitorenred.zqconsultas.SQL.Add(' where CENTRAL.CSID like ' + QUOTEDSTR(EDCSID.TEXT + '%'));
dmmonitorenred.zqconsultas.SQL.Add(' and CENTRAL.FECHAN between ' + quotedstr(inicio) + 'and' + quotedstr(fin));
dmmonitorenred.zqconsultas.SQL.add(' order by ' + (ordenando));
dmmonitorenred.zqconsultas.Open;
end;
end;
procedure TFRQcentral.DBGrid1EditButtonClick(Sender: TObject);
var
telefono:string;
CUALBOTON:INTEGER;
begin
CUALBOTON:=(DBgrid1.SELECTEDINDEX+1);
//ShowMessage(IntToStr(DBgrid1.SelectedIndex+1));
if CUALBOTON=3 then
BEGIN
EDCLIENTE.Text:= DMmonitorenred.ZQconsultasCLIENTES.AsString;
FRQcentral.ActiveCONTROL:=FRQCENTRAL.BitBtn1;
END
ELSE
If CUALBOTON=8 then
begin
telefono:=dmmonitorenred.zqconsultasDETALLE.AsString;
telefono:=(copy(telefono,5,8));
dmmonitorenred.ZQconsuldetalle.SQL.clear;
dmmonitorenred.ZQconsuldetalle.SQL.Add('SELECT * from acmsub ');
dmmonitorenred.ZQconsuldetalle.SQL.Add('WHERE telefono LIKE ' + quotedstr('%' + telefono + '%'));
dmmonitorenred.ZQconsuldetalle.Open;
DBListBox1.Items.Clear;
DBListBox1.Items.Add(dmmonitorenred.ZQconsuldetalleCSID.AsString + ' ' + dmmonitorenred.ZQconsuldetalleCLIENTES.AsString);
end;
end;
procedure TFRQcentral.BitBtn1Click(Sender: TObject);
var
cc:integer;
begin
if EDCLIENTE.TEXT <> '' then
begin
BusyBegin('realizando busqueda, espere...', Application.Handle);
dmmonitorenred.zqconsultas.SQL.clear;
dmmonitorenred.zqconsultas.SQL.Add('SELECT * from central left join acmsub on central.csid=acmsub.csid ');
dmmonitorenred.zqconsultas.SQL.Add('left JOIN evento ON CENTRAL.EVENTO = evento.Evento');
dmmonitorenred.zqconsultas.SQL.Add(' where ' + ' (upper(ACMSUB.clientes COLLATE ES_ES_CI_AI )) LIKE ' +quotedstr('%' + edcliente.Text + '%')+'');
dmmonitorenred.zqconsultas.SQL.Add(' and CENTRAL.FECHAN between ' + quotedstr(inicio) + 'and' + quotedstr(fin));
dmmonitorenred.zqconsultas.SQL.Add('ORDER BY CENTRAL.FECHAn');
dmmonitorenred.zqconsultas.Open;
cc:=DMmonitorenred.ZQconsultas.RecordCount;
Label13.Visible:=TRUE;
Label14.Visible:=TRUE;
label13.Caption:= inttostr(cc);
Sleep(1); //aqui es donde le das el tiempo para cerrarse en milisegundos
BusyEnd;
end
ELSE
if EDCSID.TEXT <> '' then
begin
BusyBegin('realizando busqueda, espere...', Application.Handle);
dmmonitorenred.zqconsultas.SQL.clear;
dmmonitorenred.zqconsultas.SQL.Add('SELECT * from central left join acmsub on central.csid=acmsub.csid ');
dmmonitorenred.zqconsultas.SQL.Add('left JOIN evento ON CENTRAL.EVENTO = evento.Evento');
dmmonitorenred.zqconsultas.SQL.Add('WHERE CENTRAL.CSID LIKE ' + quotedstr('%' +
edcsid.Text + '%'));
dmmonitorenred.zqconsultas.SQL.Add(' and CENTRAL.FECHAN between ' +
quotedstr(inicio) + 'and' + quotedstr(fin));
dmmonitorenred.zqconsultas.SQL.add('order by central.fechan');
dmmonitorenred.zqconsultas.Open;
cc:=DMmonitorenred.ZQconsultas.RecordCount;
Label13.Visible:=TRUE;
Label14.Visible:=TRUE;
label13.Caption:=inttostr(cc);
Sleep(5); //aqui es donde le das el tiempo para cerrarse en milisegundos
BusyEnd;
end;
end;
procedure TFRQcentral.DateTimePicker1CloseUp(Sender: TObject);
begin
inicio := formatdatetime('yyyy.mm.dd', datetimepicker1.date);
end;
procedure TFRQcentral.DateTimePicker2CloseUp(Sender: TObject);
begin
fin := formatdatetime('yyyy.mm.dd', datetimepicker2.date);
end;
procedure TFRQcentral.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
Label13.visible:=false;
label14.visible:=false;
end;
end.