private void DelWCal()
 {
     _dtCtrl.DeleteEmployee(emp.PayrollNumber);
     _dtCtrl.DeleteWorkingCalendar(wCal.ID);
     _dtCtrl.DeleteDepartment(dep.ID);
     _dtCtrl.DeleteCompany(com.ID);
 }
Пример #2
0
        public void TestDeleteCompany()
        {
            Assert.AreEqual(true, _dtCtrl.DeleteCompany(com1.ID));
            Assert.AreEqual(true, _dtCtrl.DeleteCompany(com2.ID));

            Assert.AreEqual(null, _dtCtrl.GetCompany(com1.ID));

            //delete again
            Assert.AreEqual(false, _dtCtrl.DeleteCompany(com1.ID));
            Assert.AreEqual(false, _dtCtrl.DeleteCompany(-1));

            //delete non-empty company
            com1.ID = _dtCtrl.AddCompany(com1);

            Department dep1 = new Department();

            dep1.CompanyID       = com1.ID;
            dep1.Name            = "Dep1";
            dep1.SupDepartmentID = 0; //root

            dep1.ID = _dtCtrl.AddDepartment(dep1);

            Assert.AreEqual(false, _dtCtrl.DeleteCompany(com1.ID));

            _dtCtrl.DeleteDepartment(dep1.ID);

            Assert.AreEqual(true, _dtCtrl.DeleteCompany(com1.ID));
        }
Пример #3
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Util.Confirm("Are you sure you want to delete this department? This cannot be undone.") == false)
            {
                return;
            }

            int        departmentID = (int)tvDepartment.SelectedNode.Tag;
            Department department   = _dtCtrl.GetDepartment(departmentID);

            if (department == null)
            {
                MessageBox.Show("Department not found.");
                BindTree();
                return;
            }

            //check if department is default
            if (departmentID == 1)
            {
                MessageBox.Show("Default department must not be deleted");
                return;
            }

            //check if department is empty
            if (_dtCtrl.GetEmployeeList(department.CompanyID, department.ID).Count > 0)
            {
                MessageBox.Show("Department is in use and can not be deleted.");
                return;
            }

            if (_dtCtrl.DeleteDepartment(departmentID) == false)
            {
                MessageBox.Show("Department not found or has already been deleted.");
                return;
            }
            else
            {
                MessageBox.Show("Department deleted.");
                BindTree();
                BindDepartment();
            }
        }
        public void TestDeleteDeparment()
        {
            //non empty dep
            Assert.AreEqual(false, _dtCtrl.DeleteDepartment(dep1.ID));

            Assert.AreEqual(true, _dtCtrl.DeleteDepartment(dep2.ID));
            Assert.AreEqual(null, _dtCtrl.GetDepartment(dep2.ID));

            Assert.AreEqual(true, _dtCtrl.DeleteDepartment(dep1.ID));
            Assert.AreEqual(true, _dtCtrl.DeleteDepartment(dep3.ID));

            //again
            Assert.AreEqual(false, _dtCtrl.DeleteDepartment(dep1.ID));
            Assert.AreEqual(false, _dtCtrl.DeleteDepartment(-1));

            _dtCtrl.DeleteCompany(com1.ID);
            _dtCtrl.DeleteCompany(com2.ID);
        }
Пример #5
0
 private void DeleteDeparment()
 {
     _dtCtrl.DeleteDepartment(dep1.ID);
     _dtCtrl.DeleteCompany(com1.ID);
 }
Пример #6
0
        private void ClearDB()
        {
            _dtCtrl.BeginTransaction();
            try
            {
                Invoke(new SetTextCallBack(SetText), new object[] { txtProgress, "Clearing..." });

                //clear undel employee
                foreach (UndeletedEmployeeNumber undelEmp in _dtCtrl.GetUndeletedEmployeeNumberList())
                {
                    _dtCtrl.DeleteUndeletedEmployeeNumber(undelEmp);
                }

                //clear uncal att records
                _dtCtrl.DeleteAllUncalculatedAttendanceRecord();

                //clear att reports
                _dtCtrl.DeleteAllAttendanceReport();

                //clear att records
                _dtCtrl.DeleteAllAttendanceRecord();

                //clear employee
                foreach (Employee emp in _dtCtrl.GetEmployeeList())
                {
                    //clear employee terminal
                    _dtCtrl.DeleteEmployeeTerminalByEmployee(emp.EmployeeNumber);

                    _dtCtrl.DeleteEmployee(emp.PayrollNumber);
                }

                //clear employee number

                //clear department
                foreach (Department dep in _dtCtrl.GetDepartmentList())
                {
                    if (dep.ID != 1)
                    {
                        _dtCtrl.DeleteDepartment(dep.ID);
                    }
                }

                //clear company
                foreach (Company com in _dtCtrl.GetCompanyList())
                {
                    if (com.ID != 1)
                    {
                        _dtCtrl.DeleteCompany(com.ID);
                    }
                }

                //clear working calendar
                foreach (WorkingCalendar wCal in _dtCtrl.GetWorkingCalendarList())
                {
                    List <Shift> shiftList = _dtCtrl.GetShiftListByWorkingCalendar(wCal.ID);

                    foreach (Shift shift in shiftList)
                    {
                        _dtCtrl.DeleteShift(shift.ID);
                    }

                    _dtCtrl.DeleteWorkingCalendar(wCal.ID);
                }

                //clear pay period

                _dtCtrl.CommitTransaction();

                Invoke(new SetTextCallBack(SetText), new object[] { txtProgress, "Clearing Complete." });
            }
            catch (Exception ex)
            {
                _dtCtrl.RollbackTransaction();
                Invoke(new AddTextCallBack(SetText), new object[] { txtProgress, "Error: " + ex.Message });
            }
        }
Пример #7
0
        public void AddUpdateDeleteDepartmentTest()
        {
            IDataController dtCtrl = LocalDataController.Instance;

            //Add a new department
            Department dept1 = new Department();

            dept1.Name            = "Dept1";
            dept1.CompanyID       = 4;
            dept1.SupDepartmentID = 0;

            dept1.ID = dtCtrl.AddDepartment(dept1);
            Assert.Greater(dept1.ID, 0);

            //Add a new sub-department
            Department dept2 = new Department();

            dept2.Name            = "Dept2";
            dept2.CompanyID       = 4;
            dept2.SupDepartmentID = dept1.ID;

            dept2.ID = dtCtrl.AddDepartment(dept2);
            Assert.Greater(dept2.ID, 0);

            //Add a empty named department
            Department dept3 = new Department();

            dept3.Name            = "";
            dept3.CompanyID       = 4;
            dept3.SupDepartmentID = 0;

            Assert.Less(dtCtrl.AddDepartment(dept3), 0);

            //Add a duplicated department
            Department dept4 = new Department();

            dept4.Name            = "Dept1";
            dept4.CompanyID       = 4;
            dept4.SupDepartmentID = 0;

            Assert.Less(dtCtrl.AddDepartment(dept4), 0);

            //Add a non-company department
            Department dept5 = new Department();

            dept5.Name            = "Dept5";
            dept5.SupDepartmentID = 0;

            Assert.Less(dtCtrl.AddDepartment(dept5), 0);

            //Update an existing department
            Assert.AreEqual(true, dtCtrl.UpdateDepartment(dept1));

            //Update an exist department using an exist Name
            dept1.Name = "Dept2";
            Assert.AreEqual(false, dtCtrl.UpdateDepartment(dept1));

            //Update an exist department using an empty Name
            dept1.Name = "";
            Assert.AreEqual(false, dtCtrl.UpdateDepartment(dept1));

            //Delete exist departments
            Assert.AreEqual(true, dtCtrl.DeleteDepartment(dept2.ID));
            Assert.AreEqual(true, dtCtrl.DeleteDepartment(dept1.ID));
        }