protected void ClinicList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ClinicList.SelectedIndex != 0)
            {
                finalPrice = (int)(Clinics[ClinicList.SelectedIndex - 1].getPrice() * Convert.ToDouble(Session["fraction"]));

                finalPriceBox.Text = Clinics[ClinicList.SelectedIndex - 1].getPrice() + " * " + Session["fraction"] + " = " + Clinics[ClinicList.SelectedIndex - 1].getPrice() * Convert.ToDouble(Session["fraction"]) + " L.E";
            }
            if (ClinicList.SelectedIndex != 0 && DateTime.TryParseExact(datepicker.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out datetime))
            {
                AppointmentDAO dao = new AppointmentDAO();

                string did   = getDoctorID();
                string shift = "Morning";
                if (PeriodList.SelectedIndex == 1)
                {
                    shift = "Evening";
                }
                List <string> times = dao.getTimes(did, datepicker.Text, shift);
                if (times.Count == 1 && times[0].Length != 5)
                {
                    Response.Write(times[0]);
                }
                else
                {
                    TimeList.Items.Clear();
                    for (int i = 0; i < times.Count; i++)
                    {
                        TimeList.Items.Add(new ListItem(times[i]));
                    }
                }
            }
        }
 protected void PeriodList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ClinicList.SelectedIndex != 0 && DateTime.TryParseExact(datepicker.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out datetime))
     {
         AppointmentDAO dao   = new AppointmentDAO();
         string         shift = "Morning";
         if (PeriodList.SelectedIndex == 1)
         {
             shift = "Evening";
         }
         string        did   = getDoctorID();
         List <string> times = dao.getTimes(did, datepicker.Text, shift);
         if (times.Count == 1 && times[0].Length != 5)
         {
             Response.Write(times[0]);
         }
         else
         {
             TimeList.Items.Clear();
             for (int i = 0; i < times.Count; i++)
             {
                 TimeList.Items.Add(new ListItem(times[i]));
             }
         }
     }
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (ClinicList.SelectedIndex != 0 && DateTime.TryParseExact(datepicker.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out datetime) && myCash >= finalPrice)
     {
         finalPrice = (int)(Clinics[ClinicList.SelectedIndex - 1].getPrice() * Convert.ToDouble(Session["fraction"]));
         //Response.Write(finalPrice + "");
         string did = getDoctorID();
         //ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:showSuccessDialogue(\"" + ClinicList.SelectedValue + "\",\"" + Session["fraction"].ToString() + "\",\"" + datepicker.Text + "\",\"" + TimeList.SelectedValue + "\"); ", true);
         AppointmentDAO dao    = new AppointmentDAO();
         string         result = dao.addAppointment(new Appointment(Session["User"].ToString(), did, datepicker.Text, TimeList.SelectedValue, finalPrice), myCash - finalPrice);
         // Response.Write(result);
         if (result.Equals("done"))
         {
             ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:showSuccessDialogue(\"" + ClinicList.SelectedValue + "\",\"" + Session["DoctorName"].ToString() + "\",\"" + datetime.DayOfWeek + " " + datepicker.Text + "\",\"" + TimeList.SelectedValue + "\",\"" + finalPrice + "\"); ", true);
         }
         else
         {
             ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:showErrorDialogue(\"" + result + "\"); ", true);
         }
     }
     else
     {
         string error = "";
         if (ClinicList.SelectedIndex == 0)
         {
             error += "Choose clinic, ";
         }
         if (!DateTime.TryParseExact(datepicker.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out datetime))
         {
             error += "pick valid date from date picker, ex: 2017-02-08, ";
         }
         if (myCash < finalPrice)
         {
             error += "You don't have enough cash to afford this visit, ";
         }
         ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:showErrorDialogue(\"" + error + "\"); ", true);
     }
 }