unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ZAbstractRODataset, ZAbstractDataset, ZDataset,
ZConnection, Inifiles, ComCtrls, TabNotBk, Grids, Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
ZQuery1: TZQuery;
Button3: TButton;
ComboBox1: TComboBox;
Label31: TLabel;
Label46: TLabel;
Label32: TLabel;
Label47: TLabel;
Label33: TLabel;
Label48: TLabel;
Label34: TLabel;
Label49: TLabel;
Label35: TLabel;
Label50: TLabel;
Label36: TLabel;
Label51: TLabel;
Label37: TLabel;
Label52: TLabel;
Label38: TLabel;
Label53: TLabel;
Label39: TLabel;
Label54: TLabel;
Label40: TLabel;
Label55: TLabel;
Label41: TLabel;
Label56: TLabel;
Label42: TLabel;
Label57: TLabel;
Label43: TLabel;
Label58: TLabel;
Label44: TLabel;
Label59: TLabel;
Label45: TLabel;
Label60: TLabel;
ZConnection1: TZConnection;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
idcuenta : string;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2, unit3 ;
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var trabajador : string ;
begin
IF edit1.text= '' then
begin
Application.MessageBox(
pchar( 'Proporciona el numero de trabajador'),
pchar('Error'),
0+48+0) ;
end
ELSE
begin
trabajador := edit1.Text;
ZQuery1.SQL.Text:='SELECT DISTINCT cuenta.nombre, cuenta.no_credito FROM cuenta WHERE cuenta.folio LIKE "%' +
trabajador +
'" ORDER BY cuenta.nombre ASC' ;
Zquery1.Open;
While not ZQuery1.Eof do
begin
ComboBox1.Items.add(ZQuery1.Fields[1].Text );
ZQuery1.Next ;
Label48.Caption := (ZQuery1.Fields[0].Text);
Button2.enabled:=false;
button3.Enabled:=true;
end;
Zquery1.Close ;
button1.enabled:=false ;
button2.enabled:= false ;
button3.enabled:= true ;
end
end;
procedure TForm1.Button3Click(Sender: TObject);
var trabajador, credito, query : string;
begin
IF Combobox1.text='' then
Application.MessageBox(
pchar( 'Selecciona un credito'),
pchar('Error'),
0+16+0)
ELSE begin
Zquery1.close;
trabajador:=edit1.text;
credito:=Combobox1.text;
query := 'SELECT cuenta.id_cuenta, cuenta.folio, cuenta.no_credito, cuenta.nombre, cuenta.rfc,' +
'cuenta.colonia, cuenta.domicilio, cuenta.ciudad, cuenta.cp, cuenta.tel_domicilio_1, '+
'cuenta.tel_domicilio_2, cuenta.tel_celular, cuenta.comercio, `status`.`status`, saldo.saldo, ' +
'cuenta.fecha_1 FROM cuenta Inner Join `status` ON cuenta.id_status = ' +
'`status`.id_status Inner Join saldo ON cuenta.id_cuenta = saldo.id_cuenta WHERE cuenta.folio = "' +
trabajador +'" AND cuenta.no_credito = "' + credito +
' " GROUP BY cuenta.id_cuenta ORDER BY saldo.fecha ASC';
Zquery1.SQL.Text:= query ;
Zquery1.Open ;
if ZQuery1.RecordCount > 0 then
begin
idcuenta:=Zquery1.Fields[0].text ;
label1.caption:= idcuenta;
label46.caption:=Zquery1.Fields[1].text ;
label47.caption:=Zquery1.Fields[2].text ;
label48.caption:=Zquery1.Fields[3].text ;
label49.caption:=Zquery1.Fields[4].text ;
label50.caption:=Zquery1.Fields[5].text ;
label51.caption:=Zquery1.Fields[6].text ;
label52.caption:=Zquery1.Fields[7].text ;
label53.caption:=Zquery1.Fields[8].text ;
label54.caption:=Zquery1.Fields[9].text ;
label55.caption:=Zquery1.Fields[10].text ;
label56.caption:=Zquery1.Fields[11].text ;
label58.caption:=Zquery1.Fields[12].text ;
label60.caption:=Zquery1.Fields[13].text ;
label59.caption:=Zquery1.Fields[14].text ;
label57.caption:=Zquery1.Fields[15].text ;
end;
end;
Zquery1.close ;
bitbtn1.enabled:= true;
end;
procedure TForm1.FormCreate(Sender: TObject);
var capt : string ;
catalog, database, hostname, password, protocol, user : string ;
inifile: TInifile ;
const saltolinea = #10#13 ;
begin
capt := 'Nueva' + saltolinea + 'Busqueda';
bitbtn1.caption:=capt;
Inifile := TInifile.Create(ExtractFilePath(Application.ExeName)+'mysql.ini');
catalog:=Inifile.ReadString('DB','catalog','');
database:=Inifile.ReadString('DB','database','');
hostname:=Inifile.ReadString('DB','hostname','');
password:=Inifile.ReadString('DB','password','');
protocol:=Inifile.ReadString('DB','protocol','');
user:=Inifile.ReadString('DB','user','');
zconnection1.catalog:= catalog;
zconnection1.database:=database;
zconnection1.hostname:=hostname;
zconnection1.password:=password;
zconnection1.protocol:=protocol;
zconnection1.user:=user;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
button2.enabled:=true ;
button3.enabled:=false ;
button1.enabled:= true ;
bitbtn1.enabled:= false;
Edit1.text:='';
ComboBox1.items.clear ;
combobox1.text:='' ;
label46.caption :='' ;
label47.caption:='' ;
label48.caption:='' ;
label49.caption:='' ;
label50.caption:='' ;
label51.caption:='' ;
label52.caption:='' ;
label53.caption:='' ;
label54.caption:='' ;
label55.caption:='' ;
label56.caption:='' ;
label57.caption:='' ;
label58.caption:='' ;
label59.caption:='' ;
label60.caption:='' ;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
form2.showmodal
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
form3.show
end;
end.