Changeset 15956 for branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
- Timestamp:
- 06/08/18 15:34:12 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
r15813 r15956 92 92 93 93 if (!string.IsNullOrEmpty(dtpFrom.Text) && !string.IsNullOrEmpty(dtpTo.Text)) { 94 if ( chbade.Checked) {94 if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) { 95 95 //whole day appointment, only dates are visible 96 if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) 97 offlineTimes.Add(CreateDowntime(from, to.AddDays(1), true, dtType)); 98 else 99 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 100 } else if (!string.IsNullOrEmpty(txttimeFrom.Text) && !string.IsNullOrEmpty(txttimeTo.Text)) { 101 //Timeframe appointment 102 if (DateTime.TryParse(dtpFrom.Text + " " + txttimeFrom.Text, out from) && DateTime.TryParse(dtpTo.Text + " " + txttimeTo.Text, out to) && from < to) { 96 if (chbade.Checked) { 97 offlineTimes.Add(CreateDowntime(new DateTime(from.Year, from.Month, from.Day), (new DateTime(to.Year, to.Month, to.Day)).AddDays(1), true, dtType)); 98 } else { 99 //Timeframe appointment 103 100 if (from.Date == to.Date) 104 101 offlineTimes.Add(CreateDowntime(from, to, false, dtType)); … … 111 108 offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); 112 109 } 113 } else 114 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 115 } 110 } 111 112 } else { 113 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 114 } 115 116 116 117 dvOnline.Invalidate(); 117 118 return true; … … 156 157 157 158 private void ChangeRecurrenceDowntime(Guid recurringId) { 158 int hourfrom = int.Parse(txttimeFrom.Text.Substring(0, txttimeFrom.Text.IndexOf(':'))); 159 int hourTo = int.Parse(txttimeTo.Text.Substring(0, txttimeTo.Text.IndexOf(':'))); 160 List<HiveDowntime> recurringDowntimes = offlineTimes.Where(appointment => ((HiveDowntime)appointment).RecurringId == recurringId).ToList(); 161 recurringDowntimes.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, hourfrom, 0, 0)); 162 recurringDowntimes.ForEach(appointment => appointment.EndDate = new DateTime(appointment.EndDate.Year, appointment.EndDate.Month, appointment.EndDate.Day, hourTo, 0, 0)); 159 DateTime from, to; 160 if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) { 161 List<HiveDowntime> recurringDowntimes = offlineTimes.Where(appointment => ((HiveDowntime)appointment).RecurringId == recurringId).ToList(); 162 recurringDowntimes.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, from.Hour, 0, 0)); 163 recurringDowntimes.ForEach(appointment => appointment.EndDate = new DateTime(appointment.EndDate.Year, appointment.EndDate.Month, appointment.EndDate.Day, to.Hour, 0, 0)); 164 } else { 165 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 166 } 163 167 } 164 168 … … 249 253 250 254 private void chbade_CheckedChanged(object sender, EventArgs e) { 251 txttimeFrom.Visible = !chbade.Checked; 252 txttimeTo.Visible = !chbade.Checked; 255 if(chbade.Checked) { 256 dtpFrom.Value = new DateTime(dtpFrom.Value.Year, dtpFrom.Value.Month, dtpFrom.Value.Day); 257 dtpTo.Value = new DateTime(dtpTo.Value.Year, dtpTo.Value.Month, dtpTo.Value.Day); 258 } 253 259 } 254 260 255 261 private void dvOnline_OnSelectionChanged(object sender, EventArgs e) { 256 262 if (dvOnline.Selection == SelectionType.DateRange) { 257 dtpFrom.Text = dvOnline.SelectionStart.ToShortDateString(); 258 dtpTo.Text = dvOnline.SelectionEnd.Date.ToShortDateString(); 259 txttimeFrom.Text = dvOnline.SelectionStart.ToShortTimeString(); 260 txttimeTo.Text = dvOnline.SelectionEnd.ToShortTimeString(); 263 dtpFrom.Value = dvOnline.SelectionStart; 264 dtpTo.Value = dvOnline.SelectionEnd.Date; 261 265 btCreate.Text = "Create Downtime"; 262 266 } 263 267 264 268 if (dvOnline.Selection == SelectionType.Appointment) { 265 dtpFrom.Text = dvOnline.SelectedAppointment.StartDate.ToShortDateString(); 266 dtpTo.Text = dvOnline.SelectedAppointment.EndDate.ToShortDateString(); 267 txttimeFrom.Text = dvOnline.SelectedAppointment.StartDate.ToShortTimeString(); 268 txttimeTo.Text = dvOnline.SelectedAppointment.EndDate.ToShortTimeString(); 269 dtpFrom.Value = dvOnline.SelectedAppointment.StartDate; 270 dtpTo.Value = dvOnline.SelectedAppointment.EndDate; 269 271 270 272 if (dvOnline.SelectedAppointment.Recurring)
Note: See TracChangeset
for help on using the changeset viewer.