private void LoginUser(string loginId, string password) { try { if (!String.IsNullOrEmpty(txtLoginId.Text) && !String.IsNullOrEmpty(txtPassword.Text)) { DataSet ds = SocketClient.LoginUser(loginId, password, Options.Instance.ApplicationCode); if (ds != null && ds.Tables.Count > 0) { Kv kv = new Kv(ds.Tables[0]); int statusID = User.LoginMsg(kv, false); Srv.SetCurrentUser(kv); if (IsValidUser(kv, statusID)) { return; } if (Ap.CurrentUser.UserStatusIDE != UserStatusE.Gone) { UserStatus frm = new UserStatus(); frm.ShowDialog(); return; } SocketClient.LoginUser(Ap.CurrentUserID, UserStatusE.Blank); if (chkRemindPassword.Checked) { Options.Instance.LoginID = loginId; Options.Instance.Password = password; } else { Options.Instance.LoginID = ""; Options.Instance.Password = ""; } Options.Instance.Save(); LoadOnlineClient(); } else { MessageForm.Error(this, MsgE.ErrorServerConnection); } } else { MessageForm.Error(this, MsgE.ErrorEmptyIdPassword); } } catch (Exception ex) { TestDebugger.Instance.WriteError(ex); MessageForm.Show(ex); } }
private void LoginGuest() { try { DataSet ds = SocketClient.LoginGuest(); if (ds != null && ds.Tables.Count > 0) { Kv kv = new Kv(ds.Tables[0]); int statusID = User.LoginMsg(kv, true); Srv.SetCurrentUser(kv); //if (IsValidUser(kv, statusID)) //{ // return; //} //if (LoginMsg(kv1)) //{ // return; //} //Srv.SetCurrentUser(kv); SocketClient.LoginUser(Ap.CurrentUserID, UserStatusE.Blank); Options.Instance.LoginID = "Guest"; Options.Instance.Password = ""; Options.Instance.Save(); ApWin.StartupForm.Visible = false; this.Visible = false; this.Close(); OnlineClient frm = new OnlineClient(); frm.Show(); } else { MessageForm.Error(this, MsgE.ErrorServerConnection); } } catch (Exception ex) { TestDebugger.Instance.WriteError(ex); MessageForm.Show(ex); } }
private void Save() { UserKv.Password = UCrypto.Encrypt(txtPassword.Text); UserKv.PasswordHint = txtPasswordHint.Text; DataSet ds = SocketClient.AddUser(UserKv); if (ds != null && ds.Tables.Count > 0) { Kv kv = new Kv(ds.Tables[0]); Srv.SetCurrentUser(kv); SocketClient.LoginUser(Ap.CurrentUserID, UserStatusE.Blank); this.Visible = false; ApWin.StartupForm.Visible = false; OnlineClient frm = new OnlineClient(); frm.Show(); } this.Close(); }
private new void Update() { Kv.Email = txtEmail.Text; Kv.FirstName = txtFirstName.Text; Kv.LastName = txtLastName.Text; Kv.NearestCityID = Convert.ToInt32(cbNearestCity.SelectedValue); if (cbCountry.SelectedIndex != 0) { Kv.CountryID = Convert.ToInt32(cbCountry.SelectedValue); } if (rbMr.Checked) { Kv.GenderIDE = GenderE.Mr; } else if (rbMrs.Checked) { Kv.GenderIDE = GenderE.Mrs; } else { Kv.GenderIDE = GenderE.Comp; } if (chkFIDE.Checked) { if (rbFM.Checked) { Kv.FideTitleIDE = FideTitleE.FM; } else if (rbIM.Checked) { Kv.FideTitleIDE = FideTitleE.IM; } else { Kv.FideTitleIDE = FideTitleE.GM; } } else { Kv.FideTitleIDE = FideTitleE.None; } if (chkICCF.Checked) { if (rbIccfIM.Checked) { Kv.IccfTitleIDE = IccfTitleE.IM; } else if (rbIccfSIM.Checked) { Kv.IccfTitleIDE = IccfTitleE.SIM; } else if (rbIccfGM.Checked) { Kv.IccfTitleIDE = IccfTitleE.GM; } } else { Kv.IccfTitleIDE = IccfTitleE.None; } Kv.PersonalNotes = txtNotes.Text; Kv.DateOfBirth = dtpDateOfBirth.Value.ToString("MM/dd/yyyy"); //Kv.DateLastLogin = DateTime.Now; Kv.Url = txtURL.Text; if (UserImage != null) { GeUserImageBytes(); } DataSet ds = SocketClient.UpdateUser(Kv); if (ds != null && ds.Tables.Count > 0) { Kv kv1 = new Kv(ds.Tables[0]); Srv.SetCurrentUser(kv1); MessageForm.Show(this, MsgE.InfoUserUpdate); } string userTitle = " - InfinityChess Online"; if (this.User.HumanRankIDE != RankE.Guest) { userTitle = "[" + this.User.UserName + "] - " + this.User.FirstName + "," + this.User.LastName + userTitle; } else { userTitle = "[" + this.User.UserName + "] - " + "Guest" + userTitle; } ApWin.OnlineClientForm.Text = userTitle; this.DialogResult = DialogResult.OK; this.Close(); }