unit ku_bearb;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, umysqlvio, uMysqlCT, uMysqlClient, uMysqlHelpers, ku_suche;
{$I mysqlinc.inc}
type
Tku_bea =
class(TFrame)
GroupBox1: TGroupBox;
Label10: TLabel;
Label9: TLabel;
Label8: TLabel;
Label7: TLabel;
Label5: TLabel;
Label4: TLabel;
Label3: TLabel;
Label1: TLabel;
ku_bea_plz: TEdit;
ku_bea_vname: TEdit;
ku_bea_strasse: TEdit;
ku_bea_hsnr: TEdit;
ku_bea_nname: TEdit;
ku_bea_tel: TEdit;
ku_bea_fax: TEdit;
ku_bea_url: TEdit;
ku_bea_email: TEdit;
ku_bea_zusatz: TMemo;
GroupBox2: TGroupBox;
Button2: TButton;
ku_bea_ort: TComboBox;
Button3: TButton;
Button1: TButton;
Label2: TLabel;
Button4: TButton;
GroupBox3: TGroupBox;
u_hinweis: TLabel;
ku_bea_kdnr: TEdit;
Label11: TLabel;
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ku_bea_plzChange(Sender: TObject);
procedure ku_bea_kdnrChange(Sender: TObject);
private
FMysql: TMysqlClient;
FResult: TMysqlResult;
public
{ Public-Deklarationen }
end;
var
kd_nname, kd_vname, kd_strasse, kd_hsnr, kd_plz, kd_ort, kd_email:
string;
kd_url, kd_zusatz, kd_tel, kd_fax:
string;
TKu_suche1: TFrame;
anz_frame: TFrame;
anz_frame2: TFrame;
implementation
uses haupt;
{$R *.dfm}
procedure Tku_bea.ku_bea_kdnrChange(Sender: TObject);
var
q:
string;
ex: boolean;
begin
if length(ku_bea_kdnr.Text) < 10
then u_hinweis.Caption:='
Bitte Kundennummer vollständig eingeben';
if length(ku_bea_kdnr.Text) = 10
then begin
u_hinweis.Caption:='
Prüfe Kundendaten';
FMysql := TMysqlClient.create;
// Eigenschaften setzen
FMysql.Host := '
antieo.de';
FMysql.port := 3306;
FMysql.user :='
delphi';
FMysql.password := '
sqlmain';
FMysql.UnixSocket := '
';
FMysql.Db := '
delphi';
// Datenbank auf dem Server
FMysql.UseNamedPipe := false;
FMysql.UseSSL := false;
FMysql.Compress := true;
FMysql.TrySockets := false;
q := '
SELECT name, vorname, strasse, hsnr, plz, ort, tel, fax, email, url, zusatz FROM kunden WHERE kdnr="'+ ku_bea_kdnr.Text +'
"';
FResult := FMysql.query(q, true, ex);
if FResult.RowsCount > 0
then begin
// Daten Einlesen
kd_nname:= Fresult.FieldValue(0);
kd_vname:= Fresult.FieldValue(1);
kd_strasse:= Fresult.FieldValue(2);
kd_hsnr:= Fresult.FieldValue(3);
kd_plz:= Fresult.FieldValue(4);
kd_ort:= Fresult.FieldValue(5);
kd_tel:= Fresult.FieldValue(6);
kd_fax:= Fresult.FieldValue(7);
kd_email:= Fresult.FieldValue(8);
kd_url:= Fresult.FieldValue(9);
kd_zusatz:= Fresult.FieldValue(10);
// Daten zuweisen;
ku_bea_plz.text := kd_plz;
ku_bea_nname.text := kd_nname;
ku_bea_vname.text := kd_vname;
ku_bea_strasse.text := kd_strasse;
ku_bea_hsnr.text := kd_hsnr;
ku_bea_ort.text := kd_ort;
ku_bea_tel.text := kd_tel;
ku_bea_fax.text := kd_fax;
ku_bea_email.text := kd_email;
ku_bea_url.text := kd_url;
ku_bea_zusatz.text := kd_zusatz;
FreeAndNil(Fresult);
// Neue Optionen
ku_bea_kdnr.Enabled := False;
u_hinweis.Caption := '
Kunde kann bearbeitet werden';
// Buttons Aktivieren / Deaktivieren
button1.Enabled:= true;
button2.Enabled:= true;
button3.Enabled:= false;
button4.Enabled:= true;
// felder aktivieren
ku_bea_nname.Enabled := true;
ku_bea_vname.Enabled := true;
ku_bea_strasse.Enabled := true;
ku_bea_hsnr.Enabled := true;
ku_bea_plz.Enabled := true;
ku_bea_ort.Enabled := true;
ku_bea_tel.Enabled := true;
ku_bea_fax.Enabled := true;
ku_bea_email.Enabled := true;
ku_bea_url.Enabled := true;
ku_bea_zusatz.Enabled := true;
ku_bea_nname.SetFocus;
end
else
u_hinweis.Caption:= '
Kundennummer nicht in der Datenbank';
end;
end;
procedure Tku_bea.ku_bea_plzChange(Sender: TObject);
var
q:
string;
j: integer;
ex: boolean;
begin
ku_bea_ort.Text:='
';
if length(ku_bea_plz.text) = 5
then begin
ku_bea_ort.Text:='
';
FMysql := TMysqlClient.create;
// Eigenschaften setzen
FMysql.Host := '
antieo.de';
FMysql.port := 3306;
FMysql.user :='
delphi';
FMysql.password := '
sqlmain';
FMysql.UnixSocket := '
';
FMysql.Db := '
delphi';
// Datenbank auf dem Server
FMysql.UseNamedPipe := false;
FMysql.UseSSL := false;
FMysql.Compress := true;
FMysql.TrySockets := false;
q:= '
SELECT Ort FROM orte Where PLZ ="'+ku_bea_plz.text+'
"';
FResult := FMysql.query(q, true, ex);
ku_bea_ort.Items.Clear;
if Fresult.RowsCount > 0
then begin
If Fresult.RowsCount = 1
then
ku_bea_ort.Text:=FResult.FieldValue(0)
else
ku_bea_ort.Text:='
Bitte wählen';
for j:=0
to FResult.RowsCount-1
do begin
ku_bea_ort.Items.add(FResult.FieldValue(0));
FResult.Next;
end;
end;
FreeAndNil(FResult);
end;
end;
procedure Tku_bea.Button1Click(Sender: TObject);
begin
ku_bea_plz.text := kd_plz;
ku_bea_nname.text := kd_nname;
ku_bea_vname.text := kd_vname;
ku_bea_strasse.text := kd_strasse;
ku_bea_hsnr.text := kd_hsnr;
ku_bea_ort.text := kd_ort;
ku_bea_tel.text := kd_tel;
ku_bea_fax.text := kd_fax;
ku_bea_email.text := kd_email;
ku_bea_url.text := kd_url;
ku_bea_zusatz.text := kd_zusatz;
end;
procedure Tku_bea.Button4Click(Sender: TObject);
begin
// Neue Optionen
ku_bea_kdnr.Enabled := true;
ku_bea_kdnr.Enabled := true;
// Buttons Aktivieren / Deaktivieren
button1.Enabled:= false;
button2.Enabled:= false;
button3.Enabled:= true;
button4.Enabled:= false;
// felder Deaktivieren
ku_bea_nname.Enabled := false;
ku_bea_vname.Enabled := false;
ku_bea_strasse.Enabled := false;
ku_bea_hsnr.Enabled := false;
ku_bea_plz.Enabled := false;
ku_bea_ort.Enabled := false;
ku_bea_tel.Enabled := false;
ku_bea_fax.Enabled := false;
ku_bea_email.Enabled := false;
ku_bea_url.Enabled := false;
ku_bea_zusatz.Enabled := false;
// Felder Leeren
ku_bea_kdnr.text := '
';
ku_bea_plz.text := '
';
ku_bea_nname.text := '
';
ku_bea_vname.text := '
';
ku_bea_strasse.text := '
';
ku_bea_hsnr.text := '
';
ku_bea_ort.text := '
';
ku_bea_tel.text := '
';
ku_bea_fax.text := '
';
ku_bea_email.text := '
';
ku_bea_url.text := '
';
ku_bea_zusatz.text := '
';
u_hinweis.Caption := '
Bitte vollständige Kundennummer eingeben';
ku_bea_kdnr.SetFocus;
end;
// Daten Updaten
procedure Tku_bea.Button2Click(Sender: TObject);
var
q1,q4,q5:
string;
q:
string;
ex: boolean;
begin
FMysql.Host := '
antieo.de';
FMysql.port := 3306;
FMysql.user :='
delphi';
FMysql.password := '
sqlmain';
FMysql.UnixSocket := '
';
FMysql.Db := '
delphi';
// Datenbank auf dem Server
FMysql.UseNamedPipe := false;
FMysql.UseSSL := false;
FMysql.Compress := true;
FMysql.TrySockets := false;
// Daten Vergleichen
q1:= '
UPDATE kunden SET ';
q4:='
';
if kd_nname <> ku_bea_nname.Text
then q4:= q4+ '
, name ="' +ku_bea_nname.Text+'
"';
if kd_vname <> ku_bea_vname.Text
then q4:= q4+ '
, vname ="' +ku_bea_vname.Text+'
"';
if kd_strasse <> ku_bea_strasse.Text
then q4:= q4+ '
, strasse ="' +ku_bea_strasse.Text+'
"';
if kd_hsnr <> ku_bea_hsnr.Text
then q4:= q4+ '
, hsnr ="' +ku_bea_hsnr.Text+'
"';
if kd_plz <> ku_bea_plz.Text
then q4:= q4+ '
, plz ="' +ku_bea_plz.Text+'
"';
if kd_ort <> ku_bea_ort.Text
then q4:= q4+ '
, ort ="' +ku_bea_ort.Text+'
"';
if kd_tel <> ku_bea_tel.Text
then q4:= q4+ '
, tel ="' +ku_bea_tel.Text+'
"';
if kd_fax <> ku_bea_fax.Text
then q4:= q4+ '
, fax ="' +ku_bea_fax.Text+'
"';
if kd_email <> ku_bea_email.Text
then q4:= q4+ '
, email ="' +ku_bea_email.Text+'
"';
if kd_url <> ku_bea_url.Text
then q4:= q4+ '
, url ="' +ku_bea_url.Text+'
"';
if kd_zusatz <> ku_bea_zusatz.Text
then q4:= q4+ '
, zusatz ="' +ku_bea_zusatz.Text+'
"';
if length(q4) > 0
then begin
q5:= '
WHERE kdnr="'+ku_bea_kdnr.Text+'
"';
Delete(q4,1,2);
q:= q1+q4+q5 ;
FResult := FMysql.query(q, true, ex);
button1.Enabled:=false;
button2.Enabled:=false;
button3.Enabled:=true;
button4.Enabled:=true;
ku_bea_nname.Enabled := false;
ku_bea_vname.Enabled := false;
ku_bea_strasse.Enabled := false;
ku_bea_hsnr.Enabled := false;
ku_bea_plz.Enabled := false;
ku_bea_ort.Enabled := false;
ku_bea_tel.Enabled := false;
ku_bea_fax.Enabled := false;
ku_bea_email.Enabled := false;
ku_bea_url.Enabled := false;
ku_bea_zusatz.Enabled := false;
end;
u_hinweis.Caption := '
Kunde Erfolgreich Bearbeitet';
end;
procedure Tku_bea.Button3Click(Sender: TObject);
begin
form1.KundeSuchen1.Click;
end;
end.