Ejemplo n.º 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!");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (SQL.HealthclinicEntities dbcon = new SQL.HealthclinicEntities())
            {
                //dbcon.Patients.Load();
                //SQL.Patient myPatient = dbcon.Patients.Local.First();

                dbcon.Messages.Load();
                SQL.Message myMsg = new SQL.Message();



                //Label1.Text = usrID;


                myMsg.MessageID = dbcon.Messages.Local.Count + 1;
                myMsg.FROM      = User.Identity.Name;
                myMsg.TO        = Convert.ToString(DropDownList1.SelectedItem.Value);
                myMsg.Message1  = TextBox1.Text;

                dbcon.Messages.Add(myMsg);
                dbcon.SaveChanges();
            }

            GridView1.DataBind();
        }
Ejemplo n.º 3
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;


            //}
        }
Ejemplo n.º 4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            SQL.HealthclinicEntities dbcon = new SQL.HealthclinicEntities();
            if (dbcon != null)
            {
                dbcon.Dispose();
            }
            dbcon = new SQL.HealthclinicEntities();
            try
            {
                dbcon.Appointments.Load();

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

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

                dbcon.Appointments.Remove(myAppointment);
                dbcon.SaveChanges();

                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();

                //   aptGridView.DataSource = testShite;
                //   aptGridView.DataBind();
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SQL.HealthclinicEntities dbcon = new SQL.HealthclinicEntities();

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

                List <SQL.Appointment> apts = (from x in dbcon.Appointments
                                               where x.PatientID == patient.PatientID
                                               select x).ToList();

                aptGridView.DataSource = apts;
                //aptGridView.DataKeyNames = "AppointmentID";
                aptGridView.DataBind();
            }
            catch (InvalidOperationException)
            {
                throw;
            }
        }