unit haupt;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, umysqlvio, uMysqlCT, uMysqlClient, uMysqlHelpers, StdCtrls, FMTBcd,
DB, SqlExpr, ComCtrls, Menus, ku_gesamt, neu_kunde, ku_bearb, ku_suche;
{$I mysqlinc.inc}
type
TForm1 =
class(TForm)
StatusBar2: TStatusBar;
MainMenu1: TMainMenu;
Optionen1: TMenuItem;
Verbindungseinstellunegn1: TMenuItem;
Kunden1: TMenuItem;
KundeSuchen1: TMenuItem;
KundeLschen1: TMenuItem;
N2: TMenuItem;
Hilfe1: TMenuItem;
Verbindung1: TMenuItem;
Verbindungsstatus1: TMenuItem;
N1: TMenuItem;
VerbindungTrennen1: TMenuItem;
VerbindungHerstellen1: TMenuItem;
AlleKundenanzeigen1: TMenuItem;
Label1: TLabel;
Kundehinzufgen2: TMenuItem;
temp_var_type: TEdit;
temp_var_value: TEdit;
Kundendatenbearbeiten1: TMenuItem;
procedure KundeSuchen1Click(Sender: TObject);
procedure Kundendatenbearbeiten1Click(Sender: TObject);
procedure Kundehinzufgen2Click(Sender: TObject);
procedure AlleKundenanzeigen1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FMysql: TMysqlClient;
FResult: TMysqlResult;
FVisibleFrame: TFrame;
procedure SetVisibleFrame(frame: TFrame);
public
property VisibleFrame: TFrame
read FVisibleFrame
write SetVisibleFrame;
end;
var
Form1: TForm1;
anz_frame: TFrame;
cou_res: integer;
implementation
{$R *.dfm}
procedure TForm1.SetVisibleFrame(frame: TFrame);
begin
if Assigned(FVisibleFrame)
then
FVisibleFrame.Free;
FVisibleFrame := frame;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FMysql := TMysqlClient.create;
StatusBar2.Panels.Add();
StatusBar2.Panels[0].Text:='
Nicht Verbunden';
// Eigenschaften setzen
FMysql.Host := '
antieo.de';
FMysql.port := 3306;
FMysql.user :='
delphi';
FMysql.password := '
sqltest';
FMysql.UnixSocket := '
';
FMysql.Db := '
delphi';
// Datenbank auf dem Server
FMysql.UseNamedPipe := false;
FMysql.UseSSL := false;
FMysql.Compress := true;
FMysql.TrySockets := false;
end;
// Bei Programmende muss das Objekt natürlich auch wieder freigegeben werden:
procedure TForm1.FormDestroy(Sender: TObject);
begin
FMysql.Free;
if FResult<>
nil then
FResult.free;
FMysql.close;
end;
procedure TForm1.AlleKundenanzeigen1Click(Sender: TObject);
var q:
string;
ex: boolean;
j: integer;
begin
VisibleFrame := TKunden_gesamt.Create(self);
with VisibleFrame
as TKunden_gesamt
do
begin
Parent:=Form1;
Left:=10;
Top:=10;
width:=910;
height:=570;
if assigned(FResult)
then begin
if FMysql.Status<>MYSQL_STATUS_READY
then
ShowMessage('
Ein Ergebnis wurde unvollständig gelesen!');
FreeAndNil(FResult);
end;
q := '
SELECT id, vorname, name FROM kunden ORDER BY id';
FResult := FMysql.query(q, true, ex);
if assigned(FResult)
then begin
cou_res:= FResult.RowsCount-1;
if assigned(FResult)
then begin
q := '
SELECT id, vorname, name FROM kunden ORDER BY id';
FResult := FMysql.query(q, true, ex);
if assigned(FResult)
then begin
// ShowMessage('Query: OK - Ergebnis gespeichert');
cou_res:= FResult.RowsCount-1;
for j:=0
to FResult.RowsCount-1
do begin
ku_list.items[j]:= FResult.FieldValue(2)+'
- '+ FResult.FieldValue(1) ;
ku_id.Items[j]:= FResult.FieldValue(0);
FResult.Next;
end;
FreeAndNil(FResult);
end
else
if ex
then begin
ShowMessage('
Query: OK - ausgeführt')
end
else
ShowMessage('
Query fehlgeschlagen: '+FMysql.LastError);
end;
end;
end;
// FMysql(freeAndNil);
end;
procedure TForm1.Kundehinzufgen2Click(Sender: TObject);
begin
VisibleFrame := TKu_hinzu.Create(self);
with VisibleFrame
as TKu_hinzu
do
begin
Parent:=Form1;
Left:=10;
Top:=10;
width:=910;
height:=570;
end;
end;
procedure TForm1.Kundendatenbearbeiten1Click(Sender: TObject);
begin
VisibleFrame := TKu_bea.Create(self);
with VisibleFrame
as TKu_bea
do
begin
Parent:=Form1;
Left:=10;
Top:=10;
width:=910;
height:=570;
end;
end;
procedure TForm1.KundeSuchen1Click(Sender: TObject);
begin
VisibleFrame := TKu_suche1.Create(self);
with VisibleFrame
as TKu_suche1
do
begin
Parent:=Form1;
Left:=10;
Top:=10;
width:=910;
height:=570;
end;
end;
end.