Пример #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;
            }
            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;
        }
Пример #2
0
 private void FormProduction_Load(object sender, System.EventArgs e)
 {
     checkAllProv.Checked = false;
     _listProviders       = Providers.GetListReports();
     textToday.Text       = DateTime.Today.ToShortDateString();
     for (int i = 0; i < _listProviders.Count; i++)
     {
         listProv.Items.Add(_listProviders[i].GetLongDesc());
     }
     if (PrefC.HasClinicsEnabled)
     {
         _listClinics = Clinics.GetForUserod(Security.CurUser);
         if (!Security.CurUser.ClinicIsRestricted)
         {
             listClin.Items.Add(Lan.g(this, "Unassigned"));
             listClin.SetSelected(0, true);
         }
         for (int i = 0; i < _listClinics.Count; i++)
         {
             int curIndex = listClin.Items.Add(_listClinics[i].Abbr);
             if (Clinics.ClinicNum == 0)
             {
                 listClin.SetSelected(curIndex, true);
                 checkAllClin.Checked = true;
             }
             if (_listClinics[i].ClinicNum == Clinics.ClinicNum)
             {
                 listClin.SelectedIndices.Clear();
                 listClin.SetSelected(curIndex, true);
             }
         }
     }
     else
     {
         listClin.Visible     = false;
         labelClin.Visible    = false;
         checkAllClin.Visible = false;
     }
     _listPayPeriods       = PayPeriods.GetDeepCopy();
     _selectedPayPeriodIdx = PayPeriods.GetForDate(DateTime.Today);
     if (_selectedPayPeriodIdx < 0)
     {
         dtPickerFrom.Value = DateTime.Today.AddDays(-7);
         dtPickerTo.Value   = DateTime.Today;
     }
     else
     {
         dtPickerFrom.Value = _listPayPeriods[_selectedPayPeriodIdx].DateStart;
         dtPickerTo.Value   = _listPayPeriods[_selectedPayPeriodIdx].DateStop;
     }
     butThis.Text = Lan.g(this, "This Period");
     SetDates();
 }
Пример #3
0
 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;
 }
Пример #4
0
        ///<summary>Does not refresh the cached list.  Make sure any updates to _listPayPeriods are done before calling this method.</summary>
        private void FillGrid()
        {
            PayPeriods.RefreshCache();
            _listPayPeriods = PayPeriods.GetDeepCopy().OrderBy(x => x.DateStart).ToList();
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn("Start Date", 80);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("End Date", 80);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Paycheck Date", 100);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            UI.GridRow row;
            foreach (PayPeriod payPeriodCur in _listPayPeriods)
            {
                if (checkHideOlder.Checked && payPeriodCur.DateStart < DateTimeOD.Today.AddMonths(-6))
                {
                    continue;
                }
                row = new OpenDental.UI.GridRow();
                row.Cells.Add(payPeriodCur.DateStart.ToShortDateString());
                row.Cells.Add(payPeriodCur.DateStop.ToShortDateString());
                if (payPeriodCur.DatePaycheck.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(payPeriodCur.DatePaycheck.ToShortDateString());
                }
                row.Tag = payPeriodCur;
                if (payPeriodCur.DateStart <= DateTimeOD.Today && payPeriodCur.DateStop >= DateTimeOD.Today)
                {
                    row.ColorBackG = Color.LightCyan;
                }
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
Пример #5
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.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;
 }