Okay, dann leg ich mal los:
Delphi-Quellcode:
procedure TF_wp.FormCreate(Sender: TObject);
begin
P_Spaltenbeschriften;
P_Tabelleauslesen;
end;
procedure TF_wp.Sg_anzeigeSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
begin
// Merkt sich die Koordinaten der ausgewählten Zelle
Spaltenno := ACol;
Zeilenno := ARow;
end;
// Diese Funktion gibt den Namen des Datensatzes zurück, der mit der aktuell
// ausgewählten Zelle verknüpft ist, damit dieser beim Lesen/Editieren direkt
// ansprechen kann...
function F_Datensatzermitteln : string;
begin
if ((Spaltenno = 1) and (Zeilenno = 1)) then result := 'Pl_1';
if ((Spaltenno = 1) and (Zeilenno = 2)) then result := 'Pl_2';
if ((Spaltenno = 1) and (Zeilenno = 3)) then result := 'Pl_3';
if ((Spaltenno = 1) and (Zeilenno = 4)) then result := 'Pl_4';
if ((Spaltenno = 1) and (Zeilenno = 5)) then result := 'Pl_5';
if ((Spaltenno = 1) and (Zeilenno = 6)) then result := 'Pl_6';
if ((Spaltenno = 1) and (Zeilenno = 7)) then result := 'Pl_7';
if ((Spaltenno = 1) and (Zeilenno = 8)) then result := 'Pl_8';
if ((Spaltenno = 1) and (Zeilenno = 9)) then result := 'Pl_9';
if ((Spaltenno = 1) and (Zeilenno = 10)) then result := 'Pl_10';
if ((Spaltenno = 1) and (Zeilenno = 11)) then result := 'Pl_11';
if ((Spaltenno = 1) and (Zeilenno = 12)) then result := 'Pl_12';
if ((Spaltenno = 1) and (Zeilenno = 13)) then result := 'Pl_13';
if ((Spaltenno = 1) and (Zeilenno = 14)) then result := 'Pl_14';
if ((Spaltenno = 2) and (Zeilenno = 1)) then result := 'Pl_15';
if ((Spaltenno = 2) and (Zeilenno = 2)) then result := 'Pl_16';
if ((Spaltenno = 2) and (Zeilenno = 3)) then result := 'Pl_17';
if ((Spaltenno = 2) and (Zeilenno = 4)) then result := 'Pl_18';
if ((Spaltenno = 2) and (Zeilenno = 5)) then result := 'Pl_19';
if ((Spaltenno = 2) and (Zeilenno = 6)) then result := 'Pl_20';
if ((Spaltenno = 2) and (Zeilenno = 7)) then result := 'Pl_21';
if ((Spaltenno = 2) and (Zeilenno = 8)) then result := 'Pl_22';
if ((Spaltenno = 2) and (Zeilenno = 9)) then result := 'Pl_23';
if ((Spaltenno = 2) and (Zeilenno = 10)) then result := 'Pl_24';
if ((Spaltenno = 2) and (Zeilenno = 11)) then result := 'Pl_25';
if ((Spaltenno = 2) and (Zeilenno = 12)) then result := 'Pl_26';
if ((Spaltenno = 2) and (Zeilenno = 13)) then result := 'Pl_27';
if ((Spaltenno = 2) and (Zeilenno = 14)) then result := 'Pl_28';
if ((Spaltenno = 3) and (Zeilenno = 1)) then result := 'Pl_29';
if ((Spaltenno = 3) and (Zeilenno = 2)) then result := 'Pl_30';
if ((Spaltenno = 3) and (Zeilenno = 3)) then result := 'Pl_31';
if ((Spaltenno = 3) and (Zeilenno = 4)) then result := 'Pl_32';
if ((Spaltenno = 3) and (Zeilenno = 5)) then result := 'Pl_33';
if ((Spaltenno = 3) and (Zeilenno = 6)) then result := 'Pl_34';
if ((Spaltenno = 3) and (Zeilenno = 7)) then result := 'Pl_35';
if ((Spaltenno = 3) and (Zeilenno = 8)) then result := 'Pl_36';
if ((Spaltenno = 3) and (Zeilenno = 9)) then result := 'Pl_37';
if ((Spaltenno = 3) and (Zeilenno = 10)) then result := 'Pl_38';
if ((Spaltenno = 3) and (Zeilenno = 11)) then result := 'Pl_39';
if ((Spaltenno = 3) and (Zeilenno = 12)) then result := 'Pl_40';
if ((Spaltenno = 3) and (Zeilenno = 13)) then result := 'Pl_41';
if ((Spaltenno = 3) and (Zeilenno = 14)) then result := 'Pl_42';
if ((Spaltenno = 4) and (Zeilenno = 1)) then result := 'Pl_43';
if ((Spaltenno = 4) and (Zeilenno = 2)) then result := 'Pl_44';
if ((Spaltenno = 4) and (Zeilenno = 3)) then result := 'Pl_45';
if ((Spaltenno = 4) and (Zeilenno = 4)) then result := 'Pl_46';
if ((Spaltenno = 4) and (Zeilenno = 5)) then result := 'Pl_47';
if ((Spaltenno = 4) and (Zeilenno = 6)) then result := 'Pl_48';
if ((Spaltenno = 4) and (Zeilenno = 7)) then result := 'Pl_49';
if ((Spaltenno = 4) and (Zeilenno = 8)) then result := 'Pl_50';
if ((Spaltenno = 4) and (Zeilenno = 9)) then result := 'Pl_51';
if ((Spaltenno = 4) and (Zeilenno = 10)) then result := 'Pl_52';
if ((Spaltenno = 4) and (Zeilenno = 11)) then result := 'Pl_53';
if ((Spaltenno = 4) and (Zeilenno = 12)) then result := 'Pl_54';
if ((Spaltenno = 4) and (Zeilenno = 13)) then result := 'Pl_55';
if ((Spaltenno = 4) and (Zeilenno = 14)) then result := 'Pl_56';
if ((Spaltenno = 5) and (Zeilenno = 1)) then result := 'Pl_57';
if ((Spaltenno = 5) and (Zeilenno = 2)) then result := 'Pl_58';
if ((Spaltenno = 5) and (Zeilenno = 3)) then result := 'Pl_59';
if ((Spaltenno = 5) and (Zeilenno = 4)) then result := 'Pl_60';
if ((Spaltenno = 5) and (Zeilenno = 5)) then result := 'Pl_61';
if ((Spaltenno = 5) and (Zeilenno = 6)) then result := 'Pl_62';
if ((Spaltenno = 5) and (Zeilenno = 7)) then result := 'Pl_63';
if ((Spaltenno = 5) and (Zeilenno = 8)) then result := 'Pl_64';
if ((Spaltenno = 5) and (Zeilenno = 9)) then result := 'Pl_65';
if ((Spaltenno = 5) and (Zeilenno = 10)) then result := 'Pl_66';
if ((Spaltenno = 5) and (Zeilenno = 11)) then result := 'Pl_67';
if ((Spaltenno = 5) and (Zeilenno = 12)) then result := 'Pl_68';
if ((Spaltenno = 5) and (Zeilenno = 13)) then result := 'Pl_69';
if ((Spaltenno = 5) and (Zeilenno = 14)) then result := 'Pl_70';
if ((Spaltenno = 6) and (Zeilenno = 1)) then result := 'Pl_71';
if ((Spaltenno = 6) and (Zeilenno = 2)) then result := 'Pl_72';
if ((Spaltenno = 6) and (Zeilenno = 3)) then result := 'Pl_73';
if ((Spaltenno = 6) and (Zeilenno = 4)) then result := 'Pl_74';
if ((Spaltenno = 6) and (Zeilenno = 5)) then result := 'Pl_75';
if ((Spaltenno = 6) and (Zeilenno = 6)) then result := 'Pl_76';
if ((Spaltenno = 6) and (Zeilenno = 7)) then result := 'Pl_77';
if ((Spaltenno = 6) and (Zeilenno = 8)) then result := 'Pl_78';
if ((Spaltenno = 6) and (Zeilenno = 9)) then result := 'Pl_79';
if ((Spaltenno = 6) and (Zeilenno = 10)) then result := 'Pl_80';
if ((Spaltenno = 6) and (Zeilenno = 11)) then result := 'Pl_81';
if ((Spaltenno = 6) and (Zeilenno = 12)) then result := 'Pl_82';
if ((Spaltenno = 6) and (Zeilenno = 13)) then result := 'Pl_83';
if ((Spaltenno = 6) and (Zeilenno = 14)) then result := 'Pl_84';
if ((Spaltenno = 7) and (Zeilenno = 1)) then result := 'Pl_85';
if ((Spaltenno = 7) and (Zeilenno = 2)) then result := 'Pl_86';
if ((Spaltenno = 7) and (Zeilenno = 3)) then result := 'Pl_87';
if ((Spaltenno = 7) and (Zeilenno = 4)) then result := 'Pl_88';
if ((Spaltenno = 7) and (Zeilenno = 5)) then result := 'Pl_89';
if ((Spaltenno = 7) and (Zeilenno = 6)) then result := 'Pl_90';
if ((Spaltenno = 7) and (Zeilenno = 7)) then result := 'Pl_91';
if ((Spaltenno = 7) and (Zeilenno = 8)) then result := 'Pl_92';
if ((Spaltenno = 7) and (Zeilenno = 9)) then result := 'Pl_93';
if ((Spaltenno = 7) and (Zeilenno = 10)) then result := 'Pl_94';
if ((Spaltenno = 7) and (Zeilenno = 11)) then result := 'Pl_95';
if ((Spaltenno = 7) and (Zeilenno = 12)) then result := 'Pl_96';
if ((Spaltenno = 7) and (Zeilenno = 13)) then result := 'Pl_97';
if ((Spaltenno = 7) and (Zeilenno = 14)) then result := 'Pl_98';
end;
// Diese Prozedur stellt den Cursor der aktuell geöffneten Tabelle auf die Position, die dem
// übergebenen eindeutigen Namen entspricht...
procedure P_Datensatzauswaehlen(Satzname : string);
begin
if not F_wp.ADO_wp.Bof then F_wp.ADO_wp.First;
while Satzname <> F_wp.ADO_wp.fieldbyname('Termin').asstring do F_wp.ADO_wp.Next;
end;
procedure P_Terminbearbeiten;
begin
if F_wp.ADO_wp.fieldbyname('Name').asstring <> '' then
begin
F_Kollision.Show;
end;
F_Terminpflege.show;
end;
procedure TF_wp.Sg_anzeigeDblClick(Sender: TObject);
var String_temp : String;
begin
String_temp := F_Datensatzermitteln;
P_Datensatzauswaehlen(String_temp);
if F_wp.ADO_wp.FieldByName('Termin').AsString = '' then
showmessage('Bitte legen Sie über den Menüeintrag einen neuen Wochenplaner an!')
else
begin
P_Datensatzauswaehlen(F_Datensatzermitteln);
P_Terminbearbeiten;
end;
end;
procedure TF_wp.Sg_anzeigeMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var String_temp : String;
begin
String_temp := F_Datensatzermitteln;
P_Datensatzauswaehlen(String_temp);
F_wp.ADO_wp.Edit;
Name_temp := F_wp.ADO_wp.FieldbyName('Name').asString;
Beschreibung_temp := F_wp.ADO_wp.FieldbyName('Beschreibung').asString;
F_wp.ADO_wp.Post;
end;
procedure TF_wp.Sg_anzeigeMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var String_temp : String;
begin
String_temp := F_Datensatzermitteln;
P_Datensatzauswaehlen(String_temp);
F_wp.ADO_wp.Edit;
F_wp.ADO_wp.FieldbyName('Name').asString := Name_temp;
F_wp.ADO_wp.FieldbyName('Beschreibung').asString := Beschreibung_temp;
F_wp.ADO_wp.Post;
P_Tabelleauslesen;
end;
und dann noch die Terminpflege, also das besagte Dialogfenster:
Delphi-Quellcode:
procedure TF_Terminpflege.Btn_AbbruchClick(Sender: TObject);
begin
F_Terminpflege.Close;
end;
procedure TF_Terminpflege.Btn_OKClick(Sender: TObject);
var
x,y : integer;
begin
F_wp.ADO_wp.Edit;
F_wp.ADO_wp.fieldbyname('Name').AsString := Edt_Terminname.Text;
if Edt_Terminname.Text = '' then
Edt_Beschreibung.Text := ''
else
F_wp.ADO_wp.fieldbyname('Beschreibung').AsString := Edt_Beschreibung.Text;
F_wp.ADO_wp.Post;
P_Tabelleauslesen;
//Der Inhalt der aktuellen Tabelle wird ausgelesen und ins String Grid übertragen.
//Dabei wird nur das Feld "Name verwendet"...
//Der erste Datensatz der Tabelle wird ausgewählt...
{ if F_wp.ADO_wp.Bof = false then F_wp.ADO_wp.First;
//Diese Schleife durchläuft die Spalten gemäß der Anzahl derselben,
//und füllt die Zellen mit dem Inhalt des Name-Feldes...
For y := 1 to 7 do
begin
For x := 1 to 14 do
begin
F_wp.Sg_anzeige.cells[y,x] := F_wp.ADO_wp.FieldByName('Name').AsString;
F_wp.ADO_wp.Next;
end;
end; }
F_Terminpflege.Close;
Edt_Terminname.Text := '';
Edt_Beschreibung.Text := '';
end;