Ejemplo n.º 1
0
 private void PasswordTextBox_TextChanged(object sender, EventArgs e)
 {
     if (PasswordTextBox.Text != string.Empty)
     {
         PasswordErrorProvider.Clear();
     }
     else
     {
         PasswordErrorProvider.SetError(PasswordTextBox, "Password Required");
     }
 }
Ejemplo n.º 2
0
 private void btnLogIn_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(this.txtUserName.Text))
     {
         UserNameErrorProvider.SetError(txtUserName, "Username empty!");
         txtUserName.Focus();
     }
     else if (string.IsNullOrWhiteSpace(this.txtPassword.Text))
     {
         PasswordErrorProvider.SetError(txtPassword, "Password empty!");
         txtPassword.Focus();
     }
     else
     {
         UserNameErrorProvider.Clear();
         PasswordErrorProvider.Clear();
         try {
             clsUtility.ExecuteSQLQuery(" SELECT * FROM Users WHERE  UserName = '******' AND Password = '******' ");
             if (clsUtility.sqlDT.Rows.Count > 0)
             {
                 clsUtility.UserID         = clsUtility.sqlDT.Rows[0]["USER_ID"].ToString();
                 clsUtility.UserName       = clsUtility.sqlDT.Rows[0]["UserName"].ToString();
                 clsUtility.UsersPrivilege = clsUtility.sqlDT.Rows[0]["Privilege"].ToString();
                 if (chkRememberMe.Checked)
                 {
                     Properties.Settings.Default.App_UserName     = txtUserName.Text;
                     Properties.Settings.Default.App_UserPassword = txtPassword.Text;
                 }
                 else
                 {
                     Properties.Settings.Default.App_UserName     = null;
                     Properties.Settings.Default.App_UserPassword = null;
                 }
                 Properties.Settings.Default.App_UserRemember = chkRememberMe.Checked;
                 Properties.Settings.Default.Save();
                 frmMDIParent frmMDIParent = new frmMDIParent();
                 frmMDIParent.Show();
                 this.Hide();
             }
             else
             {
                 lblWaring.Visible = true;
                 lblWaring.Text    = "No such user.";
             }
         }
         catch (Exception) {
             lblWaring.Visible = true;
             lblWaring.Text    = "Error executing sql statement.";
         }
     }
 }