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:
| procedure TfmArtikelverwaltung.acBtnSaveExecute(Sender: TObject); var qry: TZQuery; aid: Integer; begin fmArtikelverwaltung.FocusControl(edPrimary); qry := TZquery.Create(nil); qry.Connection := dm.Connection; with dm do begin if tblArtikelid.AsInteger > 0 then aid := tblArtikelid.AsInteger else aid := 0;
if tblArtikel.State = dsInsert then begin qry.SQL.Text := 'insert into v_artikel '+ '(artikelnr,erloesid,einheitid,wgruppeid,ugruppeid,herstid,typid,bestand,mindestbestand,hoechstbestand,kurztext,langtext,beschreibung,kommission,gebraucht,prozentual,ek_preis,preis,gewinnzuschlag)'+ 'values '+ '('+checkVal(tblArtikelartikelnr)+','+ checkVal(tblArtikelerloesid)+','+ checkVal(tblArtikeleinheitid)+','+ checkVal(tblArtikelwgruppeid)+','+ checkVal(tblArtikelugruppeid)+','+ checkVal(tblArtikelherstid)+','+ checkVal(tblArtikeltypid)+','+ checkVal(tblArtikelbestand)+ ','+ checkVal(tblArtikelmindestbestand)+','+ checkVal(tblArtikelhoechstbestand)+','+ checkVal(tblArtikelkurztext)+','+ checkVal(tblArtikellangtext)+','+ checkVal(tblArtikelbeschreibung)+','+ checkVal(tblArtikelkommission)+','+ checkVal(tblArtikelgebraucht)+','+ checkVal(tblArtikelprozentual)+','+ checkVal(tblArtikelek_preis)+','+ checkVal(tblArtikelpreis)+','+ checkVal(tblArtikelgewinnzuschlag)+')'; try qry.ExecSQL; tblArtikel.Cancel; tblArtikel.Refresh; tblArtikel.Last; except on e:exception do showmessage(e.Message); end; end;
if tblArtikel.State = dsEdit then begin qry.SQL.Text := 'update v_artikel set '+ 'artikelnr = '+checkVal(tblArtikelartikelnr)+', '+ 'erloesid = '+checkVal(tblArtikelerloesid)+', '+ 'einheitid = '+checkVal(tblArtikeleinheitid)+', '+ 'wgruppeid = '+checkVal(tblArtikelwgruppeid)+', '+ 'ugruppeid = '+checkVal(tblArtikelugruppeid)+', '+ 'herstid = '+checkVal(tblArtikelherstid)+', '+ 'typid = '+checkVal(tblArtikeltypid)+', '+ 'bestand = '+checkVal(tblArtikelbestand)+ ', '+ 'mindestbestand = '+checkVal(tblArtikelmindestbestand)+', '+ 'hoechstbestand = '+checkVal(tblArtikelhoechstbestand)+', '+ 'kurztext = '+checkVal(tblArtikelkurztext)+', '+ 'langtext = '+checkVal(tblArtikellangtext)+', '+ 'beschreibung = '+checkVal(tblArtikelbeschreibung)+', '+ 'kommission = '+checkVal(tblArtikelkommission)+', '+ 'gebraucht = '+checkVal(tblArtikelgebraucht)+', '+ 'prozentual = '+checkVal(tblArtikelprozentual)+', '+ 'ek_preis = '+checkVal(tblArtikelek_preis)+', '+ 'preis = '+checkVal(tblArtikelpreis)+', '+ 'gewinnzuschlag = '+checkVal(tblArtikelgewinnzuschlag)+' '+ 'where id = '+inttostr(aid); try qry.ExecSQL; tblArtikel.Cancel; tblArtikel.Refresh; tblArtikel.Locate('id', aid, []); except on e:exception do showmessage(e.Message); end; end; end; qry.Free; end;
function TfmArtikelverwaltung.checkVal(f: TField): String; var p: integer; begin result := 'null'; if (f is TIntegerField) then begin if f.AsInteger > 0 then result := f.AsString; end; if (f is TFloatField) then begin if f.AsCurrency > 0 then result := f.AsString; p := pos(',', result); if (p > 0) then result := StringReplace(result, ',', '.', []); end; if (f is TBooleanField) then begin if f.AsBoolean then result := 'true' else result := 'false'; end; if (f is TStringField) then begin if length(f.AsString) > 0 then result := quotedStr(f.AsString); end; end; |