예제 #1
0
        public ActionResult Login(string UserName = "", string Password = "", bool Remember = false, string returnUrl = "")
        {
            VD_USERS _user = new VD_USERS();

            _user = _model.Login(UserName, Password);

            if (_user != null && !string.IsNullOrEmpty(_user.UserName))
            {
                Session["Roles"] = _user.UserTypeID;
                FormsAuthentication.SetAuthCookie(_user.UserTypeID, Remember);

                if (_user.UserTypeID == "0")
                {
                    //admin
                    returnUrl = "/Admin/Index";
                }
            }

            if (string.IsNullOrEmpty(returnUrl))
            {
                returnUrl = "/Login/Index";
            }

            return(RedirectToLocal(returnUrl));
        }
예제 #2
0
        public VD_USERS Login(string UserName, string Password)
        {
            VD_USERS info = new VD_USERS();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.Login("WEB_VD_LOGIN", UserName, Password);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    info.ID           = Convert.ToInt64(ds.Tables[0].Rows[0]["ID"]);
                    info.UserName     = Convert.ToString(ds.Tables[0].Rows[0]["UserName"]);
                    info.Password     = Convert.ToString(ds.Tables[0].Rows[0]["Password"]);
                    info.UserTypeID   = Convert.ToString(ds.Tables[0].Rows[0]["UserTypeID"]);
                    info.UserTypeName = Convert.ToString(ds.Tables[0].Rows[0]["UserTypeName"]);
                }
            }

            return(info);
        }