unit kunden_suche_form;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
Tkunden_suche =
class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
edit_kundennummer: TEdit;
GroupBox2: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
user_sheet: TStringGrid;
Button1: TButton;
Button2: TButton;
procedure user_sheetClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private-Deklarationen }
public
zelle : integer;
end;
var
kunden_suche: Tkunden_suche;
implementation
uses hauptformular, kundendaten_view_form;
{$R *.dfm}
procedure Tkunden_suche.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
hs_kis.StatusBar1.Panels[0].Text := '
Status: Fenster "Kundensuche" erfolgreich geschlossen';
end;
procedure Tkunden_suche.FormShow(Sender: TObject);
begin
hs_kis.StatusBar1.Panels[0].Text := '
Status: Fenster "Kundensuche" erfolgreich generiert';
with user_sheet
do
begin
Cells[0,0] := '
Kundennummer';
Cells[1,0] := '
Name';
Cells[2,0] := '
Vorname';
Cells[3,0] := '
Firma';
Cells[4,0] := '
Sprache';
end;
end;
procedure Tkunden_suche.Button1Click(Sender: TObject);
var kundennummer, cr, i, j : integer;
sql :
string;
ex : boolean;
begin
if edit_kundennummer.Text <> '
'
then
begin
try kundennummer := strtoint(edit_kundennummer.Text)
except on EConvertError
do
hs_kis.StatusBar1.Panels[0].Text := '
Status: Fehler - Das ist keine Kundennummer!';
end;
hs_kis.FMysql.select_db('
syscp');
sql := '
SELECT customernumber, name, firstname, company, def_language FROM panel_customers WHERE customernumber = "'+inttostr(kundennummer)+'
"';
hs_kis.FResult := hs_kis.FMysql.query(
sql, true, ex);
if assigned(hs_kis.FResult)
then
begin
cr := hs_kis.FResult.RecNo;
user_sheet.RowCount := hs_kis.FResult.RowsCount+1;
for i:=0
to hs_kis.FResult.RowsCount-1
do begin
for j:=0
to hs_kis.FResult.FieldsCount-1
do
user_sheet.Cells[j,i+1] := hs_kis.FResult.FieldValue(j);
hs_kis.FResult.Next;
end;
if i = 1
then
hs_kis.StatusBar1.Panels[0].Text := '
Status: '+inttostr(i)+'
Datensatz gefunden'
else
hs_kis.StatusBar1.Panels[0].Text := '
Status: '+inttostr(i)+'
Datensätze gefunden';
if i > 0
then
button2.Enabled := true
else
begin
user_sheet.RowCount := 2;
user_sheet.FixedRows := 1;
end;
if i > 1242900
then
begin
user_sheet.RowCount := 2;
user_sheet.FixedRows := 1;
button2.Enabled := false;
hs_kis.StatusBar1.Panels[0].Text := '
Status: 0 Datensätze gefunden';
end;
end
else
begin
hs_kis.StatusBar1.Panels[0].Text := '
Status: Query konnte nicht ausgeführt werden';
end;
end
else
begin
//Wenn KD Nr nicht ausgefüllt
end;
end;
procedure Tkunden_suche.Button2Click(Sender: TObject);
begin
FreeAndNil(hs_kis.FResult);
Tkundendaten_view.Create(kunden_suche);
end;
procedure Tkunden_suche.user_sheetClick(Sender: TObject);
begin
zelle := user_sheet.Row;
end;
end.