Example #1
0
        //Doctor avalibility selects all records for a given date and doctor
        private void doctorAvalibility()
        {
            string selectedDate   = monthCalendar1.SelectionStart.ToString("dd/MM/yyyy");
            string selectedDoctor = doctorCombo.SelectedItem.ToString();
            int    comboID        = 0;

            if (doctorCombo.SelectedIndex == 0)
            {
                comboID = 2;
            }
            else if (doctorCombo.SelectedIndex == 1)
            {
                comboID = 3;
            }
            Unavailable unavailable         = new Unavailable();
            DataTable   dtDoctorAvalibility = unavailable.checkAvailabilityMethod(selectedDate, comboID.ToString());
            Panel       panel         = panel1;
            var         panelControls = panel1.Controls;

            foreach (Control seat in panelControls)
            {
                foreach (DataRow row in dtDoctorAvalibility.Rows)
                {
                    //Check vlaue of data row on seat id column against the text of the tabs buttons
                    if (seat.Text == row["Slot"].ToString() && comboID.ToString() == row["Staff_Id"].ToString())
                    {
                        seat.Enabled = false; //Disable seat
                        seat.Text    = row["Reason"].ToString();
                        if (row["Reason"].ToString() == "Hospital Visit")
                        {
                            seat.BackColor = Color.Red; //Colour seat Red
                        }
                        else if (row["Reason"].ToString() == "Home Visit")
                        {
                            seat.BackColor = Color.LightBlue; //Colour seat Blue
                        }
                        else if (row["Reason"].ToString() == "Meeting")
                        {
                            seat.BackColor = Color.LightYellow; //Colour seat Yellow
                        }
                        else if (row["Reason"].ToString() == "Other")
                        {
                            seat.BackColor = Color.LightGreen; //Colour seat Green
                        }
                    }
                }
            }
        }
Example #2
0
 //Create unavailibility button
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Unavailable unavailable = new Unavailable();
         int         staffID     = doctorCombo.SelectedIndex + 2;
         string      reason      = reasonCombo.SelectedItem.ToString();
         unavailable.staffID = staffID;
         unavailable.date    = monthCalendar1.SelectionStart.ToString("dd/MM/yyyy");
         unavailable.slot    = selectedApointment;
         unavailable.reason  = reason;
         unavailable.addAvailability();
         MessageBox.Show("Booking sucessful");
         doctorAvalibility();
     }
     catch (Exception error)
     {
         MessageBox.Show(error.ToString());
     }
 }