Exemple #1
0
 //Datagridview call click
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (isCanceling == true)
     {
         int          appointmentID = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
         int          patientID     = int.Parse(dataGridView1.CurrentRow.Cells[1].Value.ToString());
         DialogResult result        = MessageBox.Show("Are you sure you want cancel this appointment?", "Cancel Appointment", MessageBoxButtons.OKCancel);
         if (result == DialogResult.OK)
         {
             Appointemts appointemt = new Appointemts();
             appointemt.cancelAppointment(appointmentID, patientID);
             MessageBox.Show("Appointment Canceled", "Cancel Appointment");
             DialogResult results = MessageBox.Show("Appointment Canceled. Would you like to\ncancel another?", "Cancel Appointment", MessageBoxButtons.YesNo);
             if (results == DialogResult.Yes)
             {
                 Appointemts allAppointments = new Appointemts();
                 DataTable   dtAppointments  = allAppointments.getAllAppointments();
                 dataGridView1.DataSource  = dtAppointments; //Fill datagrid with datatable
                 dataGridView1.CurrentCell = null;
             }
             else
             {
                 dataGridView1.DataSource = null; //Empty datagrid view
                 Patients  allPatients   = new Patients();
                 DataTable dtAllPatients = allPatients.getAllPatients();
                 dataGridView1.DataSource  = dtAllPatients;
                 dataGridView1.CurrentCell = null;
                 button2.Enabled           = true;
                 isCanceling = false;
             }
         }
     }
     else
     {
         regBTN.Enabled  = false;
         fnameTB.Text    = dataGridView1.CurrentRow.Cells[1].Value.ToString();
         LnameTB.Text    = dataGridView1.CurrentRow.Cells[2].Value.ToString();
         ageTB.Text      = dataGridView1.CurrentRow.Cells[3].Value.ToString();
         addressTB.Text  = dataGridView1.CurrentRow.Cells[4].Value.ToString();
         townTB.Text     = dataGridView1.CurrentRow.Cells[5].Value.ToString();
         countyTB.Text   = dataGridView1.CurrentRow.Cells[6].Value.ToString();
         postcodeTB.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString();
         telTB.Text      = dataGridView1.CurrentRow.Cells[8].Value.ToString();
         regBTN.Enabled  = false;
     }
     //int i = 1;
     //regBTN.Enabled = false;
     //foreach (var cell in dataGridView1.SelectedRows)
     //{
     //    foreach (Control textbox in patientGB.Controls)
     //    {
     //        if (textbox is TextBox)
     //        {
     //            string currentValue = dataGridView1.CurrentRow.Cells[i].Value.ToString();
     //            textbox.Text = currentValue;
     //            i++;
     //        }
     //    }
     //}
 }
Exemple #2
0
        //Cancel appointments button
        private void button2_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;                                    //Empty datagrid view
            Appointemts allAppointments = new Appointemts();
            DataTable   dtAppointments  = allAppointments.getAllAppointments(); //Call get all appointments from appointments class

            dataGridView1.DataSource  = dtAppointments;                         //Fill datagrid with datatable
            dataGridView1.CurrentCell = null;
            button2.Enabled           = false;
            createAppBTN.Enabled      = true;
            isCanceling = true;
        }
Exemple #3
0
 //Add appointment button
 private void createAppBTN_Click(object sender, EventArgs e)
 {
     try
     {
         if (isCanceling == false)
         {
             appointemt = new Appointemts();
             int patientID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);
             int doctorID  = doctorCombo.SelectedIndex + 2;
             appointemt.date      = monthCalendar1.SelectionStart.ToString("dd/MM/yyyy");
             appointemt.timeSlot  = selectedApointment;
             appointemt.patientID = patientID;
             appointemt.doctorID  = doctorID;
             appointemt.addAppointment();
             MessageBox.Show("Booking sucessful");
             createAppBTN.Enabled = false;
             Panel panel         = panel1;
             var   panelControls = panel1.Controls;
             dataGridView1.CurrentCell = null;
             foreach (Control seat in panelControls)
             {
                 if (seat.BackColor == Color.Yellow)
                 {
                     seat.BackColor = Color.Firebrick;
                     seat.Enabled   = false;
                 }
             }
             getBookings();
         }
         else
         {
             dataGridView1.DataSource = null; //Empty datagrid view
             Patients  allPatients   = new Patients();
             DataTable dtAllPatients = allPatients.getAllPatients();
             dataGridView1.DataSource  = dtAllPatients;
             dataGridView1.CurrentCell = null;
             button2.Enabled           = true;
             isCanceling = false;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("No paitent selected\nPlease select a patient", "Booking error");
     }
 }
Exemple #4
0
        //****Methods****
        //Get bookings method selects all patient bookings for a given date and doctor
        private void getBookings()
        {
            string      selectedDate   = monthCalendar1.SelectionStart.ToString("dd/MM/yyyy");
            int         selectedDoctor = doctorCombo.SelectedIndex + 2;
            Appointemts checkBookings  = new Appointemts();
            DataTable   dtBookings     = checkBookings.checkSlots(selectedDate, selectedDoctor.ToString());
            Panel       panel          = panel1;
            var         panelControls  = panel1.Controls;

            foreach (Control seat in panelControls)
            {
                foreach (DataRow row in dtBookings.Rows)
                {
                    //Check vlaue of data row on seat id column against the text of the tabs buttons
                    if (seat.Text == row["Slot"].ToString() && selectedDoctor.ToString() == row["Doctor_Id"].ToString())
                    {
                        seat.BackColor = Color.LightSlateGray; //Colour seat yellow
                        seat.Enabled   = false;                //Disable seat
                        seat.Text      = row["First_Name"].ToString() + " " + row["Last_Name"].ToString();
                    }
                }
            }
        }