private void DelWCal() { _dtCtrl.DeleteEmployee(emp.PayrollNumber); _dtCtrl.DeleteWorkingCalendar(wCal.ID); _dtCtrl.DeleteDepartment(dep.ID); _dtCtrl.DeleteCompany(com.ID); }
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); }
public void AddCompanyTest() { IDataController dtCtrl = LocalDataController.Instance; string companyName = "ABC"; Company company = new Company(); company.Name = companyName; company.ID = dtCtrl.AddCompany(company); Assert.Greater(company.ID, 0); dtCtrl.DeleteCompany(company.ID); }
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)); }
public void DeleteCompanyTest() { IDataController dtCtrl = LocalDataController.Instance; string companyName = "ABCs"; Company company1 = new Company(); company1.Name = companyName; company1.ID = dtCtrl.AddCompany(company1); Assert.AreEqual(true, dtCtrl.DeleteCompany(company1.ID)); }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { int companyID = GetSelectedCompanyID(); if (companyID < 0) { MessageBox.Show("Please select a company to delete."); return; } //confim deleting company if (Util.Confirm("Are you sure you want to delete this company. This cannot be undone.") == false) { return; } //check is company is default company if (companyID == 1) { MessageBox.Show("Default company must not be deleted."); return; } //check if company is empty if (_dtCtrl.GetDepartmentByCompany(companyID).Count > 0) { MessageBox.Show("Company is in use and can not be deleted."); return; } if (_dtCtrl.DeleteCompany(companyID) == false) { MessageBox.Show("Company not found or has already been deleted."); } else { MessageBox.Show("Company deleted."); } LoadData(); }
private void DeleteDeparment() { _dtCtrl.DeleteDepartment(dep1.ID); _dtCtrl.DeleteCompany(com1.ID); }
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 }); } }
private void DeleteCompany() { _dtCtrl.DeleteCompany(com1.ID); }