sysjames Posted October 6, 2018 Share Posted October 6, 2018 I am still having problems with my login form that I hope someone can help me with. The relevant code in the login form follows. The problem is that it will not present the error message at all, but just loops and finally exits without presenting an error message. I hope someone can give me a clue as to why it is behaving this way. Procedure TUniLoginForm1.LoginBtnClick(Sender: TObject); Var Acct: TAccount; Begin Acct := TAccount.Create; Try ModalResult := mrNone; While ModalResult = mrNone Do If LoadAccount(EmailEntry.Text, PassEntry.Text, Acct) Then Begin UniMainModule.SetAcct(Acct.SerialClass); ModalResult := mrOK End Else Begin MessageDlg('Password or Email is in error',mtWarning,[mbOK]); <<<<<<<Does not present this message dialog Inc(ErrorCount); If ErrorCount > 3 Then ModalResult := mrCancel; End; Finally Acct.Free; End; End; The LoadAccount that is called is: Function LoadAccount(Const Email, Pass: String; Var acct: TAccount): Boolean; Var MS: TMemoryStream; Begin MS := TMemoryStream.Create; Result := True; Try Try DoGetObject('acct.' + StringToHex(LowerCase(Email)), MS); acct.SerialClass := MS; Except Result := False; End; If (acct.Pass <> Pass) And (acct.AltPass <> Pass) Then Result := False; Finally MS.Free; End; End; Quote Link to comment Share on other sites More sharing options...
55143681 Posted October 7, 2018 Share Posted October 7, 2018 1 hour ago, sysjames said: I am still having problems with my login form that I hope someone can help me with. The relevant code in the login form follows. The problem is that it will not present the error message at all, but just loops and finally exits without presenting an error message. I hope someone can give me a clue as to why it is behaving this way. Procedure TUniLoginForm1.LoginBtnClick(Sender: TObject); Var Acct: TAccount; Begin Acct := TAccount.Create; Try ModalResult := mrNone; While ModalResult = mrNone Do If LoadAccount(EmailEntry.Text, PassEntry.Text, Acct) Then Begin UniMainModule.SetAcct(Acct.SerialClass); ModalResult := mrOK End Else Begin MessageDlg('Password or Email is in error',mtWarning,[mbOK]); <<<<<<<Does not present this message dialog Inc(ErrorCount); If ErrorCount > 3 Then ModalResult := mrCancel; End; Finally Acct.Free; End; End; The LoadAccount that is called is: Function LoadAccount(Const Email, Pass: String; Var acct: TAccount): Boolean; Var MS: TMemoryStream; Begin MS := TMemoryStream.Create; Result := True; Try Try DoGetObject('acct.' + StringToHex(LowerCase(Email)), MS); acct.SerialClass := MS; Except Result := False; End; If (acct.Pass <> Pass) And (acct.AltPass <> Pass) Then Result := False; Finally MS.Free; End; End; void __fastcall TUniLoginForm1::UniBitBtn2Click(TObject *Sender) { //登录 UniMainModule()->loginUserNo=UniEdit1->Text; // UniQuery1->Close(); UniQuery1->SQL->Clear(); UniQuery1->SQL->Add("select * from user_info where user_no=:p1"); UniQuery1->ParamByName("p1")->Value=UniMainModule()->loginUserNo; UniQuery1->Open(); if(UniQuery1->RecordCount<1) { ShowMessage("该用户不存在,请先注册用户!"); UniBitBtn1->Click(); return; } // UniQuery1->Close(); UniQuery1->SQL->Clear(); UniQuery1->SQL->Add("select * from user_info where user_no=:p1 and user_pass=:p2"); UniQuery1->ParamByName("p1")->Value=UniMainModule()->loginUserNo; UniQuery1->ParamByName("p2")->Value=AESEncryptStrToHex(UniEdit2->Text.Trim(), UniMainModule()->aesKey, TEncoding::ANSI, TEncoding::UTF8, kb128, UniMainModule()->aesKey, pmZeroPadding, false,rlCRLF, rlCRLF); UniQuery1->Open(); if(UniQuery1->RecordCount<1) { ShowMessage("密码错误!"); UniEdit2->SetFocus(); return; } UniMainModule()->loginUserName=UniQuery1->FieldByName("user_name")->AsString; UniMainModule()->loginUserTeam=UniQuery1->FieldByName("team_name")->AsString; UniMainModule()->loginUserPart=UniQuery1->FieldByName("part_name")->AsString; UniMainModule()->loginUserInst=UniQuery1->FieldByName("inst_name")->AsString; UniMainModule()->loginUserTel1=UniQuery1->FieldByName("user_tel1")->AsString; UniMainModule()->loginUserTel2=UniQuery1->FieldByName("user_tel2")->AsString; UniMainModule()->loginUserStat=UniQuery1->FieldByName("user_stat")->AsString; UniMainModule()->loginUserMail=UniQuery1->FieldByName("user_mail")->AsString; UniMainModule()->loginUserHead=UniQuery1->FieldByName("user_head")->AsString; //更新登录状态 UniQuery1->Close(); UniQuery1->SQL->Clear(); mySql="update user_info set user_stat='在线' where user_no=:p1"; UniQuery1->SQL->Add(mySql); UniQuery1->ParamByName("p1")->Value=UniMainModule()->loginUserNo; UniQuery1->ExecSQL(); // ModalResult=mrOk; //this->Close(); } Quote Link to comment Share on other sites More sharing options...
sysjames Posted October 7, 2018 Author Share Posted October 7, 2018 I'm sorry. I'm not sophisticated enough to understand your post. I'm not using a SQL Database, but rather Amazon S3 for object storage. I do thank you for your reply, however. Quote Link to comment Share on other sites More sharing options...
Tokay Posted October 7, 2018 Share Posted October 7, 2018 Does the MessageDlg called from the uniGUIForm module? Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted October 7, 2018 Share Posted October 7, 2018 Have you set EnableAsynchronousOperations to true? Quote Link to comment Share on other sites More sharing options...
sysjames Posted October 7, 2018 Author Share Posted October 7, 2018 EnableAsynchronousOperations was set to false. I don't know how I managed to unset it. That fixed the problem. Thanks to all for your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.