Example #1
0
 //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();
     }
 }
Example #2
0
 //TextChanged
 private void txUserName_TextChanged(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(txUserName.Text))
     {
         MyChecker.setErr(txUserName, errorUserName, "Please enter username!", Properties.Resources.ERROR); lbErrorLogIn.Visible = false;
     }
     else
     {
         errorUserName.Clear();
     }
 }
Example #3
0
 private void txPassword_TextChanged(object sender, EventArgs e)
 {
     errorPassword.Icon = Properties.Resources.ERROR;
     if (String.IsNullOrEmpty(txPassword.Text))
     {
         MyChecker.setErr(txPassword, errorPassword, "Please enter password!", Properties.Resources.ERROR); lbErrorLogIn.Visible = false;
     }
     else
     {
         errorPassword.Clear();
     }
 }
Example #4
0
 //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();
     }
 }
Example #5
0
 private void txConfirmPasswrod_TextChanged(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(txConfirmPasswrod.Text))
     {
         MyChecker.setErr(txConfirmPasswrod, errorRe, "Enter your password", Properties.Resources.ERROR); confirm = false;
     }
     else if (!txConfirmPasswrod.Text.Equals(txNewPassword.Text))
     {
         MyChecker.setErr(txConfirmPasswrod, errorRe, "Password is not match!", Properties.Resources.ERROR); confirm = false;
     }
     else
     {
         MyChecker.setErr(txConfirmPasswrod, errorRe, "Available!", Properties.Resources.OK); confirm = true;
     }
 }
Example #6
0
 private void txReEnterPw_TextChanged(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(txReEnterPw.Text))
     {
         confirompw = false; return;
     }
     else if (txReEnterPw.Text.Equals(txForgetPw.Text) && !String.IsNullOrEmpty(txReEnterPw.Text))
     {
         MyChecker.setErr(txReEnterPw, errorConfiromPw, "Available!", Properties.Resources.OK); confirompw = true;
     }
     else
     {
         MyChecker.setErr(txReEnterPw, errorConfiromPw, "Password do not match", Properties.Resources.ERROR); confirompw = false;
     }
 }
Example #7
0
 private void txConfiromPw_TextChanged(object sender, EventArgs e)
 {
     btSignIn.Enabled = checkNotEmptyOrNull();
     if (String.IsNullOrEmpty(txConfiromPw.Text))
     {
         confirompw = false; return;
     }
     else if (txConfiromPw.Text.Equals(txNewPassword.Text) && !String.IsNullOrEmpty(txConfiromPw.Text))
     {
         MyChecker.setErr(txConfiromPw, errorConfiromPw, "Available!", Properties.Resources.OK); confirompw = true;
     }
     else
     {
         MyChecker.setErr(txConfiromPw, errorConfiromPw, "Password do not match", Properties.Resources.ERROR); confirompw = false;
     }
 }
Example #8
0
 //TextChanged
 private void txNewUserName_TextChanged(object sender, EventArgs e)
 {
     btSignIn.Enabled = checkNotEmptyOrNull();
     if (String.IsNullOrEmpty(txNewUserName.Text))
     {
         username = false; return;
     }
     else if (MyChecker.checkUserName(txNewUserName.Text))
     {
         MyChecker.setErr(txNewUserName, errorUserName, "User name alreader exists!", Properties.Resources.ERROR); username = false;
     }
     else
     {
         MyChecker.setErr(txNewUserName, errorUserName, "Available!", Properties.Resources.OK); username = true;
     }
 }
Example #9
0
        private void txNewEmail_TextChanged(object sender, EventArgs e)
        {
            var temp = sender as TextBox;

            btSignIn.Enabled = checkNotEmptyOrNull();
            if (String.IsNullOrEmpty(temp.Text))
            {
                email = false; return;
            }
            else if (!MyChecker.isEmail(temp.Text))
            {
                MyChecker.setErr(temp, errorEmail, "Email Invailable!", Properties.Resources.ERROR); email = false;
            }
            else
            {
                MyChecker.setErr(temp, errorEmail, "Available!", Properties.Resources.OK); email = true;
            }
        }
Example #10
0
        private void txNewPassword_TextChanged(object sender, EventArgs e)
        {
            var temp = sender as TextboxPassword;

            if (String.IsNullOrEmpty(temp.Text))
            {
                curr = false;
            }
            else if (MyChecker.HaveUnicodeCharacter(temp.Text))
            {
                MyChecker.setErr(temp, errorNew, "Can't accept password with a unicode character. Please try again!!", Properties.Resources.ERROR); newpw = false;
            }
            else if (!MyChecker.isPassword(temp.Text))
            {
                MyChecker.setErr(temp, errorNew, "Password need a-z, A-Z, 0-9 and symbol for a stronger password!", Properties.Resources.ERROR); newpw = false;
            }
            else
            {
                MyChecker.setErr(temp, errorNew, "Available!", Properties.Resources.OK); newpw = true;
            }
        }
Example #11
0
 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;
 }
Example #12
0
 public frmAccountSetting()
 {
     InitializeComponent();
     //Text Change
     txChangeEmail.TextChanged += (o, e) =>
     {
         var temp = o as TextBox;
         if (!MyChecker.isEmail(temp.Text))
         {
             MyChecker.setErr(temp, errorChangeEmail, "Email Invailable!", Properties.Resources.ERROR); return;
         }
         else
         {
             MyChecker.setErr(temp, errorChangeEmail, "Available!", Properties.Resources.OK); btChangeEmail.Enabled = true;
         }
     };
     //Button Click
     btChangeEmail.Click += (o, e) =>
     {
         frmEnterPassword frmPasswrod = new frmEnterPassword(btChangeEmail, txChangeEmail);
         frmPasswrod.ShowDialog();
     };
 }
Example #13
0
 //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);
     }
 }
Example #14
0
 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);
         }
     };
 }