Einzelnen Beitrag anzeigen

xSkaschY

Registriert seit: 19. Jun 2006
Ort: Bünde
95 Beiträge
 
Delphi 2007 Professional
 
#7

Re: 2 Daten -> durchlaufen und verarbeiten.

  Alt 2. Jul 2006, 18:57
Danke ! genau soetwas habe ich gesucht.


Wenn ich 2 Daten in einer Schleife benutze, werden diese automatisch immer um 1 Tag pro durchlauf erhöht, oder wie sehe ich das?

By the way:

Delphi-Quellcode:
for i := Trunc(StartDateTimePicker.Date) to Trunc(StopDateTimePicker.Date) do
begin
  tn := 'table_' + FormatDateTime('dd_mm_yy', i);
  showmessage(tn);
end;
Dürfte etwas schneller sein

Soo.. nun meine Procedure.... Wie könnte ich Sie übersichtlicher gestalten?

Delphi-Quellcode:
procedure TformSuchmaske.searchItems(Sender: TObject);
var i, k, count: integer;
    statement, currenttable: string;
    extwhere, tn: String;
    y: Integer;
    status: boolean;
begin
  count:= 0;

  loading.Position := 0;

  grid_result.Visible := False;
  label_result.Visible := False;

  grid_result.Margins.Top := 47;
  loading.Visible := True;
  label_loaddata.Visible := True;

  label_loaddata.Caption := 'Lade Daten...';

  try
    grid_result.RowCount := 2;
    grid_result.FixedRows := 1;
    
    grid_result.Cells[0,0] := 'Auftragsnummer';
    grid_result.Cells[1,0] := 'MontuerID';
    grid_result.Cells[2,0] := 'Montuer';
    grid_result.Cells[3,0] := 'AKI';
    grid_result.Cells[4,0] := 'ONKZ';
    grid_result.Cells[5,0] := 'ASB';
    grid_result.Cells[6,0] := 'Rufnummer';
    grid_result.Cells[7,0] := 'Strass / Standort';
    grid_result.Cells[8,0] := 'LSZ';
    grid_result.Cells[9,0] := 'LSZZ';
    grid_result.Cells[10,0] := 'KU-Zeit';
      
    if MySQLConnection.Connected then begin

      MySQLQuery.SQL.Clear;
      MySQLQuery.SQLConnection := MySQLConnection;

      extwhere := ' WHERE `' + searchby.Text + '` LIKE ''%' + value_searchby.Text + '%''';

      k := 1;
      
      for i := Trunc(StartDateTimePicker.Date) to Trunc(StopDateTimePicker.Date) do
      begin
        
        Application.ProcessMessages;
        
          for y := 0 to value_table.Count - 1 do begin

          currenttable := value_table.Items[y];
          tn := 'table_' + FormatDateTime('dd_mm_yy', i);

          if currenttable = tn then begin
            status := true;
          end else status := false;

          if status then begin

            statement := 'SELECT `auftragsnr`, `montuerid`, `montuer`, `aki`, `onkz`, `asb`, `rufnr`, `strstandort`, `lsz`, `lszz`, `kuzeit` FROM `'+tn+'` ' + extwhere;

            count := count + mysql_num_rows(statement);

            loading.Max := count;

            MySQLQuery.SQL.Clear;
            MySQLQuery.SQL.Add(statement);
            MySQLQuery.Open;

            while not MySQLQuery.EOF do begin
              grid_result.Cells[0,k] := MySQLQuery.FieldByName('auftragsnr').AsString;
              grid_result.Cells[1,k] := MySQLQuery.FieldByName('montuerid').AsString;
              grid_result.Cells[2,k] := MySQLQuery.FieldByName('montuer').AsString;
              grid_result.Cells[3,k] := MySQLQuery.FieldByName('aki').AsString;
              grid_result.Cells[4,k] := MySQLQuery.FieldByName('onkz').AsString;
              grid_result.Cells[5,k] := MySQLQuery.FieldByName('asb').AsString;
              grid_result.Cells[6,k] := MySQLQuery.FieldByName('rufnr').AsString;
              grid_result.Cells[7,k] := MySQLQuery.FieldByName('strstandort').AsString;
              grid_result.Cells[8,k] := MySQLQuery.FieldByName('lsz').AsString;
              grid_result.Cells[9,k] := MySQLQuery.FieldByName('lszz').AsString;
              grid_result.Cells[10,k] := MySQLQuery.FieldByName('kuzeit').AsString;
              k := k + 1;
              MySQLQuery.Next;
              loading.Position := k;
              Application.ProcessMessages;
            end;
          end;
        end;
      end;

      grid_result.RowCount := k;

      MySQLQuery.Close;

    end else begin
      showmessage('Es besteht keine Verbindung zur Datenbank, bitte überprüfen Sie Ihre Einstellungen...');
    end;

  finally
    label_loaddata.Caption := 'Es wurden ' + IntToStr(count) + ' Datensätze gefunden';
    label_result.Visible := True;
    grid_result.Margins.Top := 70;
    grid_result.Visible := True;
    loading.Visible := False;
  end;

end;
  Mit Zitat antworten Zitat