private void txtPassword_Leave(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtPassword.Text)) { if (!UserMasterDao.LoginCheck(user.UserName, txtPassword.Text)) { MessageBox.Show(Constant.NOTIFICATION_INVALID_PASSWORD, Constant.NOTIFICATION_CAPTION_INVALID_PASSWORD, MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Text = ""; txtPassword.Focus(); } } }
private void btnLogin_Click(object sender, EventArgs e) { if (txtPassword.Text == string.Empty) { MessageBox.Show(Constant.NOTIFICATIO_VALIDATION_ALL_FIELD_IS_REQUIRED, Constant.NOTIFICATIO_VALIDATION_ALL_FIELD_IS_REQUIRED, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (txtPassword.Text == string.Empty) { MessageBox.Show(Constant.NOTIFICATIO_VALIDATION_ALL_FIELD_IS_REQUIRED, Constant.NOTIFICATIO_VALIDATION_ALL_FIELD_IS_REQUIRED, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } bool IsValid = false; UserMasterDto user = new UserMasterDto(); IsValid = UserMasterDao.LoginCheck(txtUserName.Text.Trim(), txtPassword.Text, out user); if (IsValid) { MDIParent mdi = new MDIParent(user); mdi.IsMdiContainer = true; mdi.Show(); mdi.BringToFront(); this.Hide(); } //if (txtUserName.Text == "user name") //{ // MessageBox.Show("Please intput your user name.", "User Name is required", MessageBoxButtons.OK, MessageBoxIcon.Stop); // txtUserName.Focus(); //} //else if (txtPassword.Text == "password") //{ // MessageBox.Show("Please intput your password.", "Password is required", MessageBoxButtons.OK, MessageBoxIcon.Stop); // txtPassword.Focus(); //} //else //{ // USER_MASTER _user = new USER_MASTER(); // try // { // using (BaseManager manager = new BaseManager()) // { // _user = manager.GetManagerInstance<UserManager>().GetUserByNameORPassword(txtUserName.Text.Trim(), txtPassword.Text.Trim()); // } // if (_user != null) // { // frmMDIParent _parent = new frmMDIParent(_user.USERNAME, _user.USERFULLNAME); // _parent.Show(); // _parent.BringToFront(); // this.Hide(); // } // else // { // MessageBox.Show("Login ID/Password is incorrect", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Stop); // } // } // catch (Exception ex) // { // MessageBox.Show("Error: " + ex.Message, "Fatal Error Occured!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); // } //} }