// 取得所有員工資料
 private List<EmployeeModel> GetAllEmplDate() 
 {
     List<EmployeeModel> emplList = new List<EmployeeModel>();
     EmployeeModel emplModel = new EmployeeModel();
     EmployeeService emplService = new EmployeeService(emplModel);
     emplList = emplService.GetAllEmplData();
     return emplList;
 }
        // 判斷員工ID是否存在
        private Boolean JudgeEmplIDIsExist()
        {
            String emplID = this._workAttendanceModel.GetWAEmplID();
            EmployeeModel emplModel = new EmployeeModel();
            emplModel.SetEmplID(emplID);

            EmployeeService emplService = new EmployeeService(emplModel);
            emplModel = emplService.searchByEmplID();

            if (emplModel.GetName() == null || emplModel.GetName() == "")
                return false;

            return true;
        }
Esempio n. 3
0
 public EmployeeService(EmployeeModel employeeModel)
 {
     this._employeeModel = employeeModel;
 }
Esempio n. 4
0
        // 取得所有員工資料
        public List<EmployeeModel> GetAllEmplData()
        {
            List<EmployeeModel> emplList = new List<EmployeeModel>();

            if (this.connectToDB())
            {
                try
                {
                    DataTable dataSet = new DataTable();

                    String searchString = String.Format("SELECT * FROM employee");
                    MySqlCommand searchCommand = new MySqlCommand(searchString, myConnection);
                    searchCommand.ExecuteNonQuery();

                    MySqlDataAdapter adapter = new MySqlDataAdapter(searchCommand);
                    adapter.Fill(dataSet);

                    foreach (DataRow searchDr in dataSet.Rows)
                    {
                        EmployeeModel emplModel = new EmployeeModel();
                        emplModel.SetEmplID(searchDr["emplID"].ToString());
                        emplModel.SetAddress(searchDr["address"].ToString());
                        emplModel.SetBasicSalary(System.Convert.ToSingle(searchDr["basicSalary"]));
                        emplModel.SetBirth(System.Convert.ToDateTime(searchDr["birth"]));
                        emplModel.SetBlood(searchDr["blood"].ToString());
                        emplModel.SetDeptID(searchDr["deptID"].ToString());
                        emplModel.SetEmerPerson(searchDr["emerPerson"].ToString());
                        emplModel.SetEmerPhone(searchDr["emerPhoneNum"].ToString());
                        emplModel.SetEmplID(searchDr["emplID"].ToString());
                        emplModel.SetName(searchDr["emplName"].ToString());
                        emplModel.SetJobStatus(searchDr["jobStat"].ToString());
                        emplModel.SetMarriedStatus(searchDr["marriedStat"].ToString());
                        emplModel.SetMilitaryStatus(searchDr["military"].ToString());
                        emplModel.SetPhone(searchDr["phone"].ToString());
                        emplModel.SetPositoinID(searchDr["positionID"].ToString());
                        emplModel.SetSex(searchDr["sex"].ToString());
                        emplModel.SetSpouse(searchDr["spouse"].ToString());
                        emplModel.SetSsn(searchDr["ssn"].ToString());
                        emplList.Add(emplModel);
                    }
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine("Error " + ex.Number + " : " + ex.Message);
                }
            }

            this.closeConnection();

            return emplList;
        }
        // 呼叫service 利用員工ID查詢員工資料
        public EmployeePresentationModel SearchDataByEmplID()
        {
            EmployeePresentationModel emplPresentationModel = new EmployeePresentationModel();

            if (this._employeeModel.GetEmplID() == null || this._employeeModel.GetEmplID() == "")
                MessageBox.Show("請輸入員工ID");
            else
            {
                _employeeService = new EmployeeService(this._employeeModel);
                _employeeModel = _employeeService.searchByEmplID();

                emplPresentationModel.SetEmplID(_employeeModel.GetEmplID());
                emplPresentationModel.SetName(_employeeModel.GetName());
                emplPresentationModel.SetSsn(_employeeModel.GetSsn());
                emplPresentationModel.SetSex(_employeeModel.GetSex());
                emplPresentationModel.SetPhone(_employeeModel.GetPhone());
                emplPresentationModel.SetAddress(_employeeModel.GetAddress());
                emplPresentationModel.SetBlood(_employeeModel.GetBlood());
                emplPresentationModel.SetBirth(_employeeModel.GetBirth());
                emplPresentationModel.SetEmerPerson(_employeeModel.GetEmerPerson());
                emplPresentationModel.SetEmerPhone(_employeeModel.GetEmerPhone());
                emplPresentationModel.SetMilitaryStatus(_employeeModel.GetMilitaryStatus());
                emplPresentationModel.SetJobStatus(_employeeModel.GetJobStatus());
                emplPresentationModel.SetMarriedStatus(_employeeModel.GetMarriedStatus());
                emplPresentationModel.SetSpouse(_employeeModel.GetSpouse());
                emplPresentationModel.SetDeptID(_employeeModel.GetDeptID());
                emplPresentationModel.SetPositoinID(_employeeModel.GetPositionID());
                emplPresentationModel.SetBasicSalary(_employeeModel.GetBasicSalary());

                if (_employeeModel.GetName() == null || _employeeModel.GetName() == "")
                {
                    MessageBox.Show("此員工ID不存在!");
                    emplPresentationModel.SetEmplID(null);
                }
            }        

            return emplPresentationModel;
        }
 public void Initialize()
 {
     _employee = new EmployeeModel();
     _target = new PrivateObject(_employee);
 }