void SaveChanges() { if (reception == null) { return; } reception.Client = ClientOnReception; // reception.Client.Name = txtClientName.Text; // // var tmp = reception.Client.Telephones; // tmp.Add(txtTelephone.Text); // reception.Client.Telephones = tmp; reception.Rent = chkRent.Checked; reception.Cabinet.Name = cmbCabinet.SelectedText; reception.Specialist.Name = cmbSpecialist.SelectedText; reception.Specialization = cmbSpecialisation.SelectedText; reception.ReceptionTimeInterval.StartDate = dateTimeStart.Value; reception.ReceptionTimeInterval.EndDate = dateTimeEnd.Value; string errorMessage = reception.Validate(); if (errorMessage == null) { if (OnSaveChanges != null) { OnSaveChanges(this, new SaveChangesEventArgs <IReception>(reception)); } return; } MessageBox.Show(errorMessage, "Ошибка при сохранении результатов.", MessageBoxButtons.OK, MessageBoxIcon.Error); }
void SaveChanges() { if (reception == null || dummyReception == null) { return; } if (dateTimeEnd.Value - dateTimeStart.Value < TimeSpan.FromMinutes(10)) { MessageBox.Show("Время между началом и концом приёма меньше 10 минут.", "Ошибка при сохранении результатов.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } dummyReception.ID = reception.ID; dummyReception.Rent = chkRent.Checked; if (chkRent.Checked) { dummyReception.Client = null; dummyReception.Specialization = null; } else { dummyReception.Client = ClientOnReception; dummyReception.Specialization = (String)cmbSpecialisation.SelectedItem; } dummyReception.Cabinet = (ICabinet)cmbCabinet.SelectedItem; dummyReception.Specialist = (ISpecialist)cmbSpecialist.SelectedItem; dummyReception.ReceptionTimeInterval.StartDate = dateTimeStart.Value; dummyReception.ReceptionTimeInterval.EndDate = dateTimeEnd.Value; dummyReception.Price = Convert.ToInt32(numericPrice.Value); string errorMessage = dummyReception.Validate(); if (errorMessage == null) { doNothing = true; reception.Client = dummyReception.Client; reception.Rent = dummyReception.Rent; reception.Cabinet = dummyReception.Cabinet; reception.Specialist = dummyReception.Specialist; reception.Specialization = dummyReception.Specialization; reception.ReceptionTimeInterval = dummyReception.ReceptionTimeInterval; reception.Price = dummyReception.Price; if (OnSaveChanges != null) { OnSaveChanges(this, new SaveChangesEventArgs <IReception>(reception)); } doNothing = false; return; } MessageBox.Show(errorMessage, "Ошибка при сохранении результатов.", MessageBoxButtons.OK, MessageBoxIcon.Error); }