private void PasswordTextBox_TextChanged(object sender, EventArgs e) { if (PasswordTextBox.Text != string.Empty) { PasswordErrorProvider.Clear(); } else { PasswordErrorProvider.SetError(PasswordTextBox, "Password Required"); } }
private void errorprovider() { if (UsernameTextBox.Text == string.Empty) { UsernameErrorProvider.SetError(UsernameTextBox, "Username Required"); } if (PasswordTextBox.Text == string.Empty) { PasswordErrorProvider.SetError(PasswordTextBox, "Password Required"); } }
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."; } } }
private void errorprovider() { if (AdminImagePictureEdit.Image == HandVeinPattern.Properties.Resources.noprofile) { ImageErrorProvider.SetError(AdminImagePictureEdit, "Admin Image Required"); } if (IDTextBox.Text == string.Empty) { IDErrorProvider.SetError(IDTextBox, "Admin ID Required"); } if (UsernameTextBox.Text == string.Empty) { UsernameErrorProvider.SetError(UsernameTextBox, "Username Required"); } if (PasswordTextBox.Text == string.Empty) { PasswordErrorProvider.SetError(PasswordTextBox, "Password Required"); } if (FirstNameTextBox.Text == string.Empty) { FirstNameErrorProvider.SetError(FirstNameTextBox, "First Name Required"); } if (LastNameTextBox.Text == string.Empty) { LastNameErrorProvider.SetError(LastNameTextBox, "Last Name Required"); } if (GenderComboBoxEdit.SelectedIndex == 0) { GenderErrorProvider.SetError(GenderComboBoxEdit, "Gender Required"); } if (EmailButtonEdit.Text == string.Empty) { EmailErrorProvider.SetError(EmailButtonEdit, "Email Required"); } }
/// <summary> /// Excute user login validation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoginButton_Click(object sender, EventArgs e) { User user = new User() { UserName = UserNameTextBox.Text.Trim(), Password = PasswordTextBox.Text.Trim() }; Response response = new Response(); if (string.IsNullOrEmpty(UserNameTextBox.Text.Trim())) { UserNameTextBox.Focus(); UserNameErrorProvider.SetError(UserNameTextBox, "UserName can't be vacant!"); } else { UserNameErrorProvider.SetError(UserNameTextBox, ""); if (string.IsNullOrEmpty(PasswordTextBox.Text.Trim())) { PasswordTextBox.Focus(); PasswordErrorProvider.SetError(PasswordTextBox, "Password can't be vacant!"); } else { PasswordErrorProvider.SetError(PasswordTextBox, ""); if (string.IsNullOrEmpty(IdentifyingCodeTextBox.Text.Trim())) { IdentifyingCodeTextBox.Focus(); IdentifyingCodeErrorProvider.SetError(IdentifyingCodeTextBox, "IdentifyingCode can't be vacant!"); } else { try { response = new UserService().Authentication(user); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } if (string.IsNullOrEmpty(response.Message)) { if (IdentifyingCodeTextBox.Text.Trim() == identifyingCode || IdentifyingCodeTextBox.Text.Trim().ToLowerInvariant() == identifyingCode.ToLowerInvariant() || IdentifyingCodeTextBox.Text.Trim().ToUpperInvariant() == identifyingCode.ToUpperInvariant()) { Form f = Application.OpenForms["StaffList"]; if (f == null) { f = new StaffList(); f.Show(); this.Hide(); } else { f.Show(); this.Hide(); } } else { MessageBox.Show("Identifying code do not match!", "System prompt", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show(response.Message, "System prompt", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearInformation(); Bind(); } } } } }