// SICK DAYS private void RetrieveSickDays(int ID) { List <SickDays> sickDays = SickDaysFactory.RetrieveSickDaysByID(ID); dataGridviewSickDays.DataSource = sickDays; txtTotalSickDays.Text = SickDaysFactory.RetrieveNumberOfSickDays(ID).ToString(); }
private void btnAddSickDay_Click(object sender, EventArgs e) { try { if (txtSickDayDescription.Text == "") { MessageBox.Show("Error Missing Sick Day Description."); } else if (dtpSickDayDate.Value.Date > DateTime.Now.Date || dtpSickDayEndDate.Value.Date > DateTime.Now.Date) { MessageBox.Show("Error sick date cannot be in the future."); } else if (dtpSickDayDate.Value.Date > dtpSickDayEndDate.Value.Date) { MessageBox.Show("Error sick start date must be before sick end date."); } else { List <SickDays> sickDays = new List <SickDays>(); if (chkRangeOfSickDates.Checked) { //TimeSpan difference = (dtpSickDayEndDate.Value.Date - dtpSickDayDate.Value.Date); DateTime tmpDate = dtpSickDayDate.Value.Date; while (tmpDate.Date <= dtpSickDayEndDate.Value.Date) { SickDays tmpSickDay = SickDaysFactory.SickDaysCreate(); tmpSickDay.empId = emp[listBoxResults.SelectedIndex].EmpID; tmpSickDay.SickDayDate = tmpDate; tmpSickDay.SickDayDescription = txtSickDayDescription.Text; if (cmbLenthOfDay.SelectedValue.ToString() == "Full") { tmpSickDay.SickDayLength = 1; } else { tmpSickDay.SickDayLength = 0.5; } sickDays.Add(tmpSickDay); tmpDate = tmpDate.AddDays(1); } } else { SickDays tmpSickDaySingular = SickDaysFactory.SickDaysCreate(); tmpSickDaySingular.empId = emp[listBoxResults.SelectedIndex].EmpID; tmpSickDaySingular.SickDayDate = dtpSickDayDate.Value; tmpSickDaySingular.SickDayDescription = txtSickDayDescription.Text; if (cmbLenthOfDay.SelectedValue.ToString() == "Full") { tmpSickDaySingular.SickDayLength = 1; } else { tmpSickDaySingular.SickDayLength = 0.5; } sickDays.Add(tmpSickDaySingular); } foreach (SickDays tmpAddSickDay in sickDays) { CUDMethods.CreateNewSickDay(tmpAddSickDay); } MessageBox.Show("Sick Day Added."); RetrieveSickDays(emp[listBoxResults.SelectedIndex].EmpID); clearSickDayInfo(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }