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:
| procedure TForm1.Get_SMD_Daten(); var AdoQuery: TAdoQuery; ini: TIniFile; tmpStr, SQL, LastSerNr: String; aDatum: TDate; SerNrPass, SerNrFail, SerNrPseudoFehler: Integer; tmpFloat: Extended; Anzahl, i, StringGridZeile: Integer; begin StringGridZeile := 0; StringGrid1.ColCount := 6; StringGrid1.Cells[0, StringGridZeile] := 'Linie'; StringGrid1.Cells[1, StringGridZeile] := 'FPY'; StringGrid1.Cells[2, StringGridZeile] := 'Gesamt'; StringGrid1.Cells[3, StringGridZeile] := 'Pass'; StringGrid1.Cells[4, StringGridZeile] := 'Fail'; StringGrid1.Cells[5, StringGridZeile] := 'Pseudo'; StringGrid1.ColWidths[0] := 80; StringGrid1.ColWidths[1] := 50; StringGrid1.ColWidths[2] := 50; StringGrid1.ColWidths[3] := 50; StringGrid1.ColWidths[4] := 50; StringGrid1.ColWidths[5] := 50;
ini:=TIniFile.Create( ExtractFilePath(ParamStr(0)) + '\LiveFirma.ini'); tmpStr := ini.ReadString('SMD', 'DBPfad', ''); AdoQuery := TAdoQuery.Create(nil); AdoQuery.ConnectionString := tmpStr; Anzahl := ini.ReadInteger('SMD', 'AnzahlLinien', 0);
for i := 1 to Anzahl do begin tmpStr := ini.ReadString('SMD', 'DBPfad', ''); AdoQuery := TAdoQuery.Create(nil); AdoQuery.ConnectionString := tmpStr;
inc(StringGridZeile); AdoQuery.SQL.Clear; AdoQuery.SQL.Add('SELECT BN.BN, HISTORY.SERIAL_NUM, Min(HISTORY.RESULT) AS RESULT, EVENTS.EVENT_TYPE'); AdoQuery.SQL.Add(' FROM (HISTORY INNER JOIN BN ON HISTORY.KEYBN = BN.KEYBN) LEFT JOIN EVENTS ON HISTORY.KEYHIST = EVENTS.KEYHIST');
aDatum := StrToDate('08.10.2008');
AdoQuery.SQL.Add(' WHERE '); tmpStr := FormatDateTime('YYYYMMDD', aDatum-1); SQL := SQL + '(HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 223%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 224%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 225%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 23%') + ' OR'; tmpStr := FormatDateTime('YYYYMMDD', aDatum); SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 00%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 01%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 02%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 03%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 04%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 050%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 051%') + ' OR'; SQL := SQL + ' HISTORY.TEST_BEGIN Like '+QuotedStr(tmpStr + ' 052%') + ')';
AdoQuery.SQL.Add(SQL); AdoQuery.SQL.Add(' GROUP BY HISTORY.ATE_NUM, BN.BN, HISTORY.SERIAL_NUM, EVENTS.EVENT_TYPE'); tmpStr := ini.ReadString('SMD', 'ATE_NUM_' + IntToStr(i), '0'); AdoQuery.SQL.Add(' HAVING (HISTORY.ATE_NUM='+tmpStr+') AND BN.BN='+QuotedStr('75.464.880')+' AND (EVENTS.EVENT_TYPE<>'+QuotedStr('r')+' Or EVENTS.EVENT_TYPE Is Null)'); AdoQuery.SQL.Add(' ORDER BY HISTORY.SERIAL_NUM, EVENTS.EVENT_TYPE;');
AdoQuery.Active := true; SerNrPass := 0; SerNrFail := 0; SerNrPseudoFehler := 0; While not AdoQuery.Eof do begin if LastSerNr <> AdoQuery.FieldByName('SERIAL_NUM').AsString then begin LastSerNr := AdoQuery.FieldByName('SERIAL_NUM').AsString; if (AdoQuery.FieldByName('RESULT').AsString = 'P') AND (AdoQuery.FieldByName('EVENT_TYPE').AsString = '' ) then inc(SerNrPass) else if AdoQuery.FieldByName('EVENT_TYPE').AsString = 'x' then inc(SerNrFail) else inc(SerNrPseudoFehler); end; AdoQuery.Next; end; tmpStr := ini.ReadString('SMD', 'Linie' + IntToStr(i), ''); tmpFloat := SerNrPass + SerNrFail + SerNrPseudoFehler; tmpFloat := 100 - ((SerNrFail + SerNrPseudoFehler) / (tmpFloat / 100)); StringGrid1.Cells[0, StringGridZeile] := tmpStr; StringGrid1.Cells[1, StringGridZeile] := FloatToStr(RundeAufStellen(tmpFloat, 2)); StringGrid1.Cells[2, StringGridZeile] := IntToStr(SerNrPass + SerNrFail + SerNrPseudoFehler); StringGrid1.Cells[3, StringGridZeile] := IntToStr(SerNrPass); StringGrid1.Cells[4, StringGridZeile] := IntToStr(SerNrFail); StringGrid1.Cells[5, StringGridZeile] := IntToStr(SerNrPseudoFehler); AdoQuery.Active := false; AdoQuery.Free; break; end; ini.Free; end; |