private void DelWCal()
 {
     _dtCtrl.DeleteEmployee(emp.PayrollNumber);
     _dtCtrl.DeleteWorkingCalendar(wCal.ID);
     _dtCtrl.DeleteDepartment(dep.ID);
     _dtCtrl.DeleteCompany(com.ID);
 }
        private void DeleteWorkingCalendar(int workingCalendarID)
        {
            try
            {
                if (workingCalendarID < 0)
                {
                    MessageBox.Show("Please select a working calendar to delete.");
                    return;
                }

                if (Util.Confirm("Are you sure you want to delete this working calendar? This cannot be undone.") == false)
                {
                    return;
                }

                //check if worknig calendar is in use
                if (_dtCtrl.IsWorkingCalendarInUse(workingCalendarID))
                {
                    MessageBox.Show("Please select a working calendar to delete.");
                    return;
                }

                if (_dtCtrl.DeleteWorkingCalendar(workingCalendarID))
                {
                    MessageBox.Show("Working Calendar deleted.");
                }
                else
                {
                    MessageBox.Show("Working Calendar not found or has been deleted.");
                }

                BindWorkingCalendar();
            }
            catch (Exception ex)
            {
                Util.ShowErrorMessage(ex);
            }
        }
Example #3
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 });
            }
        }