Exemplo n.º 1
0
        //呼叫service 利用authoID查詢autho資料
        public AuthorizationPresentationModel SearchDataByAuthoID()
        {
            AuthorizationPresentationModel authoPresentModel = new AuthorizationPresentationModel();

            if (this._authoModel.GetAuthoID() == null || this._authoModel.GetAuthoID() == "")
            {
                MessageBox.Show("請輸入權限ID");
            }
            else
            {
                //MessageBox.Show("yes");
                _authoService = new AuthorizationService(this._authoModel);
                _authoModel   = _authoService.searchByAuthoID();

                authoPresentModel.SetAuthoID(_authoModel.GetAuthoID());
                authoPresentModel.SetAuthoName(_authoModel.GetAuthoName());
                authoPresentModel.SetAuthoValue(_authoModel.GetAuthoValue());

                if (_authoModel.GetAuthoName() == null || _authoModel.GetAuthoName() == "")
                {
                    MessageBox.Show("此權限ID不存在!");
                    //MessageBox.Show(_authoModel.GetAuthoID());
                    authoPresentModel.SetAuthoID(null);
                }
            }
            return(authoPresentModel);
        }
Exemplo n.º 2
0
 public void TestAuthoValue()
 {
     _autho.SetAuthoValue("testValue");
     Assert.AreEqual("testValue", _autho.GetAuthoValue());
 }
Exemplo n.º 3
0
        // 判斷帳號密碼是否符合資料庫中的資料
        public int judgeAccountAndPassword(String account, String password)
        {
            if (account == "" && password == "")
            {
                MessageBox.Show("請輸入員工ID與密碼!");
                return(-1);
            }
            else if (account == "")
            {
                MessageBox.Show("請輸入員工ID!");
                return(-1);
            }
            else if (password == "")
            {
                MessageBox.Show("請輸入密碼!");
                return(-1);
            }

            _accountService = new AccountService(account, password);
            _loginModel     = _accountService.searchByAccount();
            if (account == _loginModel.GetAccount() && password == _loginModel.GetPassword())
            {
                EmployeeModel emplModel = new EmployeeModel();
                emplModel.SetEmplID(account);
                EmployeeService emplService = new EmployeeService(emplModel);
                emplModel = emplService.searchByEmplID();

                if (!(emplModel.GetPositionID() == null || emplModel.GetPositionID() == ""))
                {
                    PositionModel positionModel = new PositionModel();
                    positionModel.SetId(emplModel.GetPositionID());
                    PositionService positionService = new PositionService(positionModel);

                    positionModel = positionService.searchByPositionID();

                    if (!(positionModel.GetAuthoId() == null || positionModel.GetAuthoId() == ""))
                    {
                        AuthorizationModel authoModel = new AuthorizationModel();
                        authoModel.SetAuthoID(positionModel.GetAuthoId());
                        AuthorizationService authoService = new AuthorizationService(authoModel);

                        authoModel = authoService.searchByAuthoID();

                        // > 0 管理介面
                        // = 0 員工介面
                        if (!(authoModel.GetAuthoName() == null || authoModel.GetAuthoName() == ""))
                        {
                            return(System.Convert.ToInt32(authoModel.GetAuthoValue()));
                        }
                        else
                        {
                            return(-1);
                        }
                    }
                    else
                    {
                        return(-1);
                    }
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                MessageBox.Show("帳號密碼錯誤!");
                return(-1);
            }
        }