/* public ShiftForm(Payperiod pPeriod) * */ public ShiftForm(PayPeriod pPeriod) { InitializeComponent(); myPayPeriod = pPeriod; foreach (Shift shift in myPayPeriod) { lstShifts.Items.Add(shift); } }
/* public void LoadData(string fileName) * create XmlReaderSettings settings * set settings.IgnoreComments to true * set settings.IgnoreWhiteSpace to true * try * create XmlReader reader(fileName,settings) * if(reader.ReadToDescendent("PayPeriod") * do * PayPeriod newPayPeriod * DateTime start = reader.ReadElementContentAsDateTime * DateTime end = reader.ReadElementContentAsDateTime * newPayPeriod = new PayPeriod(start,end) * * if(reader.ReadToDescendent("Shift") * do * DateTime start = reader.ReadElementContentAsDateTime * DateTime end = reader.ReadElementContentAsDateTime * * while reader.ReadToSibling("Shift") * * while reader.ReadToSibling("PayPeriod") */ public void LoadData(string fileName) { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; settings.IgnoreWhitespace = true; try { XmlReader reader = XmlReader.Create(fileName, settings); try { List.Clear(); if (reader.ReadToDescendant("PayPeriod")) { do { reader.ReadStartElement("PayPeriod"); DateTime start = DateTime.Parse(reader.ReadElementContentAsString()); DateTime end = DateTime.Parse(reader.ReadElementContentAsString()); PayPeriod newPayPeriod = new PayPeriod(start, end); Add(newPayPeriod); if (reader.Name == "Shift") { do { reader.ReadStartElement("Shift"); DateTime sStart = DateTime.Parse(reader.ReadElementContentAsString()); DateTime sEnd = DateTime.Parse(reader.ReadElementContentAsString()); Shift newShift = new Shift(sStart, sEnd); newPayPeriod.Add(newShift); reader.ReadEndElement(); } while (reader.Name =="Shift"); } reader.ReadEndElement(); } while (reader.Name == "PayPeriod"); } } catch { throw new ApplicationException("Error reading file"); } finally { reader.Close(); } } catch { } }
public void Add(PayPeriod pPeriod) { string message = ""; if (!validRange(pPeriod.StartDate,pPeriod.EndDate)) { message += "Pay period range must not fall within other pay periods, check dates."; } if (message == "") { List.Add(pPeriod); } else throw new ApplicationException(message); }
public void AddPayPeriod(DateTime start, DateTime end) { string message = ""; if (!PayPeriod.validDates(start, end)) { message = "Pay period start must come before pay period end" + Environment.NewLine; } if(!periodsList.validRange(start,end)) { message += "Pay period range is invalid, make sure there are no pay period overlaps."; } if (message == "") { PayPeriod pPeriod = new PayPeriod(start, end); periodsList.Add(pPeriod); lstPPeriods.Items.Add(periodsList[periodsList.Count - 1]); } else { MessageBox.Show(message); } }
public void Insert(int index, PayPeriod payPeriod) { List.Insert(index, payPeriod); }
public bool validUpdate(PayPeriod payPeriod, DateTime start, DateTime end) { bool validFlag = true; foreach (PayPeriod listPayPeriod in List) { if (payPeriod == listPayPeriod) continue; if (start >= listPayPeriod.StartDate && start < listPayPeriod.EndDate) validFlag = false; if (end <= listPayPeriod.EndDate && end > listPayPeriod.StartDate) validFlag = false; } return validFlag; }
public void Remove(PayPeriod pPeriod) { List.Remove(pPeriod); }
private void displayHours(PayPeriod sPayPeriod) { int accumulatedHours = (sPayPeriod.TotalLength.Days * 24) + sPayPeriod.TotalLength.Hours; txtPPeriodTime.Text = accumulatedHours.ToString() + ":" + sPayPeriod.TotalLength.Minutes.ToString(); }