Esempio n. 1
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));
        }
Esempio n. 2
0
        private void AddDepartment()
        {
            com1.Name = DateTime.Now.Ticks.ToString();
            com1.ID   = _dtCtrl.AddCompany(com1);

            dep1.CompanyID       = com1.ID;
            dep1.Name            = DateTime.Today.Ticks.ToString();
            dep1.SupDepartmentID = 0; //root
            dep1.ID = _dtCtrl.AddDepartment(dep1);
        }
Esempio n. 3
0
        private void btSubmit_Click(object sender, EventArgs e)
        {
            Department department = GetDepartmentUserInput();

            if (department == null)
            {
                return;
            }

            bool acctionSucess = false;

            if ((int)btnSubmit.Tag <= 0) //add
            {
                int id = _dtCtrl.AddDepartment(department);
                acctionSucess = id > 0;

                if (acctionSucess)
                {
                    MessageBox.Show("Department added.");
                }
                else
                {
                    MessageBox.Show("There has been an error. Please try again.");
                }
            }
            else //update
            {
                int departmentID = (int)btnSubmit.Tag;
                department.ID = departmentID;
                acctionSucess = _dtCtrl.UpdateDepartment(department);

                if (acctionSucess)
                {
                    MessageBox.Show("Department updated.");
                }
                else
                {
                    MessageBox.Show("There has been an error. Please try again.");
                }
            }

            if (acctionSucess)
            {
                LoadForm(0, (int)cbxCompany.SelectedValue, 0, "");
                BindTree();
                BindDepartment();
            }
        }
Esempio n. 4
0
        private void AddTestOneShiftNonFlexi(ref IDataController _dtCtrl)
        {
            #region add test company
            Company com = new Company();
            com.Name = DateTime.Now.Ticks.ToString();
            com.ID = _dtCtrl.AddCompany(com);
            #endregion

            #region add test department
            Department dep = new Department();
            dep.CompanyID = com.ID;
            dep.Name = DateTime.Now.Ticks.ToString();
            dep.SupDepartmentID = 0; //root
            dep.ID = _dtCtrl.AddDepartment(dep);
            #endregion

            #region add test working calendar
            WorkingCalendar wCal = new WorkingCalendar();

            wCal.Name = DateTime.Now.Ticks.ToString();

            wCal.WorkOnMonday = true;
            wCal.WorkOnTuesday = true;
            wCal.WorkOnWednesday = true;
            wCal.WorkOnThursday = true;
            wCal.WorkOnFriday = true;

            wCal.GraceForwardToEntry = 30;
            wCal.GraceBackwardToExit = 30;
            wCal.EarliestBeforeEntry = 60;
            wCal.LastestAfterExit = 180;

            List<Shift> shiftList = new List<Shift>();
            Shift shift1 = new Shift();
            shift1.From = new DateTime(2000, 2, 2, 9, 0, 0);
            shift1.To = new DateTime(2000, 2, 2, 18, 0, 0);
            shiftList.Add(shift1);

            List<Break> breakList = new List<Break>();
            Break break1 = new Break();
            break1.From = new DateTime(2000, 2, 2, 12, 0, 0);
            break1.To = new DateTime(2000, 2, 2, 13, 0, 0);
            break1.Name = "break1";
            break1.Paid = true;

            breakList.Add(break1);

            List<Holiday> holidayList = new List<Holiday>();

            PaymentRate workingDayPaymentRate = new PaymentRate();
            workingDayPaymentRate.NumberOfRegularHours = 7;
            workingDayPaymentRate.RegularRate = 100;
            workingDayPaymentRate.NumberOfOvertime1 = 8;
            workingDayPaymentRate.OvertimeRate1 = 200;

            PaymentRate nonWorkingDayPaymentRate = workingDayPaymentRate;
            PaymentRate holidayPaymentRate = workingDayPaymentRate;

            PayPeriod payPeriod = new PayPeriod();
            payPeriod.CustomPeriod = 5;
            payPeriod.PayPeriodTypeID = 5; //custom
            payPeriod.StartFrom = new DateTime(2010, 1, 1);

            wCal.ID = _dtCtrl.AddWorkingCalendar(wCal, shiftList, breakList, holidayList, workingDayPaymentRate, nonWorkingDayPaymentRate, holidayPaymentRate, payPeriod);
            #endregion

            #region add test employee
            Employee emp = new Employee();
            emp.Active = true;
            emp.ActiveFrom = DateTime.Today;
            emp.ActiveTo = DateTime.Today.AddDays(1);
            emp.Address = DateTime.Now.Ticks.ToString();
            emp.Birthday = DateTime.Today.AddYears(-20);
            emp.DepartmentID = dep.ID;
            emp.EmployeeNumber = 0;
            emp.FirstName = DateTime.Now.Ticks.ToString();
            emp.JobDescription = DateTime.Now.Ticks.ToString();
            emp.HiredDate = DateTime.Today;
            emp.LeftDate = DateTime.Today.AddYears(1);
            emp.LastName = DateTime.Now.Ticks.ToString();
            emp.PhoneNumber = DateTime.Now.Ticks.ToString();
            emp.WorkingCalendarID = wCal.ID;
            emp.PayrollNumber = _dtCtrl.AddEmployee(emp, new List<Terminal>());
            #endregion

            #region add test att records 1
            //att1 : expected totalHours: 9
            AttendanceRecord att11 = new AttendanceRecord();
            att11.EmployeeNumber = emp.EmployeeNumber;
            att11.Time = new DateTime(2010, 1, 1, 9, 0, 0);
            att11.ID = _dtCtrl.AddAttendanceRecord(att11);

            AttendanceRecord att12 = new AttendanceRecord();
            att12.EmployeeNumber = emp.EmployeeNumber;
            att12.Time = new DateTime(2010, 1, 1, 18, 0, 0);
            att12.ID = _dtCtrl.AddAttendanceRecord(att12);

            AttendanceRecord att13 = new AttendanceRecord();
            att13.EmployeeNumber = emp.EmployeeNumber;
            att13.Time = new DateTime(2010, 1, 1, 12, 0, 0);
            att13.ID = _dtCtrl.AddAttendanceRecord(att13);

            AttendanceRecord att14 = new AttendanceRecord();
            att14.EmployeeNumber = emp.EmployeeNumber;
            att14.Time = new DateTime(2010, 1, 1, 13, 0, 0);
            att14.ID = _dtCtrl.AddAttendanceRecord(att14);

            //att2 : expected totalHours: 9
            AttendanceRecord att21 = new AttendanceRecord();
            att21.EmployeeNumber = emp.EmployeeNumber;
            att21.Time = new DateTime(2010, 1, 2, 8, 45, 0);
            att21.ID = _dtCtrl.AddAttendanceRecord(att21);

            AttendanceRecord att22 = new AttendanceRecord();
            att22.EmployeeNumber = emp.EmployeeNumber;
            att22.Time = new DateTime(2010, 1, 2, 18, 15, 0);
            att22.ID = _dtCtrl.AddAttendanceRecord(att22);

            //att3 : expected totalHours: 9.75
            AttendanceRecord att31 = new AttendanceRecord();
            att31.EmployeeNumber = emp.EmployeeNumber;
            att31.Time = new DateTime(2010, 1, 3, 8, 15, 0);
            att31.ID = _dtCtrl.AddAttendanceRecord(att31);

            AttendanceRecord att32 = new AttendanceRecord();
            att32.EmployeeNumber = emp.EmployeeNumber;
            att32.Time = new DateTime(2010, 1, 3, 18, 0, 0);
            att32.ID = _dtCtrl.AddAttendanceRecord(att32);

            //att4 : expected totalHours: 0 + out mistake alert
            AttendanceRecord att41 = new AttendanceRecord();
            att41.EmployeeNumber = emp.EmployeeNumber;
            att41.Time = new DateTime(2010, 1, 4, 7, 00, 0);
            att41.ID = _dtCtrl.AddAttendanceRecord(att41);

            AttendanceRecord att42 = new AttendanceRecord();
            att42.EmployeeNumber = emp.EmployeeNumber;
            att42.Time = new DateTime(2010, 1, 4, 18, 0, 0);
            att42.ID = _dtCtrl.AddAttendanceRecord(att42);

            //att5 : expected totalHours: 8.8x
            AttendanceRecord att51 = new AttendanceRecord();
            att51.EmployeeNumber = emp.EmployeeNumber;
            att51.Time = new DateTime(2010, 1, 5, 9, 06, 0);
            att51.ID = _dtCtrl.AddAttendanceRecord(att51);

            AttendanceRecord att52 = new AttendanceRecord();
            att52.EmployeeNumber = emp.EmployeeNumber;
            att52.Time = new DateTime(2010, 1, 5, 18, 2, 0);
            att52.ID = _dtCtrl.AddAttendanceRecord(att52);

            //att6 : expected totalHours: 8.5
            AttendanceRecord att61 = new AttendanceRecord();
            att61.EmployeeNumber = emp.EmployeeNumber;
            att61.Time = new DateTime(2010, 1, 6, 9, 0, 0);
            att61.ID = _dtCtrl.AddAttendanceRecord(att61);

            AttendanceRecord att62 = new AttendanceRecord();
            att62.EmployeeNumber = emp.EmployeeNumber;
            att62.Time = new DateTime(2010, 1, 6, 18, 0, 0);
            att62.ID = _dtCtrl.AddAttendanceRecord(att62);

            AttendanceRecord att63 = new AttendanceRecord();
            att63.EmployeeNumber = emp.EmployeeNumber;
            att63.Time = new DateTime(2010, 1, 6, 12, 30, 0);
            att63.ID = _dtCtrl.AddAttendanceRecord(att63);

            AttendanceRecord att64 = new AttendanceRecord();
            att64.EmployeeNumber = emp.EmployeeNumber;
            att64.Time = new DateTime(2010, 1, 6, 13, 30, 0);
            att64.ID = _dtCtrl.AddAttendanceRecord(att64);
            #endregion
        }
Esempio n. 5
0
        private void AddTestOneShiftFlexi(ref IDataController _dtCtrl)
        {
            #region add test company
            Company com = new Company();
            com.Name = DateTime.Now.Ticks.ToString();
            com.ID = _dtCtrl.AddCompany(com);
            #endregion

            #region add test department
            Department dep = new Department();
            dep.CompanyID = com.ID;
            dep.Name = DateTime.Now.Ticks.ToString();
            dep.SupDepartmentID = 0; //root
            dep.ID = _dtCtrl.AddDepartment(dep);
            #endregion

            #region add test working calendar
            List<Break> breakList = new List<Break>();
            Break break1 = new Break();
            break1.From = new DateTime(2000, 2, 2, 12, 0, 0);
            break1.To = new DateTime(2000, 2, 2, 13, 0, 0);
            break1.Name = "break1";
            break1.Paid = true;

            breakList.Add(break1);

            List<Holiday> holidayList = new List<Holiday>();

            PaymentRate workingDayPaymentRate = new PaymentRate();
            workingDayPaymentRate.NumberOfRegularHours = 7;
            workingDayPaymentRate.RegularRate = 100;
            workingDayPaymentRate.NumberOfOvertime1 = 8;
            workingDayPaymentRate.OvertimeRate1 = 200;

            PaymentRate nonWorkingDayPaymentRate = workingDayPaymentRate;
            PaymentRate holidayPaymentRate = workingDayPaymentRate;

            PayPeriod payPeriod = new PayPeriod();
            payPeriod.CustomPeriod = 5;
            payPeriod.PayPeriodTypeID = 5; //custom
            payPeriod.StartFrom = new DateTime(2010, 1, 1);

            WorkingCalendar wCal = new WorkingCalendar();
            wCal.Name = DateTime.Now.Ticks.ToString();
            wCal.ApplyFlexiHours = true;
            wCal.FlexiHours = 40;
            wCal.WeekStartsOn = 3; //Thursday

            List<Shift> shiftList = new List<Shift>();
            Shift shift1 = new Shift();
            shift1.From = new DateTime(2000, 2, 2, 9, 0, 0);
            shift1.To = new DateTime(2000, 2, 2, 18, 0, 0);
            shiftList.Add(shift1);

            wCal.WorkOnMonday = true;
            wCal.WorkOnTuesday = true;
            wCal.WorkOnWednesday = true;
            wCal.WorkOnThursday = true;
            wCal.WorkOnFriday = true;

            wCal.GraceForwardToEntry = 30;
            wCal.GraceBackwardToExit = 30;
            wCal.EarliestBeforeEntry = 60;
            wCal.LastestAfterExit = 180;

            wCal.ID = _dtCtrl.AddWorkingCalendar(wCal, shiftList, new List<Break>(), holidayList, workingDayPaymentRate, nonWorkingDayPaymentRate, holidayPaymentRate, payPeriod);
            #endregion

            #region add test employee
            Employee emp = new Employee();
            emp.Active = true;
            emp.ActiveFrom = DateTime.Today;
            emp.ActiveTo = DateTime.Today.AddDays(1);
            emp.Address = DateTime.Now.Ticks.ToString();
            emp.Birthday = DateTime.Today.AddYears(-20);
            emp.DepartmentID = dep.ID;
            emp.EmployeeNumber = 0;
            emp.FirstName = DateTime.Now.Ticks.ToString();
            emp.JobDescription = DateTime.Now.Ticks.ToString();
            emp.HiredDate = DateTime.Today;
            emp.LeftDate = DateTime.Today.AddYears(1);
            emp.LastName = DateTime.Now.Ticks.ToString();
            emp.PhoneNumber = DateTime.Now.Ticks.ToString();
            emp.WorkingCalendarID = wCal.ID;
            emp.PayrollNumber = _dtCtrl.AddEmployee(emp, new List<Terminal>());
            #endregion

            #region add test att records 2
            //att7 : expected regHour: 10
            AttendanceRecord att71 = new AttendanceRecord();
            att71.EmployeeNumber = emp.EmployeeNumber;
            att71.Time = new DateTime(2010, 1, 7, 9, 0, 0);
            att71.ID = _dtCtrl.AddAttendanceRecord(att71);

            AttendanceRecord att72 = new AttendanceRecord();
            att72.EmployeeNumber = emp.EmployeeNumber;
            att72.Time = new DateTime(2010, 1, 7, 19, 0, 0);
            att72.ID = _dtCtrl.AddAttendanceRecord(att72);

            //att8 : expected regHour: 8
            AttendanceRecord att81 = new AttendanceRecord();
            att81.EmployeeNumber = emp.EmployeeNumber;
            att81.Time = new DateTime(2010, 1, 8, 9, 0, 0);
            att81.ID = _dtCtrl.AddAttendanceRecord(att81);

            AttendanceRecord att82 = new AttendanceRecord();
            att82.EmployeeNumber = emp.EmployeeNumber;
            att82.Time = new DateTime(2010, 1, 8, 17, 0, 0);
            att82.ID = _dtCtrl.AddAttendanceRecord(att82);

            //att9 : expected regHour: 8
            AttendanceRecord att91 = new AttendanceRecord();
            att91.EmployeeNumber = emp.EmployeeNumber;
            att91.Time = new DateTime(2010, 1, 9, 9, 0, 0);
            att91.ID = _dtCtrl.AddAttendanceRecord(att91);

            AttendanceRecord att92 = new AttendanceRecord();
            att92.EmployeeNumber = emp.EmployeeNumber;
            att92.Time = new DateTime(2010, 1, 9, 17, 0, 0);
            att92.ID = _dtCtrl.AddAttendanceRecord(att92);

            //att10 : expected regHour: 8
            AttendanceRecord att101 = new AttendanceRecord();
            att101.EmployeeNumber = emp.EmployeeNumber;
            att101.Time = new DateTime(2010, 1, 10, 9, 00, 0);
            att101.ID = _dtCtrl.AddAttendanceRecord(att101);

            AttendanceRecord att102 = new AttendanceRecord();
            att102.EmployeeNumber = emp.EmployeeNumber;
            att102.Time = new DateTime(2010, 1, 10, 17, 0, 0);
            att102.ID = _dtCtrl.AddAttendanceRecord(att102);

            //att11 : expected regHour: 4
            AttendanceRecord att111 = new AttendanceRecord();
            att111.EmployeeNumber = emp.EmployeeNumber;
            att111.Time = new DateTime(2010, 1, 11, 9, 0, 0);
            att111.ID = _dtCtrl.AddAttendanceRecord(att111);

            AttendanceRecord att112 = new AttendanceRecord();
            att112.EmployeeNumber = emp.EmployeeNumber;
            att112.Time = new DateTime(2010, 1, 11, 13, 0, 0);
            att112.ID = _dtCtrl.AddAttendanceRecord(att112);

            //att12 : expected regHour: 2 overHour: 2
            AttendanceRecord att121 = new AttendanceRecord();
            att121.EmployeeNumber = emp.EmployeeNumber;
            att121.Time = new DateTime(2010, 1, 12, 9, 0, 0);
            att121.ID = _dtCtrl.AddAttendanceRecord(att121);

            AttendanceRecord att122 = new AttendanceRecord();
            att122.EmployeeNumber = emp.EmployeeNumber;
            att122.Time = new DateTime(2010, 1, 12, 13, 0, 0);
            att122.ID = _dtCtrl.AddAttendanceRecord(att122);

            //att13 : expected overHour: 2
            AttendanceRecord att131 = new AttendanceRecord();
            att131.EmployeeNumber = emp.EmployeeNumber;
            att131.Time = new DateTime(2010, 1, 13, 9, 0, 0);
            att131.ID = _dtCtrl.AddAttendanceRecord(att131);

            AttendanceRecord att132 = new AttendanceRecord();
            att132.EmployeeNumber = emp.EmployeeNumber;
            att132.Time = new DateTime(2010, 1, 13, 11, 0, 0);
            att132.ID = _dtCtrl.AddAttendanceRecord(att132);
            #endregion
        }
        private void AddWCal()
        {
            wCal.Name = DateTime.Now.Ticks.ToString();

            wCal.WorkOnMonday    = true;
            wCal.WorkOnTuesday   = true;
            wCal.WorkOnWednesday = true;
            wCal.WorkOnThursday  = true;
            wCal.WorkOnFriday    = true;

            wCal.GraceForwardToEntry = 30;
            wCal.GraceForwardToEntry = 30;
            wCal.EarliestBeforeEntry = 60;
            wCal.LastestAfterExit    = 180;

            Shift shift = new Shift();

            shift.From = DateTime.Now;
            shift.To   = DateTime.Now;
            shiftList.Add(shift);

            payPeriod.CustomPeriod    = 5;
            payPeriod.PayPeriodTypeID = 5; //custom
            payPeriod.StartFrom       = DateTime.Today;

            wCal.ID = _dtCtrl.AddWorkingCalendar(wCal, shiftList, breakList, holidayList, workingDayPaymentRate, nonWorkingDayPaymentRate, holidayPaymentRate, payPeriod);

            com.Name = DateTime.Now.Ticks.ToString();;
            com.ID   = _dtCtrl.AddCompany(com);

            dep.Name            = DateTime.Now.Ticks.ToString();;
            dep.CompanyID       = com.ID;
            dep.SupDepartmentID = 0;
            dep.ID = _dtCtrl.AddDepartment(dep);

            emp.Active            = true;
            emp.ActiveFrom        = DateTime.Today;
            emp.ActiveTo          = DateTime.Today.AddDays(1);
            emp.Address           = DateTime.Now.Ticks.ToString();;
            emp.Birthday          = DateTime.Today.AddYears(-20);
            emp.DepartmentID      = dep.ID;
            emp.EmployeeNumber    = -1;
            emp.FirstName         = DateTime.Now.Ticks.ToString();
            emp.JobDescription    = DateTime.Now.Ticks.ToString();
            emp.HiredDate         = DateTime.Today;
            emp.LeftDate          = DateTime.Today.AddYears(1);
            emp.LastName          = DateTime.Now.Ticks.ToString();
            emp.PhoneNumber       = DateTime.Now.Ticks.ToString();;
            emp.WorkingCalendarID = wCal.ID;
            emp.FaceData1         = "";
            emp.FaceData2         = "";
            emp.FaceData3         = "";
            emp.FaceData4         = "";
            emp.FaceData5         = "";
            emp.FaceData6         = "";
            emp.FaceData7         = "";
            emp.FaceData8         = "";
            emp.FaceData9         = "";
            emp.FaceData10        = "";
            emp.FaceData11        = "";
            emp.FaceData12        = "";
            emp.FaceData13        = "";
            emp.FaceData14        = "";
            emp.FaceData15        = "";
            emp.FaceData16        = "";
            emp.FaceData17        = "";
            emp.FaceData18        = "";
            emp.PayrollNumber     = _dtCtrl.AddEmployee(emp, new List <Terminal>());
        }
        public void TestAddDepartment()
        {
            com1.ID = _dtCtrl.AddCompany(com1);

            dep1.CompanyID       = com1.ID;
            dep1.Name            = "Dep1";
            dep1.SupDepartmentID = 0; //root
            dep1.ID = _dtCtrl.AddDepartment(dep1);

            Assert.Greater(dep1.ID, 0);

            //again
            Assert.Less(_dtCtrl.AddDepartment(dep1), 0);

            //non company
            dep2.CompanyID       = 0;
            dep2.Name            = "Dep2";
            dep2.SupDepartmentID = 0; //root;
            dep2.ID = _dtCtrl.AddDepartment(dep2);

            Assert.Less(dep2.ID, 0);

            //empty name
            dep2.CompanyID       = com1.ID;
            dep2.Name            = "";
            dep2.SupDepartmentID = 0; //root;
            dep2.ID = _dtCtrl.AddDepartment(dep2);

            Assert.Less(dep2.ID, 0);

            //duplicate name
            dep2.CompanyID       = com1.ID;
            dep2.Name            = "Dep1";
            dep2.SupDepartmentID = 0; //root;
            dep2.ID = _dtCtrl.AddDepartment(dep2);

            Assert.Less(dep2.ID, 0);

            //sub deparment
            dep2.CompanyID       = com1.ID;
            dep2.Name            = "Dep2";
            dep2.SupDepartmentID = dep1.ID;
            dep2.ID = _dtCtrl.AddDepartment(dep2);

            Assert.Greater(dep2.ID, 0);

            //sub deparment, duplicate name
            dep3.CompanyID       = com1.ID;
            dep3.Name            = "Dep1";
            dep3.SupDepartmentID = dep1.ID;
            dep3.ID = _dtCtrl.AddDepartment(dep3);

            Assert.Less(dep3.ID, 0);

            //diff company, duplicate name
            com2.Name = "Com2";
            com2.ID   = _dtCtrl.AddCompany(com2);

            dep3.CompanyID       = com2.ID;
            dep3.Name            = "Dep1";
            dep3.SupDepartmentID = 0; //root
            dep3.ID = _dtCtrl.AddDepartment(dep3);

            Assert.Greater(dep3.ID, 0);

            //null
            Assert.Less(_dtCtrl.AddDepartment(null), 0);
        }
Esempio n. 8
0
        private void AddTestOneShiftNonFlexi(ref IDataController _dtCtrl)
        {
            #region add test company
            Company com = new Company();
            com.Name = DateTime.Now.Ticks.ToString();
            com.ID   = _dtCtrl.AddCompany(com);
            #endregion

            #region add test department
            Department dep = new Department();
            dep.CompanyID       = com.ID;
            dep.Name            = DateTime.Now.Ticks.ToString();
            dep.SupDepartmentID = 0; //root
            dep.ID = _dtCtrl.AddDepartment(dep);
            #endregion

            #region add test working calendar
            WorkingCalendar wCal = new WorkingCalendar();

            wCal.Name = DateTime.Now.Ticks.ToString();

            wCal.WorkOnMonday    = true;
            wCal.WorkOnTuesday   = true;
            wCal.WorkOnWednesday = true;
            wCal.WorkOnThursday  = true;
            wCal.WorkOnFriday    = true;

            wCal.GraceForwardToEntry = 30;
            wCal.GraceBackwardToExit = 30;
            wCal.EarliestBeforeEntry = 60;
            wCal.LastestAfterExit    = 180;

            List <Shift> shiftList = new List <Shift>();
            Shift        shift1    = new Shift();
            shift1.From = new DateTime(2000, 2, 2, 9, 0, 0);
            shift1.To   = new DateTime(2000, 2, 2, 18, 0, 0);
            shiftList.Add(shift1);

            List <Break> breakList = new List <Break>();
            Break        break1    = new Break();
            break1.From = new DateTime(2000, 2, 2, 12, 0, 0);
            break1.To   = new DateTime(2000, 2, 2, 13, 0, 0);
            break1.Name = "break1";
            break1.Paid = true;

            breakList.Add(break1);

            List <Holiday> holidayList = new List <Holiday>();

            PaymentRate workingDayPaymentRate = new PaymentRate();
            workingDayPaymentRate.NumberOfRegularHours = 7;
            workingDayPaymentRate.RegularRate          = 100;
            workingDayPaymentRate.NumberOfOvertime1    = 8;
            workingDayPaymentRate.OvertimeRate1        = 200;

            PaymentRate nonWorkingDayPaymentRate = workingDayPaymentRate;
            PaymentRate holidayPaymentRate       = workingDayPaymentRate;

            PayPeriod payPeriod = new PayPeriod();
            payPeriod.CustomPeriod    = 5;
            payPeriod.PayPeriodTypeID = 5; //custom
            payPeriod.StartFrom       = new DateTime(2010, 1, 1);

            wCal.ID = _dtCtrl.AddWorkingCalendar(wCal, shiftList, breakList, holidayList, workingDayPaymentRate, nonWorkingDayPaymentRate, holidayPaymentRate, payPeriod);
            #endregion

            #region add test employee
            Employee emp = new Employee();
            emp.Active            = true;
            emp.ActiveFrom        = DateTime.Today;
            emp.ActiveTo          = DateTime.Today.AddDays(1);
            emp.Address           = DateTime.Now.Ticks.ToString();
            emp.Birthday          = DateTime.Today.AddYears(-20);
            emp.DepartmentID      = dep.ID;
            emp.EmployeeNumber    = 0;
            emp.FirstName         = DateTime.Now.Ticks.ToString();
            emp.JobDescription    = DateTime.Now.Ticks.ToString();
            emp.HiredDate         = DateTime.Today;
            emp.LeftDate          = DateTime.Today.AddYears(1);
            emp.LastName          = DateTime.Now.Ticks.ToString();
            emp.PhoneNumber       = DateTime.Now.Ticks.ToString();
            emp.WorkingCalendarID = wCal.ID;
            emp.PayrollNumber     = _dtCtrl.AddEmployee(emp, new List <Terminal>());
            #endregion

            #region add test att records 1
            //att1 : expected totalHours: 9
            AttendanceRecord att11 = new AttendanceRecord();
            att11.EmployeeNumber = emp.EmployeeNumber;
            att11.Time           = new DateTime(2010, 1, 1, 9, 0, 0);
            att11.ID             = _dtCtrl.AddAttendanceRecord(att11);

            AttendanceRecord att12 = new AttendanceRecord();
            att12.EmployeeNumber = emp.EmployeeNumber;
            att12.Time           = new DateTime(2010, 1, 1, 18, 0, 0);
            att12.ID             = _dtCtrl.AddAttendanceRecord(att12);

            AttendanceRecord att13 = new AttendanceRecord();
            att13.EmployeeNumber = emp.EmployeeNumber;
            att13.Time           = new DateTime(2010, 1, 1, 12, 0, 0);
            att13.ID             = _dtCtrl.AddAttendanceRecord(att13);

            AttendanceRecord att14 = new AttendanceRecord();
            att14.EmployeeNumber = emp.EmployeeNumber;
            att14.Time           = new DateTime(2010, 1, 1, 13, 0, 0);
            att14.ID             = _dtCtrl.AddAttendanceRecord(att14);

            //att2 : expected totalHours: 9
            AttendanceRecord att21 = new AttendanceRecord();
            att21.EmployeeNumber = emp.EmployeeNumber;
            att21.Time           = new DateTime(2010, 1, 2, 8, 45, 0);
            att21.ID             = _dtCtrl.AddAttendanceRecord(att21);

            AttendanceRecord att22 = new AttendanceRecord();
            att22.EmployeeNumber = emp.EmployeeNumber;
            att22.Time           = new DateTime(2010, 1, 2, 18, 15, 0);
            att22.ID             = _dtCtrl.AddAttendanceRecord(att22);

            //att3 : expected totalHours: 9.75
            AttendanceRecord att31 = new AttendanceRecord();
            att31.EmployeeNumber = emp.EmployeeNumber;
            att31.Time           = new DateTime(2010, 1, 3, 8, 15, 0);
            att31.ID             = _dtCtrl.AddAttendanceRecord(att31);

            AttendanceRecord att32 = new AttendanceRecord();
            att32.EmployeeNumber = emp.EmployeeNumber;
            att32.Time           = new DateTime(2010, 1, 3, 18, 0, 0);
            att32.ID             = _dtCtrl.AddAttendanceRecord(att32);

            //att4 : expected totalHours: 0 + out mistake alert
            AttendanceRecord att41 = new AttendanceRecord();
            att41.EmployeeNumber = emp.EmployeeNumber;
            att41.Time           = new DateTime(2010, 1, 4, 7, 00, 0);
            att41.ID             = _dtCtrl.AddAttendanceRecord(att41);

            AttendanceRecord att42 = new AttendanceRecord();
            att42.EmployeeNumber = emp.EmployeeNumber;
            att42.Time           = new DateTime(2010, 1, 4, 18, 0, 0);
            att42.ID             = _dtCtrl.AddAttendanceRecord(att42);

            //att5 : expected totalHours: 8.8x
            AttendanceRecord att51 = new AttendanceRecord();
            att51.EmployeeNumber = emp.EmployeeNumber;
            att51.Time           = new DateTime(2010, 1, 5, 9, 06, 0);
            att51.ID             = _dtCtrl.AddAttendanceRecord(att51);

            AttendanceRecord att52 = new AttendanceRecord();
            att52.EmployeeNumber = emp.EmployeeNumber;
            att52.Time           = new DateTime(2010, 1, 5, 18, 2, 0);
            att52.ID             = _dtCtrl.AddAttendanceRecord(att52);

            //att6 : expected totalHours: 8.5
            AttendanceRecord att61 = new AttendanceRecord();
            att61.EmployeeNumber = emp.EmployeeNumber;
            att61.Time           = new DateTime(2010, 1, 6, 9, 0, 0);
            att61.ID             = _dtCtrl.AddAttendanceRecord(att61);

            AttendanceRecord att62 = new AttendanceRecord();
            att62.EmployeeNumber = emp.EmployeeNumber;
            att62.Time           = new DateTime(2010, 1, 6, 18, 0, 0);
            att62.ID             = _dtCtrl.AddAttendanceRecord(att62);

            AttendanceRecord att63 = new AttendanceRecord();
            att63.EmployeeNumber = emp.EmployeeNumber;
            att63.Time           = new DateTime(2010, 1, 6, 12, 30, 0);
            att63.ID             = _dtCtrl.AddAttendanceRecord(att63);

            AttendanceRecord att64 = new AttendanceRecord();
            att64.EmployeeNumber = emp.EmployeeNumber;
            att64.Time           = new DateTime(2010, 1, 6, 13, 30, 0);
            att64.ID             = _dtCtrl.AddAttendanceRecord(att64);
            #endregion
        }
Esempio n. 9
0
        private void AddTestOneShiftFlexi(ref IDataController _dtCtrl)
        {
            #region add test company
            Company com = new Company();
            com.Name = DateTime.Now.Ticks.ToString();
            com.ID   = _dtCtrl.AddCompany(com);
            #endregion

            #region add test department
            Department dep = new Department();
            dep.CompanyID       = com.ID;
            dep.Name            = DateTime.Now.Ticks.ToString();
            dep.SupDepartmentID = 0; //root
            dep.ID = _dtCtrl.AddDepartment(dep);
            #endregion

            #region add test working calendar
            List <Break> breakList = new List <Break>();
            Break        break1    = new Break();
            break1.From = new DateTime(2000, 2, 2, 12, 0, 0);
            break1.To   = new DateTime(2000, 2, 2, 13, 0, 0);
            break1.Name = "break1";
            break1.Paid = true;

            breakList.Add(break1);

            List <Holiday> holidayList = new List <Holiday>();

            PaymentRate workingDayPaymentRate = new PaymentRate();
            workingDayPaymentRate.NumberOfRegularHours = 7;
            workingDayPaymentRate.RegularRate          = 100;
            workingDayPaymentRate.NumberOfOvertime1    = 8;
            workingDayPaymentRate.OvertimeRate1        = 200;

            PaymentRate nonWorkingDayPaymentRate = workingDayPaymentRate;
            PaymentRate holidayPaymentRate       = workingDayPaymentRate;

            PayPeriod payPeriod = new PayPeriod();
            payPeriod.CustomPeriod    = 5;
            payPeriod.PayPeriodTypeID = 5; //custom
            payPeriod.StartFrom       = new DateTime(2010, 1, 1);

            WorkingCalendar wCal = new WorkingCalendar();
            wCal.Name            = DateTime.Now.Ticks.ToString();
            wCal.ApplyFlexiHours = true;
            wCal.FlexiHours      = 40;
            wCal.WeekStartsOn    = 3; //Thursday

            List <Shift> shiftList = new List <Shift>();
            Shift        shift1    = new Shift();
            shift1.From = new DateTime(2000, 2, 2, 9, 0, 0);
            shift1.To   = new DateTime(2000, 2, 2, 18, 0, 0);
            shiftList.Add(shift1);

            wCal.WorkOnMonday    = true;
            wCal.WorkOnTuesday   = true;
            wCal.WorkOnWednesday = true;
            wCal.WorkOnThursday  = true;
            wCal.WorkOnFriday    = true;

            wCal.GraceForwardToEntry = 30;
            wCal.GraceBackwardToExit = 30;
            wCal.EarliestBeforeEntry = 60;
            wCal.LastestAfterExit    = 180;

            wCal.ID = _dtCtrl.AddWorkingCalendar(wCal, shiftList, new List <Break>(), holidayList, workingDayPaymentRate, nonWorkingDayPaymentRate, holidayPaymentRate, payPeriod);
            #endregion

            #region add test employee
            Employee emp = new Employee();
            emp.Active            = true;
            emp.ActiveFrom        = DateTime.Today;
            emp.ActiveTo          = DateTime.Today.AddDays(1);
            emp.Address           = DateTime.Now.Ticks.ToString();
            emp.Birthday          = DateTime.Today.AddYears(-20);
            emp.DepartmentID      = dep.ID;
            emp.EmployeeNumber    = 0;
            emp.FirstName         = DateTime.Now.Ticks.ToString();
            emp.JobDescription    = DateTime.Now.Ticks.ToString();
            emp.HiredDate         = DateTime.Today;
            emp.LeftDate          = DateTime.Today.AddYears(1);
            emp.LastName          = DateTime.Now.Ticks.ToString();
            emp.PhoneNumber       = DateTime.Now.Ticks.ToString();
            emp.WorkingCalendarID = wCal.ID;
            emp.PayrollNumber     = _dtCtrl.AddEmployee(emp, new List <Terminal>());
            #endregion

            #region add test att records 2
            //att7 : expected regHour: 10
            AttendanceRecord att71 = new AttendanceRecord();
            att71.EmployeeNumber = emp.EmployeeNumber;
            att71.Time           = new DateTime(2010, 1, 7, 9, 0, 0);
            att71.ID             = _dtCtrl.AddAttendanceRecord(att71);

            AttendanceRecord att72 = new AttendanceRecord();
            att72.EmployeeNumber = emp.EmployeeNumber;
            att72.Time           = new DateTime(2010, 1, 7, 19, 0, 0);
            att72.ID             = _dtCtrl.AddAttendanceRecord(att72);

            //att8 : expected regHour: 8
            AttendanceRecord att81 = new AttendanceRecord();
            att81.EmployeeNumber = emp.EmployeeNumber;
            att81.Time           = new DateTime(2010, 1, 8, 9, 0, 0);
            att81.ID             = _dtCtrl.AddAttendanceRecord(att81);

            AttendanceRecord att82 = new AttendanceRecord();
            att82.EmployeeNumber = emp.EmployeeNumber;
            att82.Time           = new DateTime(2010, 1, 8, 17, 0, 0);
            att82.ID             = _dtCtrl.AddAttendanceRecord(att82);

            //att9 : expected regHour: 8
            AttendanceRecord att91 = new AttendanceRecord();
            att91.EmployeeNumber = emp.EmployeeNumber;
            att91.Time           = new DateTime(2010, 1, 9, 9, 0, 0);
            att91.ID             = _dtCtrl.AddAttendanceRecord(att91);

            AttendanceRecord att92 = new AttendanceRecord();
            att92.EmployeeNumber = emp.EmployeeNumber;
            att92.Time           = new DateTime(2010, 1, 9, 17, 0, 0);
            att92.ID             = _dtCtrl.AddAttendanceRecord(att92);

            //att10 : expected regHour: 8
            AttendanceRecord att101 = new AttendanceRecord();
            att101.EmployeeNumber = emp.EmployeeNumber;
            att101.Time           = new DateTime(2010, 1, 10, 9, 00, 0);
            att101.ID             = _dtCtrl.AddAttendanceRecord(att101);

            AttendanceRecord att102 = new AttendanceRecord();
            att102.EmployeeNumber = emp.EmployeeNumber;
            att102.Time           = new DateTime(2010, 1, 10, 17, 0, 0);
            att102.ID             = _dtCtrl.AddAttendanceRecord(att102);

            //att11 : expected regHour: 4
            AttendanceRecord att111 = new AttendanceRecord();
            att111.EmployeeNumber = emp.EmployeeNumber;
            att111.Time           = new DateTime(2010, 1, 11, 9, 0, 0);
            att111.ID             = _dtCtrl.AddAttendanceRecord(att111);

            AttendanceRecord att112 = new AttendanceRecord();
            att112.EmployeeNumber = emp.EmployeeNumber;
            att112.Time           = new DateTime(2010, 1, 11, 13, 0, 0);
            att112.ID             = _dtCtrl.AddAttendanceRecord(att112);

            //att12 : expected regHour: 2 overHour: 2
            AttendanceRecord att121 = new AttendanceRecord();
            att121.EmployeeNumber = emp.EmployeeNumber;
            att121.Time           = new DateTime(2010, 1, 12, 9, 0, 0);
            att121.ID             = _dtCtrl.AddAttendanceRecord(att121);

            AttendanceRecord att122 = new AttendanceRecord();
            att122.EmployeeNumber = emp.EmployeeNumber;
            att122.Time           = new DateTime(2010, 1, 12, 13, 0, 0);
            att122.ID             = _dtCtrl.AddAttendanceRecord(att122);

            //att13 : expected overHour: 2
            AttendanceRecord att131 = new AttendanceRecord();
            att131.EmployeeNumber = emp.EmployeeNumber;
            att131.Time           = new DateTime(2010, 1, 13, 9, 0, 0);
            att131.ID             = _dtCtrl.AddAttendanceRecord(att131);

            AttendanceRecord att132 = new AttendanceRecord();
            att132.EmployeeNumber = emp.EmployeeNumber;
            att132.Time           = new DateTime(2010, 1, 13, 11, 0, 0);
            att132.ID             = _dtCtrl.AddAttendanceRecord(att132);
            #endregion
        }
Esempio n. 10
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));
        }