Пример #1
0
        // 呼叫service利用departmentID查詢dept資料
        public DepartmentPresentationModel SearchDepartmentByID()
        {
            DepartmentPresentationModel deptPresentModel = new DepartmentPresentationModel();

            if (this._deptModel.GetDepartmentID() == null || _deptModel.GetDepartmentID() == "")
                MessageBox.Show("請輸入部門ID");
            else
            {
                _deptService = new DepartmentService(this._deptModel);
                _deptModel = _deptService.searchByDeptID();

                deptPresentModel.setDepartmentID(_deptModel.GetDepartmentID());
                deptPresentModel.setDepartmentName(_deptModel.GetDepartmentName());
                deptPresentModel.setDepartmentStartTime(_deptModel.GetDepartmentStartTime());
                deptPresentModel.setDepartmentEndTime(_deptModel.GetDepartmentEndTime());
                deptPresentModel.setDepartmentManager(_deptModel.GetDepartmentManager());

                if(_deptModel.GetDepartmentName() == null || _deptModel.GetDepartmentName() == "")
                {
                    MessageBox.Show("此部門ID不存在!");
                    deptPresentModel.setDepartmentID(null);
                }
            }
            return deptPresentModel;
        }
Пример #2
0
        // 呼叫service將資料新增至資料庫
        public void AddDepartment()
        {
            this._deptService = new DepartmentService(_deptModel);
            int error_flag = 0;

            if(this._deptModel.GetDepartmentID() == "" || this._deptModel.GetDepartmentName() == "" || this._deptModel.GetDepartmentManager() == "")
            {
                MessageBox.Show("尚有欄位為空白, 請重新確認是否填寫完畢!");
                error_flag = 1;
            }

            if (error_flag == 1)
                return;

            if (_deptService.AddDepartment())
                MessageBox.Show("新增成功!");
            else
                MessageBox.Show("新增失敗!");
        }
Пример #3
0
        // 呼叫service, 將資料新增至資料庫(edit)
        public Boolean editDepartment()
        {
            this._deptService = new DepartmentService(this._deptModel);
            if(this._deptModel.GetDepartmentName() == "")
            {
                MessageBox.Show("請輸入部門名稱");
                return false;
            }
            else if(this._deptModel.GetDepartmentManager() == "")
            {
                MessageBox.Show("請輸入部門主管名稱");
                return false;
            }

            if(_deptService.EditDepartment())
                MessageBox.Show("修改成功");
            else
            {
                MessageBox.Show("修改失敗");
                return false;
            }
            return true;
        }