Example #1
0
        public int LoginUser()
        {
            DataTable dt;

            // First get the company information
            CompanySelect companySelect = new CompanySelect();
            companySelect.CompanyName = companyName;
            dt = companySelect.Run();

            if (dt.Rows[0]["id"].ToString() != "")
            {
                loginData.ComID = int.Parse(dt.Rows[0]["id"].ToString());
                loginData.CompanyName = dt.Rows[0]["name"].ToString();
            }
            else
            {
                return LOGIN_COMPANY_NOEXIST;
            }

            // Now try to get the user login info
            UserSelect userSelect = new UserSelect();
            userSelect.UserName = userName;
            userSelect.Password = password;
            dt = userSelect.Run();

            // If we have more than 0 rows
            if (dt.Rows[0]["id"].ToString() != "")
            {
                if (bool.Parse(dt.Rows[0]["allowLogin"].ToString()))
                {
                    if (bool.Parse(dt.Rows[0]["active"].ToString()))
                    {
                        loginData.UserID = int.Parse(dt.Rows[0]["id"].ToString());
                        loginData.UserName = dt.Rows[0]["username"].ToString();
                        loginData.Role = int.Parse(dt.Rows[0]["role"].ToString());
                    }
                    else
                    {
                        return LOGIN_INACTIVE;
                    }
                }
                else
                {
                    return LOGIN_DISALLOWED;
                }
            }
            else
            {
                return LOGIN_INCORRECT;
            }

            return LOGIN_SUCCESS;
        }
Example #2
0
        private void selectUser()
        {
            try
            {
                UserSelect _userSelect = new UserSelect();
                _userSelect.User = this._userObj;
                _userSelect.selectUser();
                this._ds = _userSelect.Ds;

            }
            catch (Exception ex)
            {
                throw new Exception("selectUser():: " + ex.Message);
            }
        }