コード例 #1
0
        public eLoginResult Login(string UserName, string Password)
        {
            Interface_DataAccess Da = new ClsBase().pDa;

            try
            {
                Da.Connect();

                //Administrator Login
                if (UserName.ToUpper() == "Administrator".ToUpper())
                {
                    string System_Password = Da.GetSystemParameter("Administrator_Password", "Administrator");
                    if (System_Password != "")
                    {
                        string Decrypted_Password = System_Password;
                        if (Decrypted_Password == Password)
                        {
                            this.AdministratorLogin();
                            return(eLoginResult.Administrator);
                        }
                        else
                        {
                            return(eLoginResult.WrongPassword);
                        }
                    }
                    else
                    {
                        throw new CustomException("Administrator Password is not set. Contact your System Administrator.");
                    }
                }

                //User Login
                QueryCondition Qc = new QueryCondition();
                Qc.Add("UserName", UserName, typeof(string).ToString());
                DataTable Dt = Da.GetQuery("uvw_User", "", Qc, "UserID");
                if (Dt.Rows.Count > 0)
                {
                    string Decrypted_Password = (string)Do_Methods.IsNull(Dt.Rows[0]["Password"], "");

                    if (Decrypted_Password == Password)
                    {
                        this.mDrUser = Dt.Rows[0];
                        return(eLoginResult.LoggedIn);
                    }
                    else
                    {
                        return(eLoginResult.WrongPassword);
                    }
                }

                return(eLoginResult.WrongUser);
            }
            catch (Exception ex)
            { throw ex; }
            finally
            { Da.Close(); }
        }
コード例 #2
0
        public void AdministratorLogin()
        {
            Interface_DataAccess Da = new ClsBase().pDa;

            try
            {
                Da.Connect();
                DataTable Dt = Da.GetQuery("uvw_User", "*", "1 = 0");
                this.mDrUser                 = Dt.NewRow();
                this.mDrUser["UserID"]       = 0;
                this.mDrUser["EmployeeID"]   = 0;
                this.mDrUser["UserName"]     = "******";
                this.mDrUser["EmployeeName"] = "Administrator";
                this.mIsAdmin                = true;
            }
            catch (Exception ex)
            { throw ex; }
            finally
            { Da.Close(); }
        }