Changeset 16520 for branches/2947_ConfigurableIndexedDataTable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
- Timestamp:
- 01/08/19 15:39:49 (5 years ago)
- Location:
- branches/2947_ConfigurableIndexedDataTable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2947_ConfigurableIndexedDataTable
- Property svn:mergeinfo changed
-
branches/2947_ConfigurableIndexedDataTable/HeuristicLab.Clients.Hive.Administrator
- Property svn:mergeinfo changed
-
branches/2947_ConfigurableIndexedDataTable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
r15583 r16520 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 … … 222 226 protected override void SetEnabledStateOfControls() { 223 227 base.SetEnabledStateOfControls(); 224 } 225 226 public virtual void SetEnabledStateOfSchedule(bool state) { 227 if (InvokeRequired) { 228 Invoke(new Action(() => SetEnabledStateOfSchedule(state))); 229 } else { 230 if (Content == null) state = false; 231 groupBox1.Enabled = state; 232 btnClearCal.Enabled = state; 233 btnSaveCal.Enabled = state; 234 } 235 } 228 bool enabled = Content != null && !Locked; 229 dtpFrom.Enabled = enabled; 230 dtpTo.Enabled = enabled; 231 chbade.Enabled = enabled; 232 btCreate.Enabled = enabled; 233 btbDelete.Enabled = enabled; 234 btnRecurrence.Enabled = enabled; 235 btnClearCal.Enabled = enabled; 236 btnSaveCal.Enabled = enabled; 237 } 238 239 //public virtual void SetEnabledStateOfSchedule(bool state) { 240 // if (InvokeRequired) { 241 // Invoke(new Action(() => SetEnabledStateOfSchedule(state))); 242 // } else { 243 // if (Content == null || Locked || ReadOnly) state = false; 244 // //groupBox1.Enabled = state; 245 // btnClearCal.Enabled = state; 246 // btnSaveCal.Enabled = state; 247 // } 248 //} 236 249 237 250 private void btnClearCal_Click(object sender, System.EventArgs e) { … … 243 256 244 257 private void chbade_CheckedChanged(object sender, EventArgs e) { 245 txttimeFrom.Visible = !chbade.Checked; 246 txttimeTo.Visible = !chbade.Checked; 258 if(chbade.Checked) { 259 dtpFrom.Value = new DateTime(dtpFrom.Value.Year, dtpFrom.Value.Month, dtpFrom.Value.Day); 260 dtpTo.Value = new DateTime(dtpTo.Value.Year, dtpTo.Value.Month, dtpTo.Value.Day); 261 } 247 262 } 248 263 249 264 private void dvOnline_OnSelectionChanged(object sender, EventArgs e) { 250 265 if (dvOnline.Selection == SelectionType.DateRange) { 251 dtpFrom.Text = dvOnline.SelectionStart.ToShortDateString(); 252 dtpTo.Text = dvOnline.SelectionEnd.Date.ToShortDateString(); 253 txttimeFrom.Text = dvOnline.SelectionStart.ToShortTimeString(); 254 txttimeTo.Text = dvOnline.SelectionEnd.ToShortTimeString(); 266 dtpFrom.Value = dvOnline.SelectionStart; 267 dtpTo.Value = dvOnline.SelectionEnd.Date; 255 268 btCreate.Text = "Create Downtime"; 256 269 } 257 270 258 271 if (dvOnline.Selection == SelectionType.Appointment) { 259 dtpFrom.Text = dvOnline.SelectedAppointment.StartDate.ToShortDateString(); 260 dtpTo.Text = dvOnline.SelectedAppointment.EndDate.ToShortDateString(); 261 txttimeFrom.Text = dvOnline.SelectedAppointment.StartDate.ToShortTimeString(); 262 txttimeTo.Text = dvOnline.SelectedAppointment.EndDate.ToShortTimeString(); 272 dtpFrom.Value = dvOnline.SelectedAppointment.StartDate; 273 dtpTo.Value = dvOnline.SelectedAppointment.EndDate; 263 274 264 275 if (dvOnline.SelectedAppointment.Recurring)
Note: See TracChangeset
for help on using the changeset viewer.