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