예제 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            dbcontext.Appointments.Load();
            if (!IsPostBack)
            {
                //get doctor
                SQL.HealthclinicEntities dbcon = new SQL.HealthclinicEntities();
                int        docIDT = Convert.ToInt32(doctorDropDownList.SelectedValue);
                SQL.Doctor doc    = (from x in dbcon.Doctors
                                     where x.DoctorID == docIDT
                                     select x).First();

                //Appointments are all a half hour long. Thanks Oksana!
                TimeSpan aptLength = new TimeSpan(0, 0, 30);
                DateTime aptDate   = DateTime.Parse(startDateTextBox.Text);
                //Get all of doctors appointments on the day of the appointment
                List <SQL.Appointment> aptList = (from x in dbcon.Appointments
                                                  where x.DoctorID == doc.DoctorID && x.AppointmentDate == aptDate
                                                  select x).ToList();
                TimeSpan aptTime = TimeSpan.Parse(appointmentsDropDownList.SelectedValue);

                //check to see if time is valid
                foreach (SQL.Appointment cur_Apt in aptList)
                {
                    if (cur_Apt.AppointmentTime >= aptTime && cur_Apt.AppointmentTime <= aptTime.Add(aptLength))
                    {
                        throw new Exception("Time is invalid!");
                    }
                }
            }
        }
예제 #2
0
        protected void aptGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            SQL.HealthclinicEntities dbcon = new SQL.HealthclinicEntities();

            dbcon.Appointments.Load();

            SQL.Patient patient = (from x in dbcon.Patients
                                   where x.Email.Equals(User.Identity.Name)
                                   select x).First();

            int something = Convert.ToInt32(aptGridView.SelectedDataKey[0]);

            SQL.Appointment apt = (from x in dbcon.Appointments
                                   where x.AppointmentID == something
                                   select x).First();



            SQL.Doctor doc = (from x in dbcon.Doctors
                              where x.DoctorID == apt.DoctorID
                              select x).First();

            var testShite = (from a in dbcon.Appointments
                             select new
            {
                aptID = a.AppointmentID,
                aptPatient = a.PatientID,
                aptDoctor = a.DoctorID,
                aptDate = a.AppointmentDate,
                aptTime = a.AppointmentTime,
                aptLoc = a.AppointmentLocation,
                aptDept = a.DepartmentID,
                aptHospital = a.HospitalID,
                aptReason = a.Reason
            }).ToList();

            string[] potentialKeys = { "AppointmentID" };


            aptGridView.DataSource   = testShite;
            aptGridView.DataKeyNames = potentialKeys;

            lblPName.Text  = "Patient name: " + patient.LastName + "," + patient.FirstName;
            lblDName.Text  = "Doctor name: " + doc.LastName + "," + doc.FirstName;
            lblLoc.Text    = "Appointment location: " + apt.AppointmentLocation;
            lblDate.Text   = "Appointment date: " + apt.AppointmentDate + "@" + apt.AppointmentTime;
            lblReason.Text = "Reason: " + apt.Reason;


            //}
        }