Exemple #1
0
        public UserModel CheckUser(string userName, string password, out int status)
        {
            UserModel User = new UserModel();

            DALogin   da         = new DALogin();
            DataTable tableusers = da.CheckUser(userName);

            if (tableusers.Rows.Count == 0)
            {
                status = 1; // Username Wrong
            }
            else
            {
                if (Base64Encode(password) == tableusers.Rows[0]["UserPassword"].ToString())
                {
                    status            = 2;
                    User.UserId       = Convert.ToInt32(tableusers.Rows[0]["UserId"]);
                    User.UserName     = tableusers.Rows[0]["UserName"].ToString();
                    User.UserPassword = tableusers.Rows[0]["UserPassword"].ToString();
                    User.LastLogin    = DateTime.Now;
                    da.UpdateDateTime(User.LastLogin, User.UserId);
                }
                else
                {
                    status = 0; // Password Wrong
                }
            }

            return(User);
        }