Einzelnen Beitrag anzeigen

juelin

Registriert seit: 9. Mai 2006
Ort: Mannheim
142 Beiträge
 
Delphi XE5 Professional
 
#1

Firemonkey Segmentation fault (11)

  Alt 4. Jul 2019, 17:12
Hallo Delphi Gemeinde,
muss Euch leider nochmal nerven.
Mein erstes Firmemonkey-Programm.
Im Emulator läuft alles prima.
Der Fehler tritt nur im Handy auf.
In Unit1 habe ich zwei Eingabefelder (Edit1 und Edit2).
Nach dem Start des Programmes kann ich Edit1 eingeben und Edit2 erhält den Focus.
Aber sobald ich irgend ein Zeichen in Edit2 eingebe erhalte ich
Segmentation fault (11) (siehe Anhang).
Habe hier auch nichts gefunden wo weiter hilft.

Ich habe:
Windows 10
Delphi Rad-Studio XE5
Handy Sony Xperia 10

Code:

Delphi-Quellcode:
unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
  FMX.Edit, DBAccess, MyAccess, Data.DB, MemDS, System.DateUtils;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Button3: TButton;
    MyConnection1: TMyConnection;
    MyQuery1: TMyQuery;
    MyCommand1: TMyCommand;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Edit1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
      Shift: TShiftState);
    procedure Edit2KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
      Shift: TShiftState);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure MyConnection1AfterConnect(Sender: TObject);
    procedure MyCommand1AfterExecute(Sender: TObject; Result: Boolean);
    procedure MyCommand1BeforeExecute(Sender: TObject);
    procedure MyConnection1Error(Sender: TObject; E: EDAError;
      var Fail: Boolean);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    procedure Blankwegh;
    procedure Blankwegv;
    procedure Rueck;
    procedure maxlen;
    procedure ausricht;
    procedure Nummer;
    procedure numlad;
  end;

var
  Form1: TForm1;
  var JaNein: word;
  var Closestat: integer;
  var abbruch: Boolean;
  var mtasts: integer;
  var mlauf: integer;
  var mver: integer;
  var mart: integer;
  var Tag: integer;
  var Monat: integer;
  var Jahr: integer;
  var BUser: string;
  var anzrec: Integer;
  var sdate1: Char;
  var sdate2: String;
  var vwaehrs: string;
  var vtaus: Char;
  var vdezim: Char;
  var vwaehrz: Byte;
  var FSatz: string;
  var sta: integer;
  var sperr: integer;
  var DateSeparator: Char deprecated 'Use FormatSettings.DateSeparator';
  var ShortDateFormat: string deprecated 'Use FormatSettings.ShortDateFormat';
  var CurrencyString: string deprecated 'Use FormatSettings.CurrencyString';
  var ThousandSeparator: Char deprecated 'Use FormatSettings.ThousandSeparator';
  var DecimalSeparator: Char deprecated 'Use FormatSettings.DecimalSeparator';
  var CurrencyDecimals: Byte deprecated 'Use FormatSettings.CurrencyDecimals';
  var dcon: integer;
  var user: String;
  var passwd: String;
  var benutzer: string;
  var superu: string;
  var name: string;
  var anzp: integer;
  var SqlRet: Boolean;
  var vorname: string;
  var nachname: string;
  var ialpha: string;
  var inummer: integer;
  var inumkom: double;
  var iart: integer;
  var ilanmax: integer;

implementation

{$R *.fmx}

uses Unit2, Unit3;

procedure TForm1.Blankwegh;
  var laenge: integer;
  var stelle: integer;
  var vari12: integer;
  var zeichen: string;
begin
  laenge:=Length(ialpha);
  vari12:=0;
  if laenge > 0 then
  begin
    for stelle:=laenge downto 1 do
    begin
      zeichen:=Copy(ialpha,stelle,1);
      if (vari12 = 0) then
      begin
        if (zeichen <> ' ') then
        begin
          vari12:=stelle;
        end;
      end;
    end;
  end;
  if (vari12 > 0) then
  begin
    zeichen:=ialpha;
    ialpha:=Copy(zeichen,1,vari12);
  end else begin
    ialpha:='';
  end;
end;

procedure TForm1.Blankwegv;
  var laenge: integer;
  var stelle: integer;
  var vari12: integer;
  var zeichen: string;
begin
  laenge:=Length(ialpha);
  vari12:=0;
  if laenge > 0 then
  begin
    for stelle:=1 to laenge do
    begin
      zeichen:=Copy(ialpha,stelle,1);
      if (vari12 = 0) then
      begin
        if (zeichen <> ' ') then
        begin
          vari12:=stelle;
        end;
      end;
    end;
  end;
  if (vari12 > 0) then
  begin
    zeichen:=ialpha;
    ialpha:=Copy(zeichen,vari12,laenge-vari12+1);
  end else begin
    ialpha:='';
  end;
end;

procedure TForm1.Rueck;
begin
  Form1.Visible:=True;
  Closestat:=0;
  mtasts:=1;
  Form1.ActiveControl:=nil;
  if assigned(Form2) then
  begin
    Form2:=nil;
  end;
  if assigned(Form3) then
  begin
    Form3:=nil;
  end;
end;

procedure TForm1.maxlen;
  var laenge: integer;
  var h1: integer;
  var h2: integer;
begin
  laenge:=Length(ialpha);
  h1:=inummer - laenge;
  if laenge < inummer then
  begin
    if iart = 1 then
    begin
      for h2:=1 to h1 do
      begin
        ialpha:=ialpha+' ';
      end;
    end else begin
      for h2:=1 to h1 do
      begin
        ialpha:=' '+ialpha;
      end;
    end;
  end else begin
    if laenge > inummer then
    begin
      ialpha:=Copy(ialpha,1,inummer);
    end;
  end;
end;

procedure TForm1.ausricht;
  var laenge: integer;
  var stelle: integer;
begin
  ialpha:=IntToStr(inummer);
  laenge:=Length(ialpha);
  if laenge < ilanmax then
  begin
    for stelle:=1 to ilanmax-laenge do
    begin
      ialpha:=' '+ialpha;
    end;
  end;
end;

procedure TForm1.Nummer;
  var laenge: integer;
  var stelle: integer;
  var m: integer;
  var zeichen: string;
  var tt: string;
begin
  laenge:=Length(FSatz);
  tt:='';
  if laenge > 0 then
  begin
    tt:=FSatz;
    for stelle:=1 to laenge do
    begin
      zeichen:=Copy(FSatz,stelle,1);
      m:=0;
      if zeichen = '0then
      begin
        m:=1;
      end;
      if zeichen = '1then
      begin
        m:=1;
      end;
      if zeichen = '2then
      begin
        m:=1;
      end;
      if zeichen = '3then
      begin
        m:=1;
      end;
      if zeichen = '4then
      begin
        m:=1;
      end;
      if zeichen = '5then
      begin
        m:=1;
      end;
      if zeichen = '6then
      begin
        m:=1;
      end;
      if zeichen = '7then
      begin
        m:=1;
      end;
      if zeichen = '8then
      begin
        m:=1;
      end;
      if zeichen = '9then
      begin
        m:=1;
      end;
      if m = 0 then
      begin
        tt:='';
      end;
    end;
  end;
  FSatz:=tt;
end;

procedure TForm1.numlad;
  var laenge: integer;
  var stelle: integer;
  var m: integer;
  var zeichen: string;
  var tt: string;
begin
  inummer:=0;
  laenge:=Length(ialpha);
  if laenge > 3 then
  begin
    tt:='';
    for m:=1 to 4 do
    begin
      zeichen:=Copy(ialpha,m,1);
      if zeichen <> ' then
      begin
        FSatz:=zeichen;
        Nummer;
        if FSatz <> 'then
        begin
          tt:=tt+zeichen;
        end;
      end;
    end;
    laenge:=Length(tt);
    if laenge > 0 then
    begin
      inummer:=StrToInt(tt);
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Text:=' '+Chr(169)+'LINSOFT B V S Catering Datum: '+FormatDateTime('DD.MM.YYYY',now);
  Label2.Text:='';
  if (Closestat = 0) then
  begin
    if (mtasts = 1) then
    begin
      Closestat:=1;
      mtasts:=0;
      Form1.Visible:=False;
      Form2:=TForm2.Create(self);
      Form2.Show;
    end;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Label1.Text:=' '+Chr(169)+'LINSOFT B V S Catering Datum: '+FormatDateTime('DD.MM.YYYY',now);
  Label2.Text:='';
  if (Closestat = 0) then
  begin
    if (mtasts = 1) then
    begin
      mlauf:=0;
      Form1.close;
    end;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Label1.Text:=' '+Chr(169)+'LINSOFT B V S Catering Datum: '+FormatDateTime('DD.MM.YYYY',now);
  Label2.Text:='';
  if (Closestat = 0) then
  begin
    if (mtasts = 1) then
    begin
      Closestat:=1;
      mtasts:=0;
      Form1.Visible:=False;
      Form3:=TForm3.Create(self);
      Form3.Show;
    end;
  end;
end;

procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
  Shift: TShiftState);
  var h1: integer;
  var sper: string;
begin
  if mlauf = 1 then
  begin
    if ord(Key) = 13 then
    begin
      ialpha:=Edit1.Text;
      Label2.Text:='';
      Edit1.ReadOnly:=True;
      Form1.Blankwegh;
      Form1.Blankwegv;
      if ialpha <> 'then
      begin
        name:=ialpha;
        Form1.MyQuery1.SQL.Text:='SELECT * FROM user WHERE User=:Name';
        Form1.MyQuery1.ParamByName('Name').Name:='Name';
        Form1.MyQuery1.ParamByName('Name').DataType:=ftString;
        Form1.MyQuery1.ParamByName('Name').Value:=name;
        h1:=0;
        sper:='J';
        Form1.MyQuery1.Open;
        while not Form1.MyQuery1.EOF do
        begin
          h1:=1;
          sper:=Form1.MyQuery1.Fields[10].AsString;
          Form1.MyQuery1.Next;
        end;
        Form1.MyQuery1.Close;
        if h1 = 1 then
        begin
          if sper = 'Nthen
          begin
            anzp:=0;
            mlauf:=2;
            Edit2.ReadOnly:=False;
            Edit2.Text:='';
            Edit2.SetFocus;
          end else begin
            Form1.Label2.Text:='Benutzer ist gesperrt, Administrator kontaktieren';
            mlauf:=1;
            Edit1.ReadOnly:=False;
            Edit1.Text:='';
            Edit1.SetFocus;
          end;
        end else begin
          Form1.Label2.Text:='Benutzer nicht vorhanden';
          mlauf:=1;
          Edit1.ReadOnly:=False;
          Edit1.Text:='';
          Edit1.SetFocus;
        end;
      end else begin
        Form1.Label2.Text:='Benutzer muß eingegeben werden';
        mlauf:=1;
        Edit1.ReadOnly:=False;
        Edit1.Text:='';
        Edit1.SetFocus;
      end;
    end;
  end;
end;

procedure TForm1.Edit2KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
  Shift: TShiftState);
  var h1: integer;
  var pw1: string;
  var pw2: string;
  var zw1: string;
  var zw2: string;
  var zw3: string;
  var zw4: string;
  var zw5: integer;
  var zw6: string;
  var zw7: string;
  var zw8: string;
  var zw9: TDate;
  var zw10: TDate;
  var zw11: string;
  var zw12: string;
  var zw13: string;
begin
  if mlauf = 2 then
  begin
    if ord(Key) = 13 then
    begin
      ialpha:=Edit2.Text;
      Label2.Text:='';
      Edit2.ReadOnly:=True;
      Form1.Blankwegh;
      Form1.Blankwegv;
      if ialpha <> 'then
      begin
        pw1:=ialpha;
        Form1.MyCommand1.SQL.Clear;
        Form1.MyCommand1.SQL.Add('UPDATE user SET PW2=PASSWORD('''+pw1+''') WHERE User=:Name');
        Form1.MyCommand1.ParamByName('Name').Name:='Name';
        Form1.MyCommand1.ParamByName('Name').DataType:=ftString;
        Form1.MyCommand1.ParamByName('Name').Value:=name;
        Form1.MyCommand1.Execute;
        if SqlRet then
        begin
          Form1.MyQuery1.SQL.Text:='SELECT * FROM user WHERE User=:Name';
          Form1.MyQuery1.ParamByName('Name').Name:='Name';
          Form1.MyQuery1.ParamByName('Name').DataType:=ftString;
          Form1.MyQuery1.ParamByName('Name').Value:=name;
          h1:=0;
          Form1.MyQuery1.Open;
          while not Form1.MyQuery1.EOF do
          begin
            h1:=1;
            vorname:=Form1.MyQuery1.Fields[0].AsString;
            nachname:=Form1.MyQuery1.Fields[1].AsString;
            superu:=Form1.MyQuery1.Fields[11].AsString;
            pw1:=Form1.MyQuery1.Fields[13].AsString;
            pw2:=Form1.MyQuery1.Fields[14].AsString;
            Form1.MyQuery1.Next;
          end;
          Form1.MyQuery1.Close;
          if h1 = 1 then
          begin
            if pw1 = pw2 then
            begin
              benutzer:=name;
              BUser:=name;
              mlauf:=0;
              Button1.Visible:=True;
              Button3.Visible:=True;
              Label5.Visible:=False;
              Label6.Visible:=False;
              Edit1.Visible:=False;
              Edit2.Visible:=False;
              Form1.ActiveControl:=Button1;
            end else begin
              anzp:=anzp + 1;
              if anzp = 3 then
              begin
                Form1.MyCommand1.SQL.Clear;
                Form1.MyCommand1.SQL.Add('UPDATE user SET Sperre=:SP WHERE User=:Name');
                Form1.MyCommand1.ParamByName('SP').Name:='SP';
                Form1.MyCommand1.ParamByName('SP').DataType:=ftString;
                Form1.MyCommand1.ParamByName('SP').Value:='J';
                Form1.MyCommand1.ParamByName('Name').Name:='Name';
                Form1.MyCommand1.ParamByName('Name').DataType:=ftString;
                Form1.MyCommand1.ParamByName('Name').Value:=name;
                Form1.MyCommand1.Execute;
                if SqlRet then
                begin
                  Form1.MyQuery1.SQL.Text:='SELECT * FROM user WHERE User=:Name';
                  Form1.MyQuery1.ParamByName('Name').Name:='Name';
                  Form1.MyQuery1.ParamByName('Name').DataType:=ftString;
                  Form1.MyQuery1.ParamByName('Name').Value:=name;
                  Form1.MyQuery1.Open;
                  zw1:='';
                  zw2:='';
                  zw3:='';
                  zw4:='';
                  zw5:=0;
                  zw6:='';
                  zw7:='';
                  zw8:='';
                  zw9:=StrToDate('01.01.1900');
                  zw10:=StrToDate('01.01.1900');
                  zw11:='';
                  zw12:='';
                  zw13:='';
                  while not Form1.MyQuery1.EOF do
                  begin
                    zw1:=Form1.MyQuery1.Fields[0].AsString;
                    zw2:=Form1.MyQuery1.Fields[1].AsString;
                    zw3:=Form1.MyQuery1.Fields[2].AsString;
                    zw4:=Form1.MyQuery1.Fields[3].AsString;
                    zw5:=Form1.MyQuery1.Fields[4].AsInteger;
                    zw6:=Form1.MyQuery1.Fields[5].AsString;
                    zw7:=Form1.MyQuery1.Fields[6].AsString;
                    zw8:=Form1.MyQuery1.Fields[7].AsString;
                    zw9:=Form1.MyQuery1.Fields[8].AsDateTime;
                    zw10:=Form1.MyQuery1.Fields[9].AsDateTime;
                    zw11:=Form1.MyQuery1.Fields[10].AsString;
                    zw12:=Form1.MyQuery1.Fields[11].AsString;
                    zw13:=Form1.MyQuery1.Fields[12].AsString;
                    Form1.MyQuery1.Next;
                  end;
                  Form1.MyQuery1.Close;
                  Form1.MyCommand1.SQL.Clear;
                  Form1.MyCommand1.SQL.Add('INSERT INTO huser (Huser, Hzeit, Hart, Vorname, Nachname, Strasse, Hausnummer, PLZ, Ort, Handy, Festnetz, Geburtstag, Eintritt, Sperre, Supervisor, User, PW1)'+' VALUES (:Huser, :Hzeit, :Hart, :Vname, :Nname, :Str, :Hnr, :Plz, :Ort, :Han, :Tel, :Geb, :Ein, :Spe, :Sup, :Use, :PW1)');
                  Form1.MyCommand1.ParamByName('Huser').Name:='Huser';
                  Form1.MyCommand1.ParamByName('Huser').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Huser').Value:=name;
                  Form1.MyCommand1.ParamByName('Hzeit').Name:='Hzeit';
                  Form1.MyCommand1.ParamByName('Hzeit').DataType:=ftDateTime;
                  Form1.MyCommand1.ParamByName('Hzeit').Value:=now;
                  Form1.MyCommand1.ParamByName('Hart').Name:='Hart';
                  Form1.MyCommand1.ParamByName('Hart').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Hart').Value:='System Sperre';
                  Form1.MyCommand1.ParamByName('Vname').Name:='Vname';
                  Form1.MyCommand1.ParamByName('Vname').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Vname').Value:=zw1;
                  Form1.MyCommand1.ParamByName('Nname').Name:='Nname';
                  Form1.MyCommand1.ParamByName('Nname').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Nname').Value:=zw2;
                  Form1.MyCommand1.ParamByName('Str').Name:='Str';
                  Form1.MyCommand1.ParamByName('Str').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Str').Value:=zw3;
                  Form1.MyCommand1.ParamByName('Hnr').Name:='Hnr';
                  Form1.MyCommand1.ParamByName('Hnr').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Hnr').Value:=zw4;
                  Form1.MyCommand1.ParamByName('Plz').Name:='Plz';
                  Form1.MyCommand1.ParamByName('Plz').DataType:=ftInteger;
                  Form1.MyCommand1.ParamByName('Plz').Value:=zw5;
                  Form1.MyCommand1.ParamByName('Ort').Name:='Ort';
                  Form1.MyCommand1.ParamByName('Ort').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Ort').Value:=zw6;
                  Form1.MyCommand1.ParamByName('Han').Name:='Han';
                  Form1.MyCommand1.ParamByName('Han').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Han').Value:=zw7;
                  Form1.MyCommand1.ParamByName('Tel').Name:='Tel';
                  Form1.MyCommand1.ParamByName('Tel').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Tel').Value:=zw8;
                  Form1.MyCommand1.ParamByName('Geb').Name:='Geb';
                  Form1.MyCommand1.ParamByName('Geb').DataType:=ftDateTime;
                  Form1.MyCommand1.ParamByName('Geb').Value:=zw9;
                  Form1.MyCommand1.ParamByName('Ein').Name:='Ein';
                  Form1.MyCommand1.ParamByName('Ein').DataType:=ftDateTime;
                  Form1.MyCommand1.ParamByName('Ein').Value:=zw10;
                  Form1.MyCommand1.ParamByName('Spe').Name:='Spe';
                  Form1.MyCommand1.ParamByName('Spe').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Spe').Value:=zw11;
                  Form1.MyCommand1.ParamByName('Sup').Name:='Sup';
                  Form1.MyCommand1.ParamByName('Sup').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Sup').Value:=zw12;
                  Form1.MyCommand1.ParamByName('Use').Name:='Use';
                  Form1.MyCommand1.ParamByName('Use').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('Use').Value:=zw13;
                  Form1.MyCommand1.ParamByName('PW1').Name:='PW1';
                  Form1.MyCommand1.ParamByName('PW1').DataType:=ftString;
                  Form1.MyCommand1.ParamByName('PW1').Value:='';
                  Form1.MyCommand1.Execute;
                  if not SqlRet then
                  begin
                    Label2.Text:='Fehler beim Anlegen huser '+name;
                  end;
                  Form1.Label2.Text:='Passwort falsch, Benutzer '+name+' ist gesperrt';
                  mlauf:=1;
                  Edit1.ReadOnly:=False;
                  Edit1.Text:='';
                  Edit1.SetFocus;
                end else begin
                  Form1.Label2.Text:='Passwort falsch, Benutzer '+name+' konnte nicht gesperrt werden';
                  mlauf:=1;
                  Edit1.ReadOnly:=False;
                  Edit1.Text:='';
                  Edit1.SetFocus;
                end;
              end else begin
                Form1.Label2.Text:='Passwort falsch, wiederholen';
                mlauf:=2;
                Edit2.ReadOnly:=False;
                Edit2.Text:='';
                Edit2.SetFocus;
              end;
            end;
          end else begin
            Form1.Label2.Text:='Benutzer nicht vorhanden';
            mlauf:=1;
            Edit1.ReadOnly:=False;
            Edit1.Text:='';
            Edit1.SetFocus;
          end;
        end else begin
          Label2.Text:='Fehler bei Update User mit Name '+name;
          Edit2.Text:='';
          mlauf:=1;
          Edit1.ReadOnly:=False;
          Edit1.Text:='';
          Edit1.SetFocus;
        end;
      end else begin
        Form1.Label2.Text:='Passwort muß eingegeben werden';
        mlauf:=2;
        Edit2.ReadOnly:=False;
        Edit2.Text:='';
        Edit2.SetFocus;
      end;
    end;
  end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  Label1.Text:=' '+Chr(169)+'LINSOFT B V S Catering Datum: '+FormatDateTime('DD.MM.YYYY',now);
  Label2.Text:='';
  if sta = 1 then
  begin
    Form1.Caption:=' BVS Fahrdienst Version '+' <'+BUser+'>';
    Closestat:=0;
    mtasts:=1;
    ialpha:='';
    inummer:=0;
    inumkom:=0;
    iart:=1;
    mlauf:=0;
    mver:=0;
    sta:=2;
    sperr:=1;
    benutzer:='';
    DateSeparator:='.';
    ShortDateFormat:='dd.mm.yyyy';
    CurrencyString:='';
    ThousandSeparator:=Chr(0);
    DecimalSeparator:=',';
    CurrencyDecimals:=2;
    if dcon = 0 then
    begin
      MyConnection1.Open;
    end;
    Edit1.ReadOnly:=True;
    Edit2.ReadOnly:=True;
    Button1.Visible:=False;
    Button3.Visible:=False;
    if dcon = 1 then
    begin
      mlauf:=1;
      Edit1.ReadOnly:=False;
      Edit1.Text:='';
      Edit1.SetFocus;
    end;
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Label1.Text:=' '+Chr(169)+'LINSOFT B V S Catering Datum: '+FormatDateTime('DD.MM.YYYY',now);
  Form1.Cursor:=crDefault;
  if dcon = 1 then
  begin
    MyConnection1.Close;
  end;
  DateSeparator:=sdate1;
  ShortDateFormat:=sdate2;
  CurrencyString:=vwaehrs;
  ThousandSeparator:=vtaus;
  DecimalSeparator:=vdezim;
  CurrencyDecimals:=vwaehrz;
  Action:=TCloseAction.caFree;
  Form1.Free;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  Label1.Text:=' '+Chr(169)+'LINSOFT B V S Catering Datum: '+FormatDateTime('DD.MM.YYYY',now);
  if (abbruch) then
  begin
    CanClose:=true;
  end else begin
    Form1.Cursor:=crDefault;
    CanClose:=false;
    if (Closestat = 0) then
    begin
      JaNein:=messagedlg('Programm-Ende ?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TmsgDlgBtn.mbNo], 0);
      if (JaNein = mrYes) then
      begin
        CanClose:=true;
      end;
    end;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
  var ranz: integer;
  var anz: word;
  var xuser: string;
  var heute: string;
  var h1: integer;
  var h3: string;
begin
  Label1.Text:=' '+Chr(169)+'LINSOFT B V S Catering Datum: '+FormatDateTime('DD.MM.YYYY',now);
  Label2.text:='';
  Closestat:=0;
  mtasts:=1;
  ialpha:='';
  inummer:=0;
  inumkom:=0;
  iart:=1;
  mlauf:=0;
  BUser:='unknown';
  heute:=FormatDateTime('DD.MM.YYYY',now);
  h1:=StrLen(PChar(heute));
  if (h1 = 10) then
  begin
    h3:=Copy(heute, 1, 2);
    Tag:=StrToInt(h3);
    h3:=Copy(heute, 4, 2);
    Monat:=StrToInt(h3);
    h3:=Copy(heute, 7, 4);
    Jahr:=StrToInt(h3);
  end;
  vwaehrs:=CurrencyString;
  vtaus:=ThousandSeparator;
  vdezim:=DecimalSeparator;
  vwaehrz:=CurrencyDecimals;
  sdate1:=DateSeparator;
  sdate2:=ShortDateFormat;
  DateSeparator:='.';
  ShortDateFormat:='dd.mm.yyyy';
  CurrencyString:='';
  ThousandSeparator:=Chr(0);
  DecimalSeparator:=',';
  CurrencyDecimals:=2;
  abbruch:=false;
  sta:=1;
  dcon:=0;
  MyConnection1.Connected:=False;
  MyQuery1.Active:=False;
  Form1.Caption:=' BVS Fahrdienst Version '+' <'+BUser+'>';
  Label1.Text:=' '+Chr(169)+'LINSOFT B V S Catering Datum: '+FormatDateTime('DD.MM.YYYY',now);
end;

procedure TForm1.MyCommand1AfterExecute(Sender: TObject; Result: Boolean);
begin
  SqlRet:=Result;
end;

procedure TForm1.MyCommand1BeforeExecute(Sender: TObject);
begin
  SqlRet:=False;
end;

procedure TForm1.MyConnection1AfterConnect(Sender: TObject);
begin
  if MyConnection1.Connected then
  begin
    dcon:=1;
  end else begin
    JaNein:=messagedlg('keine Verbindung zur Datenbank', TMsgDlgType.mtError, [TMsgDlgBtn.mbOk], 0);
    Form1.close;
  end;
end;

procedure TForm1.MyConnection1Error(Sender: TObject; E: EDAError;
  var Fail: Boolean);
begin
  Fail:=False;
  Label2.Text:='Connection-Error: '+IntToStr(E.ErrorCode);
end;

end.
siehe Edit1.KeyUp und Edit2.KeyUp.
Edit1.Keyup läuft ohne Probleme.
Zum Edit2.KeyUp kommt das Programm nicht hin.

Danke und Gruß
Jürgen
Miniaturansicht angehängter Grafiken
bild2.jpg  
Jürgen Linder

Geändert von juelin ( 4. Jul 2019 um 19:04 Uhr)
  Mit Zitat antworten Zitat