public AppointmentForm(int appID, Database.AppointmentMgr appMgr) { m_bIsNew = false; InitializeComponent(); AppointmentManager = appMgr; m_appointment = m_appMgr.getAppointment(appID); appointmentBindingSource.DataSource = m_appointment; // Issue binding these data sources so just // assign their selection manually here. Bit of a hack but oh well. appStatusIDComboBox.SelectedIndex = m_appointment.appStatusID; appRenewIntervalIDComboBox.SelectedIndex = (m_appointment.appRenewIntervalID != null) ? (int)m_appointment.appRenewIntervalID : -1; m_nPatientID = (int)m_appointment.patID; m_nAppID = appID; txtColour.BackColor = ColorTranslator.FromHtml(m_appointment.appColour); }
private void btnSave_Click(object sender, EventArgs e) { if (m_nPatientID == -1) { MessageBox.Show("No patient selection", "PatientManager", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (docIDComboBox.SelectedValue == null || (int)docIDComboBox.SelectedValue == -1) { MessageBox.Show("No doctor selected", "Patient Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Database.appointment appointment; if (m_bIsNew) { appointment = new Database.appointment(); } else { appointment = m_appointment; } appointment.appDate = combineDateAndTime(appDateDateTimePicker.Value, dtTime.Value); appointment.appDuration = (int)numDuration.Value; appointment.appStatusID = (int)appStatusIDComboBox.SelectedIndex; appointment.appNote = appNoteTextBox.Text; appointment.appDateCreate = DateTime.Now; appointment.appAutoRenew = appRenewIntervalIDComboBox.SelectedIndex != 0; // Old design - this really isn't needed appointment.appRenewIntervalID = appRenewIntervalIDComboBox.SelectedIndex; appointment.patID = m_nPatientID; appointment.docID = (int)docIDComboBox.SelectedValue; appointment.appColour = ColorTranslator.ToHtml(txtColour.BackColor); appointment.itryID = (int)cbType.SelectedValue; if (m_bIsNew) { m_appMgr.saveAppointment(appointment); } else { m_appMgr.updateAppointment(); } m_bIsSaved = true; MessageBox.Show("Saved"); Close(); }