コード例 #1
0
        private void BindWorkingCalendarData(int workingCalendarID)
        {
            WorkingCalendar workingCalendar = _dtCtrl.GetWorkingCalendar(workingCalendarID);

            try
            {
                txtName.Text = workingCalendar.Name;

                #region Flexi Hours
                chbApplyFlexiHours.Checked = workingCalendar.ApplyFlexiHours;
                if (workingCalendar.ApplyFlexiHours)
                {
                    nudFlexiHours.Value           = workingCalendar.FlexiHours;
                    cbxWeekStartsOn.SelectedIndex = workingCalendar.WeekStartsOn;
                }
                #endregion

                #region Set Working Days
                chbMonday.Checked    = workingCalendar.WorkOnMonday;
                chbTuesday.Checked   = workingCalendar.WorkOnTuesday;
                chbWednesday.Checked = workingCalendar.WorkOnWednesday;
                chbThursday.Checked  = workingCalendar.WorkOnThursday;
                chbFriday.Checked    = workingCalendar.WorkOnFriday;
                chbSaturday.Checked  = workingCalendar.WorkOnSaturday;
                chbSunday.Checked    = workingCalendar.WorkOnSunday;

                nudGraceForwardToEntry.Value = workingCalendar.GraceForwardToEntry;
                nudGraceBackwardToExit.Value = workingCalendar.GraceBackwardToExit;
                nudEarliestBeforeEntry.Value = workingCalendar.EarliestBeforeEntry;
                nudLastestAfterExit.Value    = workingCalendar.LastestAfterExit;
                #endregion

                #region Set Shifts
                List <Shift> shiftList = _dtCtrl.GetShiftListByWorkingCalendar(workingCalendarID);
                if (shiftList.Count == 1) //one shift
                {
                    rbtOneShift.Checked      = true;
                    dtpRegularWorkFrom.Value = shiftList[0].From;
                    dtpRegularWorkTo.Value   = shiftList[0].To;
                }
                else //multi shifts
                {
                    rbtMultiShifts.Checked = true;
                    _shiftList             = shiftList;
                    BindShift();
                }
                #endregion

                #region Set Break Times
                List <Break> breaks = _dtCtrl.GetBreakListByWorkingCalendar(workingCalendarID);

                if (breaks.Count >= 1)
                {
                    Break break1 = breaks[0];
                    EnableBreakControls1(true);
                    chbBreak1.Checked = true;

                    txtBreakName1.Text    = break1.Name;
                    dtpBreakFrom1.Value   = break1.From;
                    dtpBreakTo1.Value     = break1.To;
                    chbBreakPaid1.Checked = break1.Paid;
                }

                if (breaks.Count >= 2)
                {
                    Break break2 = breaks[1];
                    EnableBreakControls2(true);
                    chbBreak2.Checked = true;

                    txtBreakName2.Text    = break2.Name;
                    dtpBreakFrom2.Value   = break2.From;
                    dtpBreakTo2.Value     = break2.To;
                    chbBreakPaid2.Checked = break2.Paid;
                }

                if (breaks.Count >= 3)
                {
                    Break break3 = breaks[2];
                    EnableBreakControls3(true);
                    chbBreak3.Checked = true;

                    txtBreakName3.Text    = break3.Name;
                    dtpBreakFrom3.Value   = break3.From;
                    dtpBreakTo3.Value     = break3.To;
                    chbBreakPaid3.Checked = break3.Paid;
                }
                #endregion

                #region Set Payment Rates
                if (workingCalendar.ApplyFlexiHours)
                {
                    PaymentRate workingDayPaymentRate = _dtCtrl.GetWorkingDayPaymentRateByWorkingCalendar(workingCalendarID);
                    ImplementCustomRates(workingDayPaymentRate);

                    nudFlexiHourRegularHour.Value   = (int)workingDayPaymentRate.NumberOfRegularHours;
                    nudFlexiHourOvertimeHour1.Value = (int)workingDayPaymentRate.NumberOfOvertime1;
                    nudFlexiHourOvertimeHour2.Value = (int)workingDayPaymentRate.NumberOfOvertime2;
                    nudFlexiHourOvertimeHour3.Value = (int)workingDayPaymentRate.NumberOfOvertime3;
                    nudFlexiHourOvertimeHour4.Value = (int)workingDayPaymentRate.NumberOfOvertime4;

                    PaymentRate nonWorkingDayPaymentRate = _dtCtrl.GetNonWorkingDayPaymentRateByWorkingCalendar(workingCalendarID);
                    ImplementCustomRates(nonWorkingDayPaymentRate);

                    PaymentRate holidayPaymentRate = _dtCtrl.GetHolidayPaymentRateByWorkingCalendar(workingCalendarID);
                    ImplementCustomRates(holidayPaymentRate);

                    Util.SetComboboxSelectedByValue(cbxFlexiHourWorkingDayRegularRate, workingDayPaymentRate.RegularRate);
                    Util.SetComboboxSelectedByValue(cbxFlexiHourNonWorkingDayRegularRate, nonWorkingDayPaymentRate.RegularRate);
                    Util.SetComboboxSelectedByValue(cbxFlexiHourHolidayRegularRate, holidayPaymentRate.RegularRate);
                    Util.SetComboboxSelectedByValue(cbxFlexiHourOvertimeRate1, workingDayPaymentRate.OvertimeRate3);
                    Util.SetComboboxSelectedByValue(cbxFlexiHourOvertimeRate2, workingDayPaymentRate.OvertimeRate4);
                    Util.SetComboboxSelectedByValue(cbxFlexiHourOvertimeRate3, workingDayPaymentRate.OvertimeRate4);
                    Util.SetComboboxSelectedByValue(cbxFlexiHourOvertimeRate4, workingDayPaymentRate.OvertimeRate4);
                }
                else
                {
                    PaymentRate workingDayPaymentRate = _dtCtrl.GetWorkingDayPaymentRateByWorkingCalendar(workingCalendarID);
                    ImplementCustomRates(workingDayPaymentRate);

                    nudWorkDayRegularHour.Value   = (int)workingDayPaymentRate.NumberOfRegularHours;
                    nudWorkDayOvertimeHour1.Value = (int)workingDayPaymentRate.NumberOfOvertime1;
                    nudWorkDayOvertimeHour2.Value = (int)workingDayPaymentRate.NumberOfOvertime2;
                    nudWorkDayOvertimeHour3.Value = (int)workingDayPaymentRate.NumberOfOvertime3;
                    nudWorkDayOvertimeHour4.Value = (int)workingDayPaymentRate.NumberOfOvertime4;

                    Util.SetComboboxSelectedByValue(cbxWorkDayRegularRate, workingDayPaymentRate.RegularRate);
                    Util.SetComboboxSelectedByValue(cbxWorkDayOvertimeRate1, workingDayPaymentRate.OvertimeRate1);
                    Util.SetComboboxSelectedByValue(cbxWorkDayOvertimeRate2, workingDayPaymentRate.OvertimeRate2);
                    Util.SetComboboxSelectedByValue(cbxWorkDayOvertimeRate3, workingDayPaymentRate.OvertimeRate3);
                    Util.SetComboboxSelectedByValue(cbxWorkDayOvertimeRate4, workingDayPaymentRate.OvertimeRate4);

                    PaymentRate nonWorkingDayPaymentRate = _dtCtrl.GetNonWorkingDayPaymentRateByWorkingCalendar(workingCalendarID);
                    ImplementCustomRates(nonWorkingDayPaymentRate);

                    nudNonWorkDayRegularHour.Value   = (int)nonWorkingDayPaymentRate.NumberOfRegularHours;
                    nudNonWorkDayOvertimeHour1.Value = (int)nonWorkingDayPaymentRate.NumberOfOvertime1;
                    nudNonWorkDayOvertimeHour2.Value = (int)nonWorkingDayPaymentRate.NumberOfOvertime2;
                    nudNonWorkDayOvertimeHour3.Value = (int)nonWorkingDayPaymentRate.NumberOfOvertime3;
                    nudNonWorkDayOvertimeHour4.Value = (int)nonWorkingDayPaymentRate.NumberOfOvertime4;

                    Util.SetComboboxSelectedByValue(cbxNonWorkDayRegularRate, nonWorkingDayPaymentRate.RegularRate);
                    Util.SetComboboxSelectedByValue(cbxNonWorkDayOvertimeRate1, nonWorkingDayPaymentRate.OvertimeRate1);
                    Util.SetComboboxSelectedByValue(cbxNonWorkDayOvertimeRate2, nonWorkingDayPaymentRate.OvertimeRate2);
                    Util.SetComboboxSelectedByValue(cbxNonWorkDayOvertimeRate3, nonWorkingDayPaymentRate.OvertimeRate3);
                    Util.SetComboboxSelectedByValue(cbxNonWorkDayOvertimeRate4, nonWorkingDayPaymentRate.OvertimeRate4);

                    PaymentRate holidayPaymentRate = _dtCtrl.GetHolidayPaymentRateByWorkingCalendar(workingCalendarID);
                    ImplementCustomRates(holidayPaymentRate);

                    nudHolidayRegularHour.Value   = (int)holidayPaymentRate.NumberOfRegularHours;
                    nudHolidayOvertimeHour1.Value = (int)holidayPaymentRate.NumberOfOvertime1;
                    nudHolidayOvertimeHour2.Value = (int)holidayPaymentRate.NumberOfOvertime2;
                    nudHolidayOvertimeHour3.Value = (int)holidayPaymentRate.NumberOfOvertime3;
                    nudHolidayOvertimeHour4.Value = (int)holidayPaymentRate.NumberOfOvertime4;

                    Util.SetComboboxSelectedByValue(cbxHolidayRegularRate, holidayPaymentRate.RegularRate);
                    Util.SetComboboxSelectedByValue(cbxHolidayOvertimeRate1, holidayPaymentRate.OvertimeRate1);
                    Util.SetComboboxSelectedByValue(cbxHolidayOvertimeRate2, holidayPaymentRate.OvertimeRate2);
                    Util.SetComboboxSelectedByValue(cbxHolidayOvertimeRate3, holidayPaymentRate.OvertimeRate3);
                    Util.SetComboboxSelectedByValue(cbxHolidayOvertimeRate4, holidayPaymentRate.OvertimeRate4);
                }
                #endregion

                #region Set Holidays
                _holidayList = _dtCtrl.GetHolidayListByWorkingCalendar(workingCalendarID);
                BindHoliday();
                #endregion

                #region Set Pay Period
                PayPeriod     payPeriod     = _dtCtrl.GetPayPeriod(workingCalendar.PayPeriodID);
                PayPeriodType payPeriodType = _dtCtrl.GetPayPeriodType(payPeriod.PayPeriodTypeID);

                if (payPeriodType.ID == 5)//custom Pay Period
                {
                    rbtPayPeriodCustom.Checked = true;
                    nudCustomPayPeriod.Value   = payPeriod.CustomPeriod;
                }
                else
                {
                    rbtPayPeriodWeekly.Checked      = payPeriodType.ID == 1;
                    rbtPayPeriodBiweekly.Checked    = payPeriodType.ID == 2;
                    rbtPayPeriodMonthly.Checked     = payPeriodType.ID == 3;
                    rbtPayPeriodHalfmonthly.Checked = payPeriodType.ID == 4;
                }

                dtpPayPeriodStartFrom.Value = payPeriod.StartFrom;
                #endregion
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Faulty Working Calendar. Please delete it and add a new one.");
            }
        }
コード例 #2
0
        private void BindWorkingCalendar(int workingCalendarID)
        {
            _workingCalendar = _dtCtrl.GetWorkingCalendar(workingCalendarID);

            if (_workingCalendar == null)
            {
                MessageBox.Show("Working Calendar not found or has been deleted.");
                this.Close();
            }

            //set shift
            List <Shift> shiftList = _dtCtrl.GetShiftListByWorkingCalendar(workingCalendarID);

            if (shiftList.Count == 0)
            {
                MessageBox.Show("Invalid Working Calendar.");
                this.Close();
            }
            else
            {
                lblNumberOfShift.Text = shiftList.Count.ToString();
            }

            lblWorkFrom.Text = GetTimeString(shiftList[0].From);
            lblWorkTo.Text   = GetTimeString(shiftList[shiftList.Count - 1].To);

            //set payment rate
            PaymentRate workDayPaymentRate = _dtCtrl.GetWorkingDayPaymentRateByWorkingCalendar(workingCalendarID);

            if (workDayPaymentRate == null)
            {
                //TODO
            }
            else
            {
                ucWorkingDayPaymentRate.SetPaymentRate(workDayPaymentRate);
            }

            if (_workingCalendar.ApplyFlexiHours == false)
            {
                PaymentRate nonWorkDayPaymentRate = _dtCtrl.GetNonWorkingDayPaymentRateByWorkingCalendar(workingCalendarID);

                if (nonWorkDayPaymentRate == null)
                {
                    //TODO
                }
                else
                {
                    ucNonWorkingDayPaymentRate.SetPaymentRate(nonWorkDayPaymentRate);
                }

                PaymentRate holidayRate = _dtCtrl.GetHolidayPaymentRateByWorkingCalendar(workingCalendarID);

                if (holidayRate == null)
                {
                    //TODO
                }
                else
                {
                    ucHolidayPaymentRate.SetPaymentRate(holidayRate);
                }
            }
            else
            {
                tabControl1.TabPages.Remove(tpgNonWorkingDayPaymentRate);
                tabControl1.TabPages.Remove(tpgHolidayPaymentRate);

                tpgWorkingDayPaymentRate.Text = "Flexi Hours Payment Rate";
            }

            //set break
            List <Break> breakList = _dtCtrl.GetBreakListByWorkingCalendar(workingCalendarID);

            if (breakList.Count >= 1)
            {
                lblBreak1.Text = GetTimeString(breakList[0].From) + " - " + GetTimeString(breakList[0].To);
            }
            else
            {
                lblBreak1.Text = "";
            }

            if (breakList.Count >= 2)
            {
                lblBreak2.Text = GetTimeString(breakList[1].From) + " - " + GetTimeString(breakList[0].To);
            }
            else
            {
                lblBreak2.Text = "";
            }

            if (breakList.Count >= 3)
            {
                lblBreak3.Text = GetTimeString(breakList[2].From) + " - " + GetTimeString(breakList[0].To);
            }
            else
            {
                lblBreak3.Text = "";
            }

            //set pay period
            PayPeriod payPeriod = _dtCtrl.GetPayPeriod(_workingCalendar.PayPeriodID);

            if (payPeriod == null)
            {
                //TODO
            }
            else
            {
                PayPeriodType payPeriodType = _dtCtrl.GetPayPeriodType(payPeriod.PayPeriodTypeID);

                if (payPeriodType == null)
                {
                    //TODO
                }
                else if (payPeriodType.ID == 5) //custom
                {
                    lblPayPeriod.Text = "Every " + payPeriod.CustomPeriod + " day(s)";
                }
                else
                {
                    lblPayPeriod.Text = payPeriodType.Name;
                }

                lblPayPeriodStartFrom.Text = payPeriod.StartFrom.ToShortDateString();

                //set calendar
                _holidayList = _dtCtrl.GetHolidayListByWorkingCalendar(workingCalendarID);

                FormatCalendar(DateTime.Today.Year, DateTime.Today.Month);
            }
        }
コード例 #3
0
        private void BindWorkingCalendar(int workingCalendarID)
        {
            _workingCalendar = _dtCtrl.GetWorkingCalendar(workingCalendarID);

            if (_workingCalendar == null)
            {
                MessageBox.Show("Working Calendar not found or has been deleted.");
                this.Close();
            }

            lblWorkFrom.Text = GetTimeString(_workingCalendar.RegularWorkingFrom);
            lblWorkTo.Text   = GetTimeString(_workingCalendar.RegularWorkingTo);

            //set payment rate
            PaymentRate workDayPaymentRate = _dtCtrl.GetWorkingDayPaymentRateByWorkingCalendar(workingCalendarID);

            if (workDayPaymentRate == null)
            {
                //TODO
            }
            else
            {
                ucWorkingDayPaymentRate.SetPaymentRate(workDayPaymentRate);
            }

            PaymentRate nonWorkDayPaymentRate = _dtCtrl.GetNonWorkingDayPaymentRateByWorkingCalendar(workingCalendarID);

            if (nonWorkDayPaymentRate == null)
            {
                //TODO
            }
            else
            {
                ucNonWorkingDayPaymentRate.SetPaymentRate(nonWorkDayPaymentRate);
            }

            PaymentRate holidayRate = _dtCtrl.GetHolidayPaymentRateByWorkingCalendar(workingCalendarID);

            if (holidayRate == null)
            {
                //TODO
            }
            else
            {
                ucHolidayPaymentRate.SetPaymentRate(holidayRate);
            }

            //set break
            List <Break> breakList = _dtCtrl.GetBreakListByWorkingCalendar(workingCalendarID);

            if (breakList.Count >= 1)
            {
                lblBreak1.Text = GetTimeString(breakList[0].From) + " - " + GetTimeString(breakList[0].To);
            }
            else
            {
                lblBreak1.Text = "";
            }

            if (breakList.Count >= 2)
            {
                lblBreak2.Text = GetTimeString(breakList[1].From) + " - " + GetTimeString(breakList[0].To);
            }
            else
            {
                lblBreak2.Text = "";
            }

            if (breakList.Count >= 3)
            {
                lblBreak3.Text = GetTimeString(breakList[2].From) + " - " + GetTimeString(breakList[0].To);
            }
            else
            {
                lblBreak3.Text = "";
            }

            //set pay period
            PayPeriod payPeriod = _dtCtrl.GetPayPeriod(_workingCalendar.PayPeriodID);

            if (payPeriod == null)
            {
                //TODO
            }
            else
            {
                PayPeriodType payPeriodType = _dtCtrl.GetPayPeriodType(payPeriod.PayPeriodTypeID);

                if (payPeriodType == null)
                {
                    //TODO
                }
                else if (payPeriodType.ID == 5) //custom
                {
                    lblPayPeriod.Text = "Every " + payPeriod.CustomPeriod + " day(s)";
                }
                else
                {
                    lblPayPeriod.Text = payPeriodType.Name;
                }

                lblPayPeriodStartFrom.Text = payPeriod.StartFrom.ToShortDateString();

                //set calendar
                _holidayList = _dtCtrl.GetHolidayListByWorkingCalendar(workingCalendarID);

                FormatCalendar(DateTime.Today.Year, DateTime.Today.Month);
            }
        }