コード例 #1
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;


            //}
        }
コード例 #2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            IEnumerable <SQL.Appointment> testAppointmentList =
                (from testDate in dbcontext.Appointments.Local
                 where testDate.AppointmentDate.Equals(startDateTextBox.Text)
                 orderby testDate.AppointmentTime
                 select testDate).AsEnumerable();

            foreach (SQL.Appointment testDate in testAppointmentList)
            {
                if (appointmentsDropDownList.SelectedValue.Equals(testDate.AppointmentTime))
                {
                    appointmentsDropDownList.SelectedValue.Remove(appointmentsDropDownList.SelectedIndex);
                }
            }


            /*
             * var userID = User.Identity.GetUserId();
             *
             * dbcontext.Patients.Load();
             * //SQL.Patient myPatient = new SQL.Patient();
             *
             * SQL.Patient myPatient = (from y in dbcontext.Patients.Local
             *                              where y.Email.Equals(userID)
             *                              select y).First();
             * SQL.Patient np = myPatient;
             */
            dbcontext.Appointments.Load();
            SQL.Patient patient = (from x in dbcontext.Patients
                                   where x.Email.Equals(User.Identity.Name)
                                   select x).First();

            SQL.Appointment myAppointment = new SQL.Appointment();
            myAppointment.AppointmentDate     = Convert.ToDateTime(startDateTextBox.Text);
            myAppointment.AppointmentTime     = TimeSpan.Parse(appointmentsDropDownList.SelectedValue);
            myAppointment.PatientID           = patient.PatientID;
            myAppointment.DoctorID            = Convert.ToInt32(doctorDropDownList.SelectedValue);
            myAppointment.HospitalID          = Convert.ToInt32(locationDropDownList.SelectedValue);
            myAppointment.AppointmentLocation = Convert.ToInt32(locationDropDownList.SelectedValue);
            myAppointment.DepartmentID        = Convert.ToInt32(departmentDropDownList.SelectedValue);
            myAppointment.Reason = reasonTextBox.Text;

            dbcontext.Appointments.Add(myAppointment);
            dbcontext.SaveChanges();
        }
コード例 #3
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;
            }
        }