/// <summary> /// Login /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Author: Le Tien Phat. /// Created date: 14/05/2011 /// </remarks> private void btnLogIn_Click(object sender, System.EventArgs e) { ep.SetError(txtUserName, ""); if(txtUserName.Text.Trim().Length == 0) { ep.SetError(txtUserName, clsResources.GetMessage("errors.required", "User name")); return; } clsAutUserBO login = new clsAutUserBO(); string userName = txtUserName.Text.Trim(); string password = txtPassword.Text; m_iLoginResult = login.Login(userName, password); switch(m_iLoginResult) { case clsConstants.ACCOUNT_NOT_EXIST://-2 MessageBox.Show(clsResources.GetMessage("errors.login.ACCOUNT_NOT_EXIST"), clsResources.GetMessage("errors.general"), MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Clear(); txtUserName.Focus(); txtUserName.SelectAll(); break; case clsConstants.PASSWORD_WRONG://-3: MessageBox.Show("Password is wrong", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); //txtPassword.Clear(); txtPassword.Focus(); txtPassword.SelectAll(); break; case clsConstants.ACCOUNT_INACTIVE://-4: MessageBox.Show("Account is not active", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); //txtPassword.Clear(); txtUserName.Focus(); txtUserName.SelectAll(); break; case clsConstants.ACCOUNT_EXPIRED://-5: MessageBox.Show("Account expired", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Clear(); txtUserName.Focus(); txtUserName.SelectAll(); break; case clsConstants.PASSWORD_EXPIRED://-6: MessageBox.Show("Password expired", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); clsSystemConfig.UserName = userName; frmChangePWD frm = new frmChangePWD(); this.Hide(); frm.ShowDialog(); this.Show(); txtPassword.Clear(); txtUserName.Focus(); txtUserName.SelectAll(); break; case clsConstants.LOGIN_SUCCESS: clsSystemConfig.UserName = userName; this.Close(); break; } }
/// <summary> /// Login /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Author: Le Tien Phat. /// Created date: 14/05/2011 /// </remarks> private void btnLogIn_Click(object sender, System.EventArgs e) { ep.SetError(txtUserName, ""); if (txtUserName.Text.Trim().Length == 0) { ep.SetError(txtUserName, clsResources.GetMessage("errors.required", "User name")); return; } clsAutUserBO login = new clsAutUserBO(); string userName = txtUserName.Text.Trim(); string password = txtPassword.Text; m_iLoginResult = login.Login(userName, password); switch (m_iLoginResult) { case clsConstants.ACCOUNT_NOT_EXIST: //-2 MessageBox.Show(clsResources.GetMessage("errors.login.ACCOUNT_NOT_EXIST"), clsResources.GetMessage("errors.general"), MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Clear(); txtUserName.Focus(); txtUserName.SelectAll(); break; case clsConstants.PASSWORD_WRONG: //-3: MessageBox.Show("Password is wrong", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); //txtPassword.Clear(); txtPassword.Focus(); txtPassword.SelectAll(); break; case clsConstants.ACCOUNT_INACTIVE: //-4: MessageBox.Show("Account is not active", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); //txtPassword.Clear(); txtUserName.Focus(); txtUserName.SelectAll(); break; case clsConstants.ACCOUNT_EXPIRED: //-5: MessageBox.Show("Account expired", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Clear(); txtUserName.Focus(); txtUserName.SelectAll(); break; case clsConstants.PASSWORD_EXPIRED: //-6: MessageBox.Show("Password expired", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); clsSystemConfig.UserName = userName; frmChangePWD frm = new frmChangePWD(); this.Hide(); frm.ShowDialog(); this.Show(); txtPassword.Clear(); txtUserName.Focus(); txtUserName.SelectAll(); break; case clsConstants.LOGIN_SUCCESS: clsSystemConfig.UserName = userName; this.Close(); break; } }