Exemplo n.º 1
0
        private void FillGrid()
        {
            PayPeriods.RefreshCache();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Start Date", 80);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("End Date", 80);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Paycheck Date", 100);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            UI.ODGridRow row;
            for (int i = 0; i < PayPeriods.List.Length; i++)
            {
                row = new OpenDental.UI.ODGridRow();
                row.Cells.Add(PayPeriods.List[i].DateStart.ToShortDateString());
                row.Cells.Add(PayPeriods.List[i].DateStop.ToShortDateString());
                if (PayPeriods.List[i].DatePaycheck.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(PayPeriods.List[i].DatePaycheck.ToShortDateString());
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
        ///<summary>Deletes all the selected pay periods. Performs validation to make sure the delete is safe.</summary>
        private void butDelete_Click(object sender, EventArgs e)
        {
            //validation
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select one or more Pay Periods to delete.");
                return;
            }
            if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Are you sure you want to delete all selected pay periods?"))
            {
                return;
            }
            List <PayPeriod> listSelectedPayPeriods = new List <PayPeriod>();

            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                listSelectedPayPeriods.Add((PayPeriod)gridMain.ListGridRows[gridMain.SelectedIndices[i]].Tag);
            }
            List <PayPeriod> listPayPeriodsToDelete;

            if (!IsSafeToDelete(listSelectedPayPeriods, out listPayPeriodsToDelete))
            {
                return;
            }
            if (listPayPeriodsToDelete == null || listPayPeriodsToDelete.Count == 0)
            {
                return;
            }
            //Actual deletion logic below.
            foreach (PayPeriod payPeriod in listSelectedPayPeriods)
            {
                PayPeriods.Delete(payPeriod);
            }
            FillGrid();
        }
Exemplo n.º 5
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            PayPeriod payPeriodCur = new PayPeriod();

            if (PayPeriods.GetCount() == 0)
            {
                payPeriodCur.DateStart = DateTime.Today;
            }
            else
            {
                payPeriodCur.DateStart = PayPeriods.GetLast().DateStop.AddDays(1);
            }
            payPeriodCur.DateStop     = payPeriodCur.DateStart.AddDays(13);      //payPeriodCur.DateStop is inclusive, this is effectively a 14 day default pay period. This only affects default date of newly created pay periods.
            payPeriodCur.DatePaycheck = payPeriodCur.DateStop.AddDays(4);
            FormPayPeriodEdit FormP = new FormPayPeriodEdit(payPeriodCur);

            FormP.IsNew = true;
            FormP.ShowDialog();
            if (FormP.DialogResult == DialogResult.Cancel)
            {
                return;
            }
            FillGrid();
            changed = true;
        }
Exemplo n.º 6
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     PayPeriods.Delete(_payPeriodCur);
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 7
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();
 }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
0
 private void FormTimeCard_Load(object sender, System.EventArgs e)
 {
     Text              = Lan.g(this, "TimeCard for") + " " + EmployeeCur.FName + " " + EmployeeCur.LName;
     TimeDelta         = ClockEvents.GetServerTime() - DateTime.Now;
     SelectedPayPeriod = PayPeriods.GetForDate(DateTime.Today);
     if (IsBreaks)
     {
         textOvertime.Visible  = false;
         labelOvertime.Visible = false;
         butCompute.Visible    = false;
         butAdj.Visible        = false;
     }
     FillPayPeriod();
     FillMain(true);
 }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
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;
 }
Exemplo n.º 12
0
        private void FormPayPeriodManager_Load(object sender, System.EventArgs e)
        {
            PayPeriod payPeriod = PayPeriods.GetMostRecent();

            if (payPeriod == null)
            {
                dateTimeStart.Value = DateTime.Today;
            }
            else
            {
                dateTimeStart.Value = payPeriod.DateStop.AddDays(1);
            }
            PayPeriodInterval payPeriodInterval = (PayPeriodInterval)PrefC.GetInt(PrefName.PayPeriodIntervalSetting);

            if (payPeriodInterval == PayPeriodInterval.Weekly)
            {
                radioWeekly.Checked = true;
                numPayPeriods.Text  = "52";
            }
            else if (payPeriodInterval == PayPeriodInterval.BiWeekly)
            {
                radioBiWeekly.Checked = true;
                numPayPeriods.Text    = "21";
            }
            else if (payPeriodInterval == PayPeriodInterval.Monthly)
            {
                radioMonthly.Checked = true;
                numPayPeriods.Text   = "12";
            }
            int dayOfWeek = PrefC.GetInt(PrefName.PayPeriodPayDay);

            if (dayOfWeek != 0)           //They have a day of the week selected
            {
                comboDay.SelectedIndex        = dayOfWeek;
                numDaysAfterPayPeriod.Enabled = false;
                checkExcludeWeekends.Enabled  = false;
                radioPayBefore.Enabled        = false;
                radioPayAfter.Enabled         = false;
            }
            else
            {
                comboDay.SelectedIndex       = 0;
                numDaysAfterPayPeriod.Text   = PrefC.GetString(PrefName.PayPeriodPayAfterNumberOfDays);
                checkExcludeWeekends.Checked = PrefC.GetBool(PrefName.PayPeriodPayDateExcludesWeekends);
                if (checkExcludeWeekends.Checked)
                {
                    if (PrefC.GetBool(PrefName.PayPeriodPayDateBeforeWeekend))
                    {
                        radioPayBefore.Checked = true;
                    }
                    else
                    {
                        radioPayAfter.Checked = true;
                    }
                }
                if (!checkExcludeWeekends.Checked)
                {
                    radioPayBefore.Checked = false;
                    radioPayBefore.Enabled = false;
                    radioPayAfter.Checked  = false;
                    radioPayAfter.Enabled  = false;
                }
                else
                {
                    radioPayBefore.Enabled = true;
                    radioPayAfter.Enabled  = true;
                }
            }
            _listPayPeriods = new List <PayPeriod>();
            FillGrid();
        }