//Create new account private void btSignIn_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(MyConnect.getString("select Email from LogIn where Email=N'" + txNewEmail.Text + "'"))) { MyChecker.setErr(txNewEmail, errorEmail, "Email Invailable!", Properties.Resources.ERROR); email = false; txNewEmail.Focus(); return; } if (!username) { txNewUserName.Focus(); return; } else if (!email) { txNewEmail.Focus(); return; } else if (!password) { txNewPassword.Focus(); return; } else if (!confirompw) { txConfiromPw.Focus(); return; } else { if (ac.AddObject(new Account(txNewUserName.Text, StringPassword.EncrytString(txNewPassword.Text, Properties.Resources.KeyCrypt), cbManager.Checked, txNewEmail.Text))) { MessageBox.Show("Create new account successfully!"); } else { MessageBox.Show("Can't create account!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } setAutoCompleteCollection(); } }
private void btApply_Click(object sender, EventArgs e) { string key = StringPassword.RandomStringGenerator(10); account.password = StringPassword.EncrytString(txForgetPw.Text, Properties.Resources.KeyCrypt); if (ac.UpdateObject(account)) { MessageBox.Show("Successfully!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Please check password or email again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Text Change private void txCurrPassword_TextChanged(object sender, EventArgs e) { if (String.IsNullOrEmpty(txCurrPassword.Text)) { MyChecker.setErr(txCurrPassword, errorCur, "Enter your password", Properties.Resources.ERROR); curr = false; } else if (!txCurrPassword.Text.Equals(StringPassword.DecrytString(account.password, Properties.Resources.KeyCrypt))) { errorCur.Clear(); curr = false; } else { curr = true; errorCur.Clear(); } }
//Log in private void btLogin_Click(object sender, EventArgs e) { errorUserName.Icon = Properties.Resources.ERROR; errorPassword.Icon = Properties.Resources.ERROR; if (String.IsNullOrEmpty(txUserName.Text)) { errorUserName.SetError(txUserName, "Please enter user name!!"); //check textbox username } else { errorUserName.SetError(txUserName, null); } if (String.IsNullOrEmpty(txPassword.Text)) { errorPassword.SetError(txPassword, "Please enter password!!"); //check textbox password } else { errorUserName.SetError(txPassword, null); } if (!String.IsNullOrEmpty(txUserName.Text) && !String.IsNullOrEmpty(txPassword.Text)) { if (MyChecker.checkUserName(txUserName.Text) && MyChecker.checkPassword(txUserName.Text, txPassword.Text)) { MessageBox.Show("Log In successfully!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); lbErrorLogIn.Visible = false; if (cbRemember.Checked) { //save user name and password in setting file string key = Properties.Resources.KeyCrypt; Properties.Settings.Default.UserName = StringPassword.EncrytString(txUserName.Text, key); Properties.Settings.Default.Password = StringPassword.EncrytString(txPassword.Text, key); Properties.Settings.Default.Save(); } //Useris accessing Properties.Settings.Default.Accessing = txUserName.Text; Properties.Settings.Default.Service = ac.getObject(txUserName.Text).service; Properties.Settings.Default.Save(); this.Hide(); frmMain main = new frmMain(); main.setUserAccessing("User is accessing : " + txUserName.Text); main.Show(); } else { lbErrorLogIn.Visible = true; } } }
private void btSend_Click(object sender, EventArgs e) { code = StringPassword.RandomStringGenerator(6); account = (ac.getObject(ac.getUserName(txSendEmail.Text))); if (String.IsNullOrEmpty(txSendEmail.Text)) { return; } if (String.IsNullOrEmpty(account.username)) { MyChecker.setErr(txSendEmail, errorEmail, "Email is not available!", Properties.Resources.ERROR); txSendEmail.Focus(); } else if (MyAction.sendEmail(txSendEmail.Text, code)) { MessageBox.Show("If you don't received code, Please try send again!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); myEmail = txSendEmail.Text; } else { MessageBox.Show("If you don't received code, Please try send again!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txSendEmail.Focus(); } groupBox1.Visible = false; }
// //From load private void frmLogIn_Load(object sender, EventArgs e) { Screen s = Screen.PrimaryScreen; this.Left = (s.WorkingArea.Width - this.Width) / 2; this.Top = (s.WorkingArea.Height - this.Height) / 2; pnLogin.Visible = true; pnSignIn.Visible = false; btSignIn.Enabled = false; //Stop flickering typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, pnLogin, new object[] { true }); //Remember account if (!String.IsNullOrEmpty(Properties.Settings.Default.UserName) && !String.IsNullOrEmpty(Properties.Settings.Default.Password)) { txUserName.Text = StringPassword.DecrytString(Properties.Settings.Default.UserName, Properties.Resources.KeyCrypt); txPassword.Text = StringPassword.DecrytString(Properties.Settings.Default.Password, Properties.Resources.KeyCrypt); } txUserName.AutoCompleteMode = AutoCompleteMode.Suggest; txUserName.AutoCompleteSource = AutoCompleteSource.CustomSource; setAutoCompleteCollection(); }
//Button save private void btSaveShange_Click(object sender, EventArgs e) { if (!curr) { txCurrPassword.Focus(); MyChecker.setErr(txCurrPassword, errorCur, "Wrong passowrd!", Properties.Resources.ERROR); return; } if (!newpw) { txNewPassword.Focus(); return; } if (!confirm) { txConfirmPasswrod.Focus(); return; } account.password = StringPassword.EncrytString(txNewPassword.Text, Properties.Resources.KeyCrypt); if (new AccountDAO().UpdateObject(account)) { MessageBox.Show("Password saved!", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("There was an error, can't save password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public frmEnterPassword(Button btChangeEmail, TextBox txChangeEmail) { InitializeComponent(); txPassword.TextChanged += (o, e) => { if (!String.IsNullOrEmpty(txPassword.Text)) { btOk.Enabled = true; } else { btOk.Enabled = false; MyChecker.setErr(txPassword, errorPassword, "Please enter password!", Properties.Resources.ERROR); } }; btOk.Click += (o, e) => { if (txPassword.Text.Equals(StringPassword.DecrytString(account.password, Properties.Resources.KeyCrypt))) { account.email = txChangeEmail.Text; if (new AccountDAO().UpdateObject(account)) { MessageBox.Show("Successfully!", "Informaation", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Error, Check your Email again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } btChangeEmail.Enabled = false; this.Close(); } else { MyChecker.setErr(txPassword, errorPassword, "Passwrod is not avalibale!", Properties.Resources.ERROR); } }; }