private void BtnLogin_Click(object sender, EventArgs e) { AuthBAL Auth = new AuthBAL(); AuthDAL Ad = new AuthDAL(); if (TxtUseName.Text.Trim() != "" && TxtPasWord.Text.Trim() != "") { Auth.Username = TxtUseName.Text.Trim(); Auth.Password = TxtPasWord.Text.Trim(); bool result = Ad.Auth(Auth); if (result == true) { TUnlock.Enabled = true; } else { MessageBox.Show("Invalid Username and Password"); } } else if (TxtUseName.Text.Trim() == "") { MessageBox.Show("Username Cannot be Empty"); TxtUsername.Focus(); } else if (TxtPasWord.Text.Trim() == "") { MessageBox.Show("Password Cannot be Empty"); TxtPassword.Focus(); } else { MessageBox.Show("Username and Password cannot be empty"); } }
public ResponseStatus IsAllow(string controller, string action, HttpCookieCollection cookies) { authDal = new AuthDAL(); ResponseStatus status = authDal.IsAllowNoneUserOrAllUser(controller, action); authDal.ReturnUnitToPool(); if (status == ResponseStatus.ALLOW_ALL_USER) { if (!CheckCookies(cookies)) { return(ResponseStatus.NOT_LOGIN); } else { return(status); } } else if (status == ResponseStatus.ALLOW_SPECIFY_USER) { if (!CheckCookies(cookies)) { return(ResponseStatus.NOT_LOGIN); } else { string userId = cookies[GLB.userId].Value.ToString(); if (authDal.AllowSpecify(controller, action, userId)) { return(ResponseStatus.ALLOW_SPECIFY_USER_PASS); } else { return(ResponseStatus.NOALLOW); } } } else { return(status); } }