private bool CreateDowntime(DowntimeType dtType) { DateTime from, to; if (!string.IsNullOrEmpty(dtpFrom.Text) && !string.IsNullOrEmpty(dtpTo.Text)) { if (chbade.Checked) { //whole day appointment, only dates are visible if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) { offlineTimes.Add(CreateDowntime(from, to.AddDays(1), true, dtType)); } else { MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (!string.IsNullOrEmpty(txttimeFrom.Text) && !string.IsNullOrEmpty(txttimeTo.Text)) { //Timeframe appointment if (DateTime.TryParse(dtpFrom.Text + " " + txttimeFrom.Text, out from) && DateTime.TryParse(dtpTo.Text + " " + txttimeTo.Text, out to) && from < to) { if (from.Date == to.Date) { offlineTimes.Add(CreateDowntime(from, to, false, dtType)); } else { //more than 1 day selected while (from.Date != to.Date) { offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); from = from.AddDays(1); } offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); } } else { MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } dvOnline.Invalidate(); return(true); } else { MessageBox.Show("Error creating downtime, please fill out all textboxes!", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
private void shutdownRadioButton_CheckedChanged(object sender, EventArgs e) { DowntimeType = DowntimeType.Shutdown; }
private void OfflineRadioButton_CheckedChanged(object sender, EventArgs e) { DowntimeType = DowntimeType.Offline; }
public DowntimeTypeView() { InitializeComponent(); DowntimeType = DowntimeType.Offline; }
private bool CreateDowntime(DowntimeType dtType) { DateTime from, to; if (!string.IsNullOrEmpty(dtpFrom.Text) && !string.IsNullOrEmpty(dtpTo.Text)) { if (chbade.Checked) { //whole day appointment, only dates are visible if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) offlineTimes.Add(CreateDowntime(from, to.AddDays(1), true, dtType)); else MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!string.IsNullOrEmpty(txttimeFrom.Text) && !string.IsNullOrEmpty(txttimeTo.Text)) { //Timeframe appointment if (DateTime.TryParse(dtpFrom.Text + " " + txttimeFrom.Text, out from) && DateTime.TryParse(dtpTo.Text + " " + txttimeTo.Text, out to) && from < to) { if (from.Date == to.Date) offlineTimes.Add(CreateDowntime(from, to, false, dtType)); else { //more than 1 day selected while (from.Date != to.Date) { offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); from = from.AddDays(1); } offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); } } else MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } dvOnline.Invalidate(); return true; } else { MessageBox.Show("Error creating downtime, please fill out all textboxes!", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } }
private void CreateDailyRecurrenceDowntimes(DateTime dateFrom, DateTime dateTo, bool allDay, HashSet<DayOfWeek> daysOfWeek, DowntimeType appointmentType) { DateTime incDate = dateFrom; Guid guid = Guid.NewGuid(); while (incDate.Date <= dateTo.Date) { if (daysOfWeek.Contains(incDate.Date.DayOfWeek)) offlineTimes.Add(CreateDowntime(incDate, new DateTime(incDate.Year, incDate.Month, incDate.Day, dateTo.Hour, dateTo.Minute, 0), allDay, true, guid, appointmentType)); incDate = incDate.AddDays(1); } dvOnline.Invalidate(); }
private HiveDowntime CreateDowntime(DateTime startDate, DateTime endDate, bool allDay, bool recurring, Guid recurringId, DowntimeType downtimeType) { HiveDowntime downtime = new HiveDowntime(); downtime.StartDate = startDate; downtime.EndDate = endDate; downtime.AllDayEvent = allDay; downtime.BorderColor = Color.Red; downtime.Locked = true; downtime.Subject = downtimeType.ToString(); downtime.Recurring = recurring; downtime.RecurringId = recurringId; return downtime; }
private void shutdownRadioButton_CheckedChanged(object sender, EventArgs e) { DowntimeType = DowntimeType.Shutdown; }
private void OfflineRadioButton_CheckedChanged(object sender, EventArgs e) { DowntimeType = DowntimeType.Offline; }
public DowntimeTypeView() { InitializeComponent(); DowntimeType = DowntimeType.Offline; }
private void CreateDailyRecurrenceDowntimes(DateTime dateFrom, DateTime dateTo, bool allDay, HashSet <DayOfWeek> daysOfWeek, DowntimeType appointmentType) { DateTime incDate = dateFrom; Guid guid = Guid.NewGuid(); while (incDate.Date <= dateTo.Date) { if (daysOfWeek.Contains(incDate.Date.DayOfWeek)) { offlineTimes.Add(CreateDowntime(incDate, new DateTime(incDate.Year, incDate.Month, incDate.Day, dateTo.Hour, dateTo.Minute, 0), allDay, true, guid, appointmentType)); } incDate = incDate.AddDays(1); } dvOnline.Invalidate(); }
private HiveDowntime CreateDowntime(DateTime startDate, DateTime endDate, bool allDay, bool recurring, Guid recurringId, DowntimeType downtimeType) { HiveDowntime downtime = new HiveDowntime(); downtime.StartDate = startDate; downtime.EndDate = endDate; downtime.AllDayEvent = allDay; downtime.BorderColor = Color.Red; downtime.Locked = true; downtime.Subject = downtimeType.ToString(); downtime.Recurring = recurring; downtime.RecurringId = recurringId; return(downtime); }