unit NachrichtNeuUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls,
DB, ADODB, Grids, DBGrids;
type
TNachrichtNeu =
class(TForm)
Empaenger: TEdit;
Label1: TLabel;
Betreff: TEdit;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
nachricht: TMemo;
Label3: TLabel;
DSAdressen: TDataSource;
TblAdressen: TADOTable;
DBGrid1: TDBGrid;
Label4: TLabel;
Label5: TLabel;
EdtSender: TEdit;
Label6: TLabel;
DSPrioritaeten: TDataSource;
TblPrioritaeten: TADOTable;
prioritaet: TComboBox;
QrySender: TADOQuery;
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure DBGrid1DblClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
NachrichtNeu: TNachrichtNeu;
EID : Integer;
implementation
uses HauptUnit;
{$R *.dfm}
procedure TNachrichtNeu.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Empaenger.Clear;
Betreff.Clear;
Nachricht.Clear;
TblAdressen.Close;
TblPrioritaeten.Close;
QrySender.Close;
end;
procedure TNachrichtNeu.FormShow(Sender: TObject);
var
fname :
String;
lname :
String;
begin
TblAdressen.Open;
TblPrioritaeten.Open;
QrySender.Parameters.ParamByName('
userid_Global').Value := userid_Global;
QrySender.Open;
fname := QrySender.FieldByName('
fname').AsString;
lname := QrySender.FieldByName('
lname').AsString;
EdtSender.Text :='
'+fname+'
'+'
'+lname+'
';
Empaenger.Clear;
end;
procedure TNachrichtNeu.Button1Click(Sender: TObject);
var
Qry : TADOQuery;
begin
Qry := TADOQuery.Create(self);
qry.Connection := HauptForm.ADOConnection1;
Qry.SQL.Text := '
insert into nachrichten (sender_id,empfeanger_id,nachricht,betreff,prioritaet) values (:userid_Global, :EID, :nachricht, :betreff, :prioritaet )';
Qry.Parameters.ParamByName('
userid_Global').Value := userid_Global;
Qry.Parameters.ParamByName('
EID').Value := EID;
Qry.Parameters.ParamByName('
nachricht').Value := nachricht.Text;
Qry.Parameters.ParamByName('
betreff').Value := betreff.Text;
Qry.Parameters.ParamByName('
prioritaet').Value := prioritaet.Text;
if Qry.ExecSQL > 0
then
MessageDlg('
Nachricht wurde gesendet', mtInformation, [mbOK], 0);
Qry.Free;
NachrichtNeu.Close;
end;
procedure TNachrichtNeu.Button2Click(Sender: TObject);
begin
NachrichtNeu.Close;
end;
procedure TNachrichtNeu.DBGrid1DblClick(Sender: TObject);
var
Vorname :
String;
Nachname :
String;
begin
// var´s füllen mit vorname, nachname und der id des empfängers
Empaenger.Clear;
Vorname := TblAdressen.FieldByName ('
fname').AsString;
Nachname := TblAdressen.FieldByName ('
lname').AsString;
EID := TblAdressen.FieldByName ('
id').AsInteger;
Empaenger.Text := '
'+Vorname+'
'+Nachname+'
';
end;
end.