Exemple #1
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDateStart.errorProvider1.GetError(textDateStart) != "" ||
         textDateStop.errorProvider1.GetError(textDateStop) != "" ||
         textDatePaycheck.errorProvider1.GetError(textDatePaycheck) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDateStart.Text == "" || textDateStop.Text == "")
     {
         MsgBox.Show(this, "Start and end dates are required.");
         return;
     }
     PayPeriodCur.DateStart    = PIn.PDate(textDateStart.Text);
     PayPeriodCur.DateStop     = PIn.PDate(textDateStop.Text);
     PayPeriodCur.DatePaycheck = PIn.PDate(textDatePaycheck.Text);
     if (IsNew)
     {
         PayPeriods.Insert(PayPeriodCur);
     }
     else
     {
         PayPeriods.Update(PayPeriodCur);
     }
     DialogResult = DialogResult.OK;
 }
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDateStart.errorProvider1.GetError(textDateStart) != "" ||
                textDateStop.errorProvider1.GetError(textDateStop) != "" ||
                textDatePaycheck.errorProvider1.GetError(textDatePaycheck) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (textDateStart.Text == "" || textDateStop.Text == "")
            {
                MsgBox.Show(this, "Start and end dates are required.");
                return;
            }
            DateTime dateStart    = PIn.Date(textDateStart.Text);
            DateTime dateStop     = PIn.Date(textDateStop.Text);
            DateTime datePaycheck = PIn.Date(textDatePaycheck.Text);

            if (dateStart > dateStop)
            {
                MsgBox.Show(this, "The End Date cannot be before the Start Date.  Please change the date range.");
                return;
            }
            if (dateStop > datePaycheck)
            {
                MsgBox.Show(this, "The Paycheck Date must be on or after the End Date.  Please change the End Date or the Paycheck Date.");
                return;
            }
            _payPeriodCur.DateStart    = PIn.Date(textDateStart.Text);
            _payPeriodCur.DateStop     = PIn.Date(textDateStop.Text);
            _payPeriodCur.DatePaycheck = PIn.Date(textDatePaycheck.Text);
            PayPeriods.RefreshCache();             //Refresh the cache to include any other changes that might have been made in FormTimeCardSetup.
            List <PayPeriod> listExistingPayPeriods = PayPeriods.GetDeepCopy();

            if (_listNonInsertedPayPeriods != null)
            {
                //Add any payperiods that have not been inserted into the db.
                listExistingPayPeriods.AddRange(_listNonInsertedPayPeriods.FindAll(x => !x.IsSame(_payPeriodCur)));
            }
            if (PayPeriods.AreAnyOverlapping(listExistingPayPeriods, new List <PayPeriod>()
            {
                _payPeriodCur
            }))
            {
                MsgBox.Show(this, "This pay period overlaps with existing pay periods. Please fix this pay period first.");
                return;
            }
            if (IsSaveToDb)
            {
                if (IsNew)
                {
                    PayPeriods.Insert(_payPeriodCur);
                }
                else
                {
                    PayPeriods.Update(_payPeriodCur);
                }
            }
            DialogResult = DialogResult.OK;
        }
 private void butOK_Click(object sender, EventArgs e)
 {
     if (gridMain.Rows.Count == 0)
     {
         MsgBox.Show(this, "Pay periods must be generated first.");
         return;
     }
     if (numDaysAfterPayPeriod.errorProvider1.GetError(numDaysAfterPayPeriod) != "")
     {
         MsgBox.Show(this, numDaysAfterPayPeriod.errorProvider1.GetError(numDaysAfterPayPeriod));
         return;
     }
     PayPeriods.RefreshCache();             //Refresh the cache to include any other changes that might have been made in FormTimeCardSetup.
     //overlapping logic
     if (PayPeriods.AreAnyOverlapping(PayPeriods.GetDeepCopy(), _listPayPeriods))
     {
         MsgBox.Show(this, "You have created pay periods that would overlap with existing pay periods. Please fix those pay periods first.");
         return;
     }
     //Save payperiods
     foreach (PayPeriod payPeriod in _listPayPeriods)             //PayPeriods are always new in this form.
     {
         PayPeriods.Insert(payPeriod);
     }
     //Save Preferences
     if (radioWeekly.Checked)
     {
         Prefs.UpdateInt(PrefName.PayPeriodIntervalSetting, (int)PayPeriodInterval.Weekly);
     }
     else if (radioBiWeekly.Checked)
     {
         Prefs.UpdateInt(PrefName.PayPeriodIntervalSetting, (int)PayPeriodInterval.BiWeekly);
     }
     else
     {
         Prefs.UpdateInt(PrefName.PayPeriodIntervalSetting, (int)PayPeriodInterval.Monthly);
     }
     Prefs.UpdateInt(PrefName.PayPeriodPayDay, comboDay.SelectedIndex);
     Prefs.UpdateInt(PrefName.PayPeriodPayAfterNumberOfDays, PIn.Int(numDaysAfterPayPeriod.Text));
     Prefs.UpdateBool(PrefName.PayPeriodPayDateExcludesWeekends, checkExcludeWeekends.Checked);
     if (radioPayBefore.Checked)
     {
         Prefs.UpdateBool(PrefName.PayPeriodPayDateBeforeWeekend, true);
     }
     else if (radioPayAfter.Checked)
     {
         Prefs.UpdateBool(PrefName.PayPeriodPayDateBeforeWeekend, false);
     }
     DialogResult = DialogResult.OK;
 }
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDateStart.errorProvider1.GetError(textDateStart) != "" ||
         textDateStop.errorProvider1.GetError(textDateStop) != "" ||
         textDatePaycheck.errorProvider1.GetError(textDatePaycheck) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDateStart.Text == "" || textDateStop.Text == "")
     {
         MsgBox.Show(this, "Start and end dates are required.");
         return;
     }
     _payPeriodCur.DateStart    = PIn.Date(textDateStart.Text);
     _payPeriodCur.DateStop     = PIn.Date(textDateStop.Text);
     _payPeriodCur.DatePaycheck = PIn.Date(textDatePaycheck.Text);
     PayPeriods.RefreshCache();             //Refresh the cache to include any other changes that might have been made in FormTimeCardSetup.
     if (PayPeriods.AreAnyOverlapping(PayPeriods.GetDeepCopy(), new List <PayPeriod>()
     {
         _payPeriodCur
     }))
     {
         MsgBox.Show(this, "This pay period overlaps with existing pay periods. Please fix this pay period first.");
         return;
     }
     if (IsSaveToDb)
     {
         if (IsNew)
         {
             PayPeriods.Insert(_payPeriodCur);
         }
         else
         {
             PayPeriods.Update(_payPeriodCur);
         }
     }
     DialogResult = DialogResult.OK;
 }