예제 #1
0
        // 輸入部門ID搜尋部門資料
        public DepartmentModel searchByDeptID()
        {
            if (this.connectToDB())
            {
                try
                {
                    DataTable dataset = new DataTable();

                    String       searchString  = String.Format("SELECT * FROM department WHERE departmentID = '" + this._deptModel.GetDepartmentID() + "'");
                    MySqlCommand searchCommand = new MySqlCommand(searchString, myConnection);
                    searchCommand.ExecuteNonQuery();

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

                    foreach (DataRow searchDr in dataset.Rows)
                    {
                        _deptModel.SetDepartmentName(searchDr["departmentName"].ToString());
                        _deptModel.SetDepartmentStartTime(System.Convert.ToDateTime(searchDr["departmentStartTime"]));
                        _deptModel.SetDepartmentEndTime(System.Convert.ToDateTime(searchDr["departmentEndTime"]));
                        _deptModel.SetDepartmentManager(searchDr["departmentManager"].ToString());
                    }
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine("Error " + ex.Number + " : " + ex.Message);
                }
            }
            this.closeConnection();
            return(this._deptModel);
        }
예제 #2
0
 //建構子
 public DepartmentController(DepartmentPresentationModel deptPresentationModel)
 {
     _deptModel.SetDepartmentID(deptPresentationModel.getDepartmentID());
     _deptModel.SetDepartmentName(deptPresentationModel.getDepartmentName());
     _deptModel.SetDepartmentStartTime(deptPresentationModel.getDepartmentStartTime());
     _deptModel.SetDepartmentEndTime(deptPresentationModel.getDepartmentEndTime());
     _deptModel.SetDepartmentManager(deptPresentationModel.getDepartmentManager());
 }
예제 #3
0
 public void TestDepartmentName()
 {
     _department.SetDepartmentName("testdepName");
     Assert.AreEqual("testdepName", _department.GetDepartmentName());
 }