Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 22.08.04 12:32 
Liebe Helpher,

wie ist es möglich, mit D3Prof einen Querydatensatz eines DBF-Files zu editieren?
RequestLive := true funktioniert nicht!

Vielen Dank für Hilfe!!

Detlef Annies
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: So 22.08.04 22:50 
Zitat:
funktioniert nicht - gibts nicht!
;)

hallo detlef!

wo drückt der hut - oder brennt der schuh? *g*

eine andere möglichkeit, als RequestLive auf 'true' zu stellen gibts auch bei delphi3 und dBase-Tabellen nicht.
behandelst du eine tabelle, oder ist diese mit anderen tabellen ge-joined? dann kann es schon probs beim editieren geben - hab ich hab gelesen...

wie äussert sich das nicht-funktionieren?
werden die einträge nicht aktualisiert oder hagelt es fehlermeldungen?

man liest sich ;)

mfg, stefan
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 23.08.04 13:24 
Hi, Grayfox!

Die Dbasetabelle ist allein für sich und die Fehermeldung ist harmlos in der Art:
"Datenmenge kann nicht editiert werden"

Den genauen Text müsste ich nochmmal nachsehen, vielleicht reicht dir das schon, ich wollte dir jedenfalls erstmal antworten!

Grüße, Detlef :roll:
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Mo 23.08.04 13:41 
Leg mal Indizes auf alle Felder, die Du in Deiner Query im WHERE benutzt und Poste mal die Query wenn es nicht geht.

_________________
Ha! Es compiliert! Wir können ausliefern!
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 23.08.04 20:59 
Hi, Neojones,

danke dass du auch mit "dran" bist, ich hatte mit deiner Antwort nicht gerechnet,
deshalb gebe ich erstmal die "Korrekte" Fehlermeldung zur Laufzeit an:

Eine Datenmenge, die nur zum Lesen ist, kann nicht editiert werden.

Nun habe ich gerade eben ein Objekt namens TUpdateSQL entdeckt, und dort die
Eigenschaft TUpdateSQL.ModifySQL :shock: Zur Zeit kann ich damit noch nicht viel anfangen.

Leider kann ich mich jetzt nicht weiter selbst darum kümmern, da ich morgen ganz früh raus muss. :gaehn:

Vielleicht müßte man in dieser Richtung weiterdenken :idea: :?:

Bis dann, Detlef
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Di 24.08.04 08:23 
Puh, da bin ich dann wieder überfragt, weil wir hier andere Datenbank-Komponenten verwenden (was ziemlich spezielles für mySQL).

_________________
Ha! Es compiliert! Wir können ausliefern!
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 24.08.04 10:30 
Du musst das Query (Eigenschaft UpdateSQL) mit dieser Kompo verbinden. Danach klickst Du doppelt auf die UpdateSQL-Kompo und kannst in dem Dialog die ganzen Statements automatisch erzeugen lassen, indem Du die notwendigen Angaben machst (KeyField, UpdateFields usw.).

Einfach auf Generate SQL klicken und die Statements werde erzeugt ;-)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 24.08.04 13:25 
Danke UGrohne (Ulf?)

Drucke mir gerade deine Erklärung aus und hoppel dann noch durchs Internet, bezüglich TUpdateSql. Mal sehen, was da zutage tritt.

Dann werde ich mal loslegen,

Grüße, Detlef
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 24.08.04 13:38 
D. Annies hat folgendes geschrieben:
Danke UGrohne (Ulf?)

Wie kommt man als erstes auf Ulf??? Also ich würde da mit Udo anfangen, stimmt aber beides nicht :twisted:
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 24.08.04 14:13 
Hi, nicht(Udo oder Ulf)!

Aber wahrscheinlich fragt man codexmäßig einen Moderator nicht nach seinem (ihrem) Vornamen ... :wink:

Nochmal sachlich:

Es geht mir ja wirklich "nur" darum, etwas formulieren zu können in der Art:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
query1.first;
repeat
  if query1.fields[2].asstring = stringgrid2.cells[2,4] then
     query1.fields[4].asstring := stringrid2.cells[2,5];
  until query1.eof;


Und diese Änderung soll der Table mitbekommen!

Bin schon ganz fertig! :oops: :cry: :?:

Grüße, Detlef
Moderiert von user profile iconUGrohne: Delphi-Tags hinzugefügt.
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Di 24.08.04 16:18 
ich frag lieber nicht das publikum, denn dabei kommt selten was gescheites heraus, sondern tippe gleich auf 'uwe' :D
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 24.08.04 16:50 
grayfox hat folgendes geschrieben:
ich frag lieber nicht das publikum, denn dabei kommt selten was gescheites heraus, sondern tippe gleich auf 'uwe' :D

*g* jetzt aber mal nicht so OffTopic hier. Aber ... naja ... ok ... es stimmt. Mit Kodex hat das hier nix zu tun ;-)

@Annies: Das müsste dann auch so gehen, rein theoretisch. Ich habs bisher nie so gemacht, weil ich mehr auf SQL stehe ;-) Probiers einfach mal aus

//EDIT:
Ich empfehle aber eher folgenden Code, denn wenn das Query keine Datensatz enthält, fliegt Dir Deine Konstrukution um die Ohren, weil die Schleife auf jeden Fall einmal ausgeführt wird.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
query1.first;
while not Query1.EoF do begin
  if query1.fields[2].asstring = stringgrid2.cells[2,4] then
     query1.fields[4].asstring := stringrid2.cells[2,5];
  end;
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Di 24.08.04 16:55 
hallo detlef!

entweder einfach...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
(*$UNTESTED*)
query1.first; 
while not Query1.EOF do begin 
  if query1.fields[2].asstring = stringgrid2.cells[2,4] then begin
    query1.EDIT;  <-- NEU
    query1.fields[4].asstring := stringrid2.cells[2,5]; 
    query1.POST   <-- NEU
  end; 
end;


wenn du aber schon eine query verwendest, dann macn es gleich ordentlich! :wink:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
(*$UNTESTED*)
with query1 do begin
  close;
  SQL.Clear;
  SQL.ADD('UPDATE Tabellenname SET Feldname4= :aText WHERE (Feldname2 = :aVergleich');
  Params[0].asString:= stringgrid2.cells[2,4];
  Params[1].asString:= stringgrid2.cells[2,5]; 
  ExecSql
end;



mfg, stefan

// edit: @uwe: schliesslich brauchte ich ja einen pausenfüller, während ich den beitrag getippt habe ;)
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 24.08.04 17:03 
grayfox hat folgendes geschrieben:
wenn du aber schon eine query verwendest, dann macn es gleich ordentlich! :wink:

Das hat dann aber wieder den Nachteil, dass die Ergebnismenge verloren geht. Falls er die Daten also in einem DBGrid anzeigt, sollte ein zweites Query her, dass die UPDATEs u.ä. ausführt. Deswegen habe ich diese Möglichkeit auch nicht genannt.

grayfox hat folgendes geschrieben:
// edit: @uwe: schliesslich brauchte ich ja einen pausenfüller, während ich den beitrag getippt habe ;)

Soso, 30min für diesen Beitrag? ;-)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 24.08.04 18:03 
Hallo,

das war ja ein Spaß für mich, eure letzten Beiträge zu lesen. Ich habe es zur Zeit
folgendermaßen verarbeitet (siehe ge-remmten Code in der Mitte)
aber jetzt habe ich doch ordentlich "Schiss" bekommen!

Zur Sicherheit gebe ich mal den Prozedurcode an (Nein, ich will euch nicht erschlagen..)



ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
procedure TForm1.Button13Click(Sender: TObject);              // Die eigentliche  
                                                                 Bücherabgabe
var gef, sgef, weiter : boolean;                              // als Zeilenvektor
   k, h1, b, n        : integer;
   t                  : textfile;
   aktion             : string[30];
begin
  if MessageDlg('   Klasse, Untergruppe, Lehrkraft'+#13+
                '    gibt Buch/Bücher KOMPLETT ab'+#13+
                '(oder wie in der Untertabelle zu sehen)'+#13+
                '           Alle Angaben oK? ', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
  begin
    if fileexists('PraeAktion.txt') then    begin  {aha!}  end
    else
    begin
      assignfile(t,'PraeAktion.txt'); rewrite(t); writeln(t, 'Ausgabe'); closefile(t);
    end;

    assignfile(t,'PraeAktion.txt'); reset(t); readln(t,aktion); closefile(t);
    if aktion = 'Ausgabe' then
    begin
      assignfile(t, 'PraeAktion.txt'); rewrite(t);
      aktion := 'Abgabe'; writeln(t, aktion); closefile(t);
      showmessage('Tabelle <buecher> muss jetzt sortiert werden!'); rufe_borland_dbdclick(self);
      q1sort(self);
    end;
    showmessage('Bücherprogramm setzt nach Sortprüfung wieder auf ...');

    b := 0; dbgrid5.visible := false;
    repeat
      b := b+1; table3.first;  gef := false;
      repeat
        if table3.Fields[0].asstring = stringgrid5.cells[b,0] then gef := true  // Buchtitel in T3 gefunden
        else  table3.next;
      until gef or table3.eof;
      if gef then
      begin
        if (strtoint(stringgrid5.cells[b,1]) > 0) and (sg8anz = 0) then
        begin
          weiter := true;
          repeat
            if table3.fields[2].asstring <> stringgrid5.cells[0,1] then table3.next
          until (table3.fields[2].asstring = stringgrid5.cells[0,1]) or table3.EOF;
          if table3.eof then
          begin
            showmessage ('Klasse/Lehrkraft hat dieses Buch nicht!  '+inttostr(b));
            weiter := false;
          end;
          if weiter = true then
          begin
            k := 0;
            repeat
              if (table3.fields[2].asstring = stringgrid5.cells[0,1]) then
              begin
                k := k+1;
                table3.edit;                                            // Abgabedatum eintragen
                  table3.fields[4].asstring := label32.caption;
                table3.post;
              end;
              table3.next;
            until (k = strtoint(stringgrid5.cells[b,1])) or (table3.EOF); // table3.fields[2].asstring <> stringgrid5.cells[0,1];
     // ***************
            {with query1 do
            begin
              SQL.Text := 'update buecher.dbf set A_DATUM = :A_DATUM where A_DATUM = :OLD_A_DATUM;';
              parambyname('OLD_KLASSE').asstring  := stringgrid5.cells[0,1];
              parambyname('OLD_A_DATUM').asstring := label32.caption;
              ExecSQL;
            end;}

     // ***************
            if messagedlgpos('Buch aus dem Buchsatz löschen? ',
                mtConfirmation, mbYesNoCancel, 0,200,475) = mrYes then
            begin
              table2.first; gef := false;
              repeat
                if table2.fields[0].asstring = stringgrid5.cells[0,1] then gef := true
                else table2.next;
              until gef;
              n := 2; gef := false;
              repeat
                if table2.fields[n].asstring = stringgrid5.cells[b,0] then gef := true
                else n := n+1;
              until gef;  // table2.fields[n].asstring = '';
              table2.edit;                                          // wird aus dem Buchsatz
                if n < table2.fieldcount-1 then
                begin                                                 // entfernt, die folgenden
                  repeat
                    table2.fields[n].asstring := table2.fields[n+1].asstring; // Bücher rücken auf
                    n := n + 1;
                  until (table2.fields[n].asstring = '') or (n = table2.fieldcount-1);
                end;
              table2.post;
            end;

            table4.first; gef := false;
            repeat
              if table4.fields[0].asstring = stringgrid5.cells[b,0] then gef := true
              else  table4.next;
            until gef or table4.eof;
            if gef then
            begin                                                               // addiere in T4
              h1 := strtoint(table4.fields[8].asstring);
              h1 := h1 + k;   // + strtoint(stringgrid5.cells[b,1]);
              table4.Edit; table4.fields[8].asstring := inttostr(h1); table4.post;
              if k = 1 then showmessage(inttostr(k)+ ' Buch in T4 addiert! ')
              else          showmessage(inttostr(k)+ ' Bücher in T4 addiert! ');
            end
          end
        end;

        if sg8anz > 0 then                                         // von einer Schülergrp
        begin                                                      //      oder
          n := 0;                                                  // von einem Schüler
          repeat
            n := n+1; sgef := false;
            repeat
              if (table3.fields[5].asstring = stringgrid8.cells[1,n]) and
                 (table3.fields[6].asstring = stringgrid8.cells[2,n]) then sgef := true
              else table3.next;
            until sgef or table3.eof;
            if sgef and (stringgrid5.cells[b,1] = '1') then       // z. B. Fra, Eng
            begin
              table3.edit; table3.fields[4].asstring := label32.caption; table3.post;
            end;
            table3.next;
          until n = sg8anz;

          table4.first; gef := false;
          repeat
            if (table4.fields[0].asstring = stringgrid5.cells[b,0]) then gef := true
            else  table4.next;                                    // Titel muss Unikat sein!
          until gef or table4.eof;
          if gef then
          begin                                    // addiere in T4, wenn Buch zurück
            if stringgrid5.cells[b,1] <> '0' then
            begin
              h1 := strtoint(table4.fields[8].asstring); h1 := h1 + sg8anz;
              table4.Edit; table4.fields[8].asstring := inttostr(h1); table4.post;
              if sg8anz = 1 then showmessage(inttostr(sg8anz)+ ' Buch in T4 addiert! ')
              else               showmessage(inttostr(sg8anz)+ ' Bücher in T4 addiert! ');
            end;
          end;
        end;
      end;
    until b = strtoint(label33.caption);
    table3.refresh;  showmessage ('weiter mit beliebiger Taste ... ');
    dbgrid5.visible := true;
    ort := 'Zeilenvektorabgabe '+stringgrid5.cells[0,1]; leihprotokoll(self, b, ort);
    showmessage('Tabelle 3 (Bücher) wird jetzt sortiert ausgegeben ..'); q1sort(self);
    buecherfreigabeclick(self); form2.szopendialog1.filename := 'leihprotokoll.txt';
  end
  else  begin showmessage('Bücherabgabe abgebrochen!'); button12.setfocus; end;
end;



Ich weiß leider nicht, wie man den Code hier richtig reinstellt, aber ihr seht, dass das Update nicht immer das ganze File betrifft, sondern nur z.B. eine bestimmte Klasse, die mehrere Bücher hat, aber nur ein Buch in Klassenstärke) abgibt.

Über eine Antwort würde ich sehr freuen!! (Wird wohl etwas dauern, hoffentlich ist alles soweit klar)

Detlef Annies

Moderiert von user profile iconUGrohne: Delphi-Tags hinzugefügt.
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Di 24.08.04 21:01 
hallo detlef!

das war ja ein Spaß für mich, eure letzten Beiträge zu lesen :?:
das war kein spass, das war harte arbeit! ;)

wenn du delphi-tags verwendet hättest, würde meine motivation, mich den den quelltext zu kämpfen, gleich um ein vielfaches höher sein *g*
editier bitte deinen beitrag nochmal - und setze [ delphi] vor den quelltext und [ /delphi] (ohne blank an der ersten stelle) in der zeile nach deinem quelltext. meine augen werden es dir danken :shock:

mfg, stefan
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 25.08.04 05:34 
Hi, Grayfox (et aliter)

Dank für deine Aufklärung, wie man den Code reinstellt: (ich versuchs mal)

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
procedure TForm1.Button13Click(Sender: TObject); // Die eigentliche 
Bücherabgabe 
var gef, sgef, weiter : boolean; // als Zeilenvektor 
k, h1, b, n : integer; 
t : textfile; 
aktion : string[30]; 
begin 
if MessageDlg(' Klasse, Untergruppe, Lehrkraft'+#13+ 
' gibt Buch/Bücher KOMPLETT ab'+#13+ 
'(oder wie in der Untertabelle zu sehen)'+#13+ 
' Alle Angaben oK? ', mtConfirmation, [mbYes, mbNo], 0) = mrYes then 
begin 
if fileexists('PraeAktion.txt') then begin {aha!} end 
else 
begin 
assignfile(t,'PraeAktion.txt'); rewrite(t); writeln(t, 'Ausgabe'); closefile(t); 
end; 

assignfile(t,'PraeAktion.txt'); reset(t); readln(t,aktion); closefile(t); 
if aktion = 'Ausgabe' then 
begin 
assignfile(t, 'PraeAktion.txt'); rewrite(t); 
aktion := 'Abgabe'; writeln(t, aktion); closefile(t); 
showmessage('Tabelle <buecher> muss jetzt sortiert werden!'); rufe_borland_dbdclick(self); 
q1sort(self); 
end; 
showmessage('Bücherprogramm setzt nach Sortprüfung wieder auf ...'); 

b := 0; dbgrid5.visible := false; 
repeat 
b := b+1; table3.first; gef := false; 
repeat 
if table3.Fields[0].asstring = stringgrid5.cells[b,0] then gef := true // Buchtitel in T3 gefunden 
else table3.next; 
until gef or table3.eof; 
if gef then 
begin 
if (strtoint(stringgrid5.cells[b,1]) > 0) and (sg8anz = 0) then 
begin 
weiter := true; 
repeat 
if table3.fields[2].asstring <> stringgrid5.cells[0,1] then table3.next 
until (table3.fields[2].asstring = stringgrid5.cells[0,1]) or table3.EOF; 
if table3.eof then 
begin 
showmessage ('Klasse/Lehrkraft hat dieses Buch nicht! '+inttostr(b)); 
weiter := false; 
end; 
if weiter = true then 
begin 
k := 0; 
repeat 
if (table3.fields[2].asstring = stringgrid5.cells[0,1]) then 
begin 
k := k+1; 
table3.edit; // Abgabedatum eintragen 
table3.fields[4].asstring := label32.caption; 
table3.post; 
end; 
table3.next; 
until (k = strtoint(stringgrid5.cells[b,1])) or (table3.EOF); // table3.fields[2].asstring <> stringgrid5.cells[0,1]; 
// *************** 
{with query1 do 
begin 
SQL.Text := 'update buecher.dbf set A_DATUM = :A_DATUM where A_DATUM = :OLD_A_DATUM;'; 
parambyname('OLD_KLASSE').asstring := stringgrid5.cells[0,1]; 
parambyname('OLD_A_DATUM').asstring := label32.caption; 
ExecSQL; 
end;}
 
// *************** 
if messagedlgpos('Buch aus dem Buchsatz löschen? ', 
mtConfirmation, mbYesNoCancel, 0,200,475) = mrYes then 
begin 
table2.first; gef := false; 
repeat 
if table2.fields[0].asstring = stringgrid5.cells[0,1] then gef := true 
else table2.next; 
until gef; 
n := 2; gef := false; 
repeat 
if table2.fields[n].asstring = stringgrid5.cells[b,0] then gef := true 
else n := n+1; 
until gef; // table2.fields[n].asstring = ''; 
table2.edit; // wird aus dem Buchsatz 
if n < table2.fieldcount-1 then 
begin // entfernt, die folgenden 
repeat 
table2.fields[n].asstring := table2.fields[n+1].asstring; // Bücher rücken auf 
n := n + 1; 
until (table2.fields[n].asstring = '') or (n = table2.fieldcount-1); 
end; 
table2.post; 
end; 

table4.first; gef := false; 
repeat 
if table4.fields[0].asstring = stringgrid5.cells[b,0] then gef := true 
else table4.next; 
until gef or table4.eof; 
if gef then 
begin // addiere in T4 
h1 := strtoint(table4.fields[8].asstring); 
h1 := h1 + k; // + strtoint(stringgrid5.cells[b,1]); 
table4.Edit; table4.fields[8].asstring := inttostr(h1); table4.post; 
if k = 1 then showmessage(inttostr(k)+ ' Buch in T4 addiert! ') 
else showmessage(inttostr(k)+ ' Bücher in T4 addiert! '); 
end 
end 
end; 

if sg8anz > 0 then // von einer Schülergrp 
begin // oder 
n := 0; // von einem Schüler 
repeat 
n := n+1; sgef := false; 
repeat 
if (table3.fields[5].asstring = stringgrid8.cells[1,n]) and 
(table3.fields[6].asstring = stringgrid8.cells[2,n]) then sgef := true 
else table3.next; 
until sgef or table3.eof; 
if sgef and (stringgrid5.cells[b,1] = '1') then // z. B. Fra, Eng 
begin 
table3.edit; table3.fields[4].asstring := label32.caption; table3.post; 
end; 
table3.next; 
until n = sg8anz; 

table4.first; gef := false; 
repeat 
if (table4.fields[0].asstring = stringgrid5.cells[b,0]) then gef := true 
else table4.next; // Titel muss Unikat sein! 
until gef or table4.eof; 
if gef then 
begin // addiere in T4, wenn Buch zurück 
if stringgrid5.cells[b,1] <> '0' then 
begin 
h1 := strtoint(table4.fields[8].asstring); h1 := h1 + sg8anz; 
table4.Edit; table4.fields[8].asstring := inttostr(h1); table4.post; 
if sg8anz = 1 then showmessage(inttostr(sg8anz)+ ' Buch in T4 addiert! ') 
else showmessage(inttostr(sg8anz)+ ' Bücher in T4 addiert! '); 
end; 
end; 
end; 
end; 
until b = strtoint(label33.caption); 
table3.refresh; showmessage ('weiter mit beliebiger Taste ... '); 
dbgrid5.visible := true; 
ort := 'Zeilenvektorabgabe '+stringgrid5.cells[0,1]; leihprotokoll(self, b, ort); 
showmessage('Tabelle 3 (Bücher) wird jetzt sortiert ausgegeben ..'); q1sort(self); 
buecherfreigabeclick(self); form2.szopendialog1.filename := 'leihprotokoll.txt'; 
end 
else begin showmessage('Bücherabgabe abgebrochen!'); button12.setfocus; end; 
end;


Herzlichen Dank, wenn ihr euch noch einmal bemüht, es wäre mir sehr geholfen!
Wahrscheinlich erkennt ihr Profis noch weitere "Macken", aber ich bin ein guter "Lerner" und kann durch Tipps weiterdenken.

Viele Grüße, Detlef

Moderiert von user profile iconUGrohne: Delphi-Tags korrigiert.
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mi 25.08.04 07:21 
@Annies: Könntest Du Deinen Code im letzten Beitrag nochmal neu reinposten, weil der ist durch die Delphi-Tags (die ich korrigiert habe) ziemlich unleserlich geworden und mir fehlt gerade die Zeit dazu ;-)

Die Delphi-Tags werden ohne das Leerzeichen geschrieben, also so:

[delphi]code[/delphi]

Dann klappt's auch mit den anderen Mitgliedern ;-)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 25.08.04 13:54 
Hi, Helpher,

so, der Code, ist oben auch schon lesbar:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
procedure TForm1.Button13Click(Sender: TObject);              // Die eigentliche    
                                                                 Bücherabgabe  
var gef, sgef, weiter : boolean;                              // als Zeilenvektor  
   k, h1, b, n        : integer;  
   t                  : textfile;  
   aktion             : string[30];  
begin  
  if MessageDlg('   Klasse, Untergruppe, Lehrkraft'+#13+  
                '    gibt Buch/Bücher KOMPLETT ab'+#13+  
                '(oder wie in der Untertabelle zu sehen)'+#13+  
                '           Alle Angaben oK? ', mtConfirmation, [mbYes, mbNo], 0) = mrYes then  
  begin  
    if fileexists('PraeAktion.txt') then    begin  {aha!}  end  
    else  
    begin  
      assignfile(t,'PraeAktion.txt'); rewrite(t); writeln(t, 'Ausgabe'); closefile(t);  
    end;  

 
    assignfile(t,'PraeAktion.txt'); reset(t); readln(t,aktion); closefile(t);  
    if aktion = 'Ausgabe' then  
    begin  
      assignfile(t, 'PraeAktion.txt'); rewrite(t);  
      aktion := 'Abgabe'; writeln(t, aktion); closefile(t);  
      showmessage('Tabelle <buecher> muss jetzt sortiert werden!'); rufe_borland_dbdclick(self);  
      q1sort(self);  
    end;  
    showmessage('Bücherprogramm setzt nach Sortprüfung wieder auf ...');  

    b := 0; dbgrid5.visible := false;  
    repeat  
      b := b+1; table3.first;  gef := false;  
      repeat  
        if table3.Fields[0].asstring = stringgrid5.cells[b,0] then gef := true  // Buchtitel in T3 gefunden  
        else  table3.next;  
      until gef or table3.eof;  
      if gef then  
      begin  
        if (strtoint(stringgrid5.cells[b,1]) > 0) and (sg8anz = 0) then  
        begin  
          weiter := true;  
          repeat  
            if table3.fields[2].asstring <> stringgrid5.cells[0,1] then table3.next  
          until (table3.fields[2].asstring = stringgrid5.cells[0,1]) or table3.EOF;  
          if table3.eof then  
          begin  
            showmessage ('Klasse/Lehrkraft hat dieses Buch nicht!  '+inttostr(b));  
            weiter := false;  
          end;  
          if weiter = true then  
          begin  
            k := 0;  
            repeat  
              if (table3.fields[2].asstring = stringgrid5.cells[0,1]) then  
              begin  
                k := k+1;  
                table3.edit;                                            // Abgabedatum eintragen  
                  table3.fields[4].asstring := label32.caption;  
                table3.post;  
              end;  
              table3.next;  
            until (k = strtoint(stringgrid5.cells[b,1])) or (table3.EOF); // table3.fields[2].asstring <> stringgrid5.cells[0,1];  
     // ***************  
            {with query1 do  
            begin  
              SQL.Text := 'update buecher.dbf set A_DATUM = :A_DATUM where A_DATUM = :OLD_A_DATUM;';  
              parambyname('OLD_KLASSE').asstring  := stringgrid5.cells[0,1];  
              parambyname('OLD_A_DATUM').asstring := label32.caption;  
              ExecSQL;  
            end;}
  
     // ***************  
            if messagedlgpos('Buch aus dem Buchsatz löschen? ',  
                mtConfirmation, mbYesNoCancel, 0,200,475) = mrYes then  
            begin  
              table2.first; gef := false;  
              repeat  
                if table2.fields[0].asstring = stringgrid5.cells[0,1] then gef := true  
                else table2.next;  
              until gef;  
              n := 2; gef := false;  
              repeat  
                if table2.fields[n].asstring = stringgrid5.cells[b,0] then gef := true  
                else n := n+1;  
              until gef;  // table2.fields[n].asstring = '';  
              table2.edit;                                          // wird aus dem Buchsatz  
                if n < table2.fieldcount-1 then  
                begin                                                 // entfernt, die folgenden  
                  repeat  
                    table2.fields[n].asstring := table2.fields[n+1].asstring; // Bücher rücken auf  
                    n := n + 1;  
                  until (table2.fields[n].asstring = '') or (n = table2.fieldcount-1);  
                end;  
              table2.post;  
            end;  

            table4.first; gef := false;  
            repeat  
              if table4.fields[0].asstring = stringgrid5.cells[b,0] then gef := true  
              else  table4.next;  
            until gef or table4.eof;  
            if gef then  
            begin                                                               // addiere in T4  
              h1 := strtoint(table4.fields[8].asstring);  
              h1 := h1 + k;   // + strtoint(stringgrid5.cells[b,1]);  
              table4.Edit; table4.fields[8].asstring := inttostr(h1); table4.post;  
              if k = 1 then showmessage(inttostr(k)+ ' Buch in T4 addiert! ')  
              else          showmessage(inttostr(k)+ ' Bücher in T4 addiert! ');  
            end  
          end  
        end;  

        if sg8anz > 0 then                                         // von einer Schülergrp  
        begin                                                      //      oder  
          n := 0;                                                  // von einem Schüler  
          repeat  
            n := n+1; sgef := false;  
            repeat  
              if (table3.fields[5].asstring = stringgrid8.cells[1,n]) and  
                 (table3.fields[6].asstring = stringgrid8.cells[2,n]) then sgef := true  
              else table3.next;  
            until sgef or table3.eof;  
            if sgef and (stringgrid5.cells[b,1] = '1') then       // z. B. Fra, Eng  
            begin  
              table3.edit; table3.fields[4].asstring := label32.caption; table3.post;  
            end;  
            table3.next;  
          until n = sg8anz;  

          table4.first; gef := false;  
          repeat  
            if (table4.fields[0].asstring = stringgrid5.cells[b,0]) then gef := true  
            else  table4.next;                                    // Titel muss Unikat sein!  
          until gef or table4.eof;  
          if gef then  
          begin                                    // addiere in T4, wenn Buch zurück  
            if stringgrid5.cells[b,1] <> '0' then  
            begin  
              h1 := strtoint(table4.fields[8].asstring); h1 := h1 + sg8anz;  
              table4.Edit; table4.fields[8].asstring := inttostr(h1); table4.post;  
              if sg8anz = 1 then showmessage(inttostr(sg8anz)+ ' Buch in T4 addiert! ')  
              else               showmessage(inttostr(sg8anz)+ ' Bücher in T4 addiert! ');  
            end;  
          end;  
        end;  
      end;  
    until b = strtoint(label33.caption);  
    table3.refresh;  showmessage ('weiter mit beliebiger Taste ... ');  
    dbgrid5.visible := true;  
    ort := 'Zeilenvektorabgabe '+stringgrid5.cells[0,1]; leihprotokoll(self, b, ort);  
    showmessage('Tabelle 3 (Bücher) wird jetzt sortiert ausgegeben ..'); q1sort(self);  
    buecherfreigabeclick(self); form2.szopendialog1.filename := 'leihprotokoll.txt';  
  end  
  else  begin showmessage('Bücherabgabe abgebrochen!'); button12.setfocus; end;  
end;



Oben im Kommentar ist mein Vorschlag zu sehen, wie ich ich es bisher verstanden habe, ich weiß nicht genau, ob er richtig ist und für die zweite Stelle weiter unten bräuchte ich noch eine Lösungshilfe, dann habe ich es wohl langsam verstanden!

Vielen Dank für Hilfe, Detlef Annies

Moderiert von user profile iconUGrohne: 157 Leerzeilen entfernt ;-)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 27.08.04 16:08 
Halo, Helpher,

scheint ja nicht so einfach zu sein, meine Frage(n) zu beantworten, oder seid ihr alle im Urlaub? 8)

Würde mich jedenfalls freuen, eine Lösung für die beiden table/query-Operationen in SQL zu bekommen!

Grüße, Detlef Annies