示例#1
0
        private void allAppoitnmentsData_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int         index = e.RowIndex;
            appointment app;

            if (index > -1)
            {
                if (this.filteredAppointments.Rows.Count != 0)
                {
                    string title = filteredAppointments.Rows[index]["title"] as string;
                    app = dbConn.getAppointmentByTitle(title);
                }
                else if (this.searchedAllAppointments.Rows.Count != 0)
                {
                    string title = searchedAllAppointments.Rows[index]["title"] as string;
                    app = dbConn.getAppointmentByTitle(title);
                }
                else
                {
                    string title = dtAllAppointments.Rows[index]["title"] as string;
                    app = dbConn.getAppointmentByTitle(title);
                }
                EditAppointment ea = new EditAppointment(app);
                ea.ShowDialog();
            }
        }
        private void appointments_datagridview_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0 && senderGrid.Columns[e.ColumnIndex].ToString() == this.appointments_datagridview.Columns["EditAppointment"].ToString())
            {
                DataGridViewRow selectedAppointment = this.appointments_datagridview.CurrentRow;
                int             appointmentID       = int.Parse(this.appointments_datagridview.Rows[e.RowIndex].Cells["AppointmentID"].Value.ToString());
                Appointment     appointment         = this.appointmentController.GetAppointmentByID(appointmentID);
                EditAppointment editAppointment     = new EditAppointment();
                editAppointment.PopulateEditAppointmentFields(appointment);
                if (!(appointment.Scheduled_Date < DateTime.Now))
                {
                    DialogResult result = editAppointment.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        this.Reset_Button_Click(sender, e);
                    }
                }
                else
                {
                    MessageBox.Show("This appointment has passed. Cannot Edit.");
                }
            }
        }
示例#3
0
        /// <summary>
        ///   Handles the Click event of the EditAppointment_Button control. Fails if no appointment is selected but if one is it is loaded into a <see cref = "OpticianDB.Forms.Dialogs.EditAppointment" /> form and then the list is refreshed after the form closes
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        private void EditAppointment_Button_Click(object sender, EventArgs e)
        {
            if (appointments_DayView.SelectedAppointment == null)
            {
                MessageBox.Show("No appointment was selected to be loaded", "Could not load appointment",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (EditAppointment ea1 = new EditAppointment(GetSelectedAppointmentId()))
            {
                ea1.ShowDialog();
            }
            dbb.RefreshAdaptor();
            RefreshAppointments();
        }