Example #1
0
 //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;
         }
     }
 }
Example #2
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;
     }
 }