public static DTO_Usuario ValidarLogin(DTO_Login obj) { if (string.IsNullOrWhiteSpace(obj.Usuario)) { throw new Exception("Campo usuário vazio!"); } if (string.IsNullOrWhiteSpace(obj.Senha)) { throw new Exception("Campo senha vazio!"); } return(DAL_Login.ValidarLogin(obj)); }
public static DTO_Entidade ValidarLogin(DTO_Login ObjLog) { if (string.IsNullOrWhiteSpace(ObjLog.nome)) { throw new Exception("Campo nome vazio"); } if (string.IsNullOrWhiteSpace(ObjLog.senha)) { throw new Exception("Campo senha vazio"); } Conexao.Conectar(); return(DAL_Login.ValidarLogin(ObjLog)); }
public bool CheckUserCredentials(string userName, string password, string userType) { DAL_Login login = new DAL_Login(); try { bool LoginResponse = login.CheckUserCredentials(userName, password, userType); if (LoginResponse) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
public ActionResult Login(string Username, string Password) { GlobalSettings gs = new GlobalSettings(); DAL_Login DalLogin = new DAL_Login(); try { ModelState.Clear(); DataTable dt = DalLogin.GetEmployees(new SqlParameter("@UserName", Username), new SqlParameter("@Password", Password), new SqlParameter("@ProgramName", gs.Appname1), new SqlParameter("@IP", gs.GetLocalIPAddress())); if (dt.Rows.Count > 0) { HttpCookie cookie = new HttpCookie("User"); cookie.Values.Add("UserID", dt.Rows[0][0].ToString()); cookie.Values.Add("Username", Username); cookie.Values.Add("EmpName", dt.Rows[0][2].ToString()); cookie.Values.Add("UserType", dt.Rows[0][1].ToString()); cookie.HttpOnly = true; Response.Cookies.Add(cookie); FormsAuthentication.SetAuthCookie(dt.Rows[0][0].ToString(), false); string a = Request.Cookies["User"].Values[0]; return(Json(new { success = true, message = "Login Successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet })); } else { throw new ApplicationException("Invalid Username or Password"); } } catch (Exception ex) { return(new HttpStatusCodeResult(410, ex.Message)); } }
public WMS_Login() { InitializeComponent(); _dal_Login = new DAL_Login(); _dal_Warehouse = new DAL_Warehouse(); }