protected void btnSubmit_Click(object sender, EventArgs e) { AppointmentAppDbEntities dbcon = new AppointmentAppDbEntities(); dbcon.AppointmentTables.Load(); int hour = Convert.ToInt32(ddlHour.SelectedValue.ToString()); int minute = Convert.ToInt32(ddlMinute.SelectedValue.ToString()); if (validateAppointment(txtAdvisorName.Text, Convert.ToDateTime(lblDate.Text), new TimeSpan(hour, minute, 0))) { AppointmentTable myAppointment = new AppointmentTable(); myAppointment.AdvisorName = txtAdvisorName.Text; myAppointment.Location = txtLocation.Text; myAppointment.Date = Convert.ToDateTime(lblDate.Text); myAppointment.Time = new TimeSpan(hour, minute, 0); myAppointment.Reason = txtReason.Text; dbcon.AppointmentTables.Add(myAppointment); dbcon.SaveChanges(); gvBrowse.DataBind(); lstResult.Items.Clear(); lstResult.Items.Add("Student name: name, Advisor Name: " + txtAdvisorName.Text); lstResult.Items.Add("Location: " + txtLocation.Text); lstResult.Items.Add("Date: " + Convert.ToDateTime(lblDate.Text)); lstResult.Items.Add("Time: " + new TimeSpan(hour, minute, 0)); lstResult.Items.Add("Reason: " + txtReason.Text); } }
protected void deleteBtn_Click(object sender, EventArgs e) { int appointmentIdentifier; try { appointmentIdentifier = Convert.ToInt32(appointmentsView.SelectedRow.Cells[1].Text); } catch (Exception) { return; } NewBDcon(); dbcon.AppointmentTables.Load(); dbcon.MessagesTables.Load(); AppointmentTable entry = dbcon.AppointmentTables.Find(appointmentIdentifier); string advisorEmail = appointmentsView.SelectedRow.Cells[5].Text; string studentEmail = appointmentsView.SelectedRow.Cells[7].Text; string message = "Appointment Cancel: " + appointmentsView.SelectedRow.Cells[2].Text + " " + appointmentsView.SelectedRow.Cells[3].Text; string role = check_role(); MessagesTable messageEntry; if (role == "advisor") { messageEntry = new MessagesTable { EmailDate = DateTime.Today, EmailFrom = advisorEmail, EmailText = message, EmailTime = DateTime.Today.TimeOfDay, EmailTo = studentEmail }; } else { messageEntry = new MessagesTable { EmailDate = DateTime.Today, EmailFrom = studentEmail, EmailText = message, EmailTime = DateTime.Now.TimeOfDay, EmailTo = advisorEmail }; } dbcon.MessagesTables.Add(messageEntry); dbcon.AppointmentTables.Remove(entry); dbcon.SaveChanges(); View_Own_Appointments(); }
protected void editButton_Click(object sender, EventArgs e) { appointmentDB.AppointmentTables.Load(); var visitSummary = (from item in appointmentDB.AppointmentTables.Local where item.AppointmentID == Convert.ToInt32(GridView2.SelectedDataKey[0]) select item); AppointmentTable app = visitSummary.First(); app.VisitSummary = TextBox1.Text; appointmentDB.SaveChanges(); GridView2.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { AppointmentDBEntities1 dbcon = new AppointmentDBEntities1(); dbcon.AppointmentTables.Load(); // select item to delete AppointmentTable abc = (from x in dbcon.AppointmentTables.Local where x.AppointmentId == Convert.ToInt32(RemoveBox.Text) select x).First(); // delete obj dbcon.AppointmentTables.Remove(abc); dbcon.SaveChanges(); }
public async Task CreateAsync(Appointment appointment, CancellationToken cancellation = default) { var appointmentTable = new AppointmentTable { AppointmentAt = appointment.AppointmentAt, DoctorId = appointment.DoctorId.Value, PatientId = appointment.PatientId.Value, AppointmentId = appointment.AppointmentId.Value, Duration = appointment.AppointmentDuration.DurationInMinutes }; var context = await _dbContextProvider.GetAsync(); context.AppointmentTables.Add(appointmentTable); await context.SaveChangesAsync(cancellation); }
protected void Button1_Click(object sender, EventArgs e) { using (AdvisingDatabaseEntities1 dbcon = new AdvisingDatabaseEntities1()) { //retrieve the database results string queryUserName = Session["UserName"].ToString(); var user = (from x in dbcon.StudentTables where x.StudentUserName.Equals(queryUserName) select x).First(); //make new table and add it to the real database AppointmentTable table = new AppointmentTable(); table.StudentUserName = user.StudentUserName; table.AdvisorUserName = user.StudentAdvisorUserName; table.AppointmentReason = TextBox3.Text; table.AppointmentDate = Calendar1.SelectedDate.ToString().Substring(0, Calendar1.SelectedDate.ToString().IndexOf(" ")); table.AppointmentTime = TextBox1.Text + ":" + TextBox2.Text + " " + DropDownList1.SelectedValue; string proposedDate = Calendar1.SelectedDate.ToString().Substring(0, Calendar1.SelectedDate.ToString().IndexOf(" ")); string queryTable = Session["UserName"].ToString(); var tbl = (from x in dbcon.AppointmentTables where x.AppointmentDate.Equals(proposedDate) select x); if (tbl.Count() == 0) { dbcon.AppointmentTables.Add(table); StateLabel.Text = "You have a new appointment with your advisor at " + Calendar1.SelectedDate.ToString().Substring(0, Calendar1.SelectedDate.ToString().IndexOf(" ")) + " at " + TextBox1.Text + ":" + TextBox2.Text + " " + DropDownList1.SelectedValue + ". Reason: " + TextBox3.Text; MailSender.CreateMessage(Session["UserName"] + "@ndsu.edu", "New appointment added", "You have a new appointment with your advisor on" + Calendar1.SelectedDate.ToString().Substring(0, Calendar1.SelectedDate.ToString().IndexOf(" ")) + " at " + TextBox1.Text + ":" + TextBox2.Text + " " + DropDownList1.SelectedValue + ". Reason: " + TextBox3.Text); } else { StateLabel.Text = "Choose a different time."; } dbcon.SaveChanges(); } // show data in the GridView GridView1.DataBind(); }
protected void CancelAptButton_Click(object sender, EventArgs e) { if (GridView1.SelectedValue != null) { int removeID = Convert.ToInt32(GridView1.SelectedDataKey.Value); AppointmentTable toRemove = (from apt in dbcon.AppointmentTables where apt.IdNumber == removeID select apt).FirstOrDefault(); dbcon.AppointmentTables.Remove(toRemove); dbcon.SaveChanges(); GridView1.DataBind(); } else { ShowMessage("Please select a row before deleting."); } }
protected void ScheduleButton_Click(object sender, EventArgs e) { currDoc = GetDoctorFromName(DoctorSelectDropDownList.SelectedValue.Trim()); if (TimeDropDownList.SelectedValue != "") { //update DB with new appt AppointmentTable appt = new AppointmentTable(); appt.AppointmentID = GenerateApptID(); appt.DoctorID = docID; appt.PatientID = currUser.PatientID; appt.Data = AppointmentDaySelectCalendar.SelectedDate; appt.Time = TimeSpan.Parse(TimeDropDownList.SelectedValue); appt.VisitSummary = CheckCharLimit(ReasonTextBox.Text, 50); medDB.AppointmentTables.Add(appt); UpdateDB(); //send message to inbox MessageTable msgToPatient = new MessageTable(); msgToPatient.MessageID = GenerateMsgID(); msgToPatient.MessageTo = currUser.Email; msgToPatient.MessageFrom = "System"; msgToPatient.Date = DateTime.Now; //msgToPatient.Message = $"Appointment scheduled on {appt.Data} @ {appt.Time} with Doctor {currDoc.LastName}"; msgToPatient.Message = "Scheduled appointment"; medDB.MessageTables.Add(msgToPatient); UpdateDB(); MessageTable msgToDoctor = new MessageTable(); msgToDoctor.MessageID = GenerateMsgID(); msgToDoctor.MessageTo = currDoc.Email; msgToDoctor.MessageFrom = "System"; msgToDoctor.Date = DateTime.Now; //msgToDoctor.Message = $"Appointment scheduled on {appt.Data} @ {appt.Time} with Patient {currUser.FirstName + currUser.LastName}"; //msgToDoctor.Message = "Appointment scheduled"; msgToDoctor.Message = "Scheduled appointment"; medDB.MessageTables.Add(msgToDoctor); UpdateDB(); Server.TransferRequest(Request.Url.AbsolutePath, false); } }
//delete email protected void Button2_Click(object sender, EventArgs e) { using (CommunicationEntities dbcon = new CommunicationEntities()) { if (GridView1.SelectedDataKey.Value != null) //if there is one selected { int email = Convert.ToInt32(GridView1.SelectedDataKey.Value.ToString()); //first convert to integer AppointmentTable msg = (from x in dbcon.EmailTables where x.ID == email select x).First(); //delete row from the table dbcon.EmailTables.Remove(msg); dbcon.SaveChanges(); } } GridView1.DataBind(); }
protected void ScheduleButton_Click(object sender, EventArgs e) { currDoc = GetCurrentDoctor(); PatientTable currPat = GetPatientFromName(PatientsSelectDropDownList.SelectedValue.Trim()); //Update DB with new appointmnet AppointmentTable appt = new AppointmentTable(); appt.AppointmentID = GenerateApptID(); appt.DoctorID = docID; appt.PatientID = currPat.PatientID; appt.Data = AppointmentDaySelectCalendar.SelectedDate; appt.Time = TimeSpan.Parse(TimeDropDownList.SelectedValue); medDB.AppointmentTables.Add(appt); UpdateDB(); ////Send message to inbox //MessageTable msgToPatient = new MessageTable(); //msgToPatient.MessageID = GenerateMsgID(); //msgToPatient.MessageTo = currUser.UserLoginName; //msgToPatient.MessageFrom = "System"; //msgToPatient.Date = DateTime.Now; ////msgToPatient.Message = $"Appointment scheduled on {appt.Data} @ {appt.Time} with Doctor {currDoc.LastName}"; //msgToPatient.Message = "Appointment scheduled"; //medDB.MessageTables.Add(msgToPatient); //UpdateDB(); //MessageTable msgToDoctor = new MessageTable(); //msgToDoctor.MessageID = GenerateMsgID(); //msgToDoctor.MessageTo = currDoc.UserLoginName; //msgToDoctor.MessageFrom = "System"; //msgToDoctor.Date = DateTime.Now.Date; ////msgToDoctor.Message = $"Appointment scheduled on {appt.Data} @ {appt.Time} with Patient {currUser.FirstName + currUser.LastName}"; //msgToDoctor.Message = "Appointment scheduled"; //medDB.MessageTables.Add(msgToDoctor); //UpdateDB(); Server.TransferRequest(Request.Url.AbsolutePath, false); }
private bool validateAppointment(string advisorName, DateTime appDate, TimeSpan appTime) { AppointmentAppDbEntities dbcon = new AppointmentAppDbEntities(); dbcon.AppointmentTables.Load(); try { AppointmentTable existingApp = (from x in dbcon.AppointmentTables.Local where x.Date.Equals(appDate) && x.Time.Equals(appTime) select x).First(); } catch (Exception e) { return(advisorAvailable(advisorName, appDate, appTime)); } lstResult.Items.Clear(); lstResult.Items.Add("You already have an existing appointment at that date and time."); return(false); }
/* No longer needed * private void RefreshSession() * { * using (ScheduleEntities dbcon = new ScheduleEntities()) * { * * if (Session.Count > 0) * { * studentName = Session["User"].ToString(); * * var studentNameToId = * (from stu in dbcon.StudentTables * where stu.StudentUserName == studentName * select stu).First(); * * Session.Add("StdID", studentNameToId.StudentID); * * studentID = Convert.ToInt32(Session["StdID"].ToString()); * } * } * } */ //Add button protected void addBtn_Click(object sender, EventArgs e) { using (ScheduleEntities dbcon = new ScheduleEntities()) { var studentIDToAdvisorID = (from apt in dbcon.AppointmentTables where apt.StudentID == studentID select apt).First(); int advisorID = studentIDToAdvisorID.AdvisorID; var advisorDates = (from date in dbcon.AdvisorTables where date.AdvisorID == advisorID select date).First(); if (true /*Calendar1.SelectedDate.ToString() >= advisorDates.advisorStartDate && * Calendar1.SelectedDate.ToString() <= advisorDates.advisorEndDate*/) { AppointmentTable app = new AppointmentTable(); app.StudentID = studentID; app.AdvisorID = advisorID; app.AppointmentDate = Convert.ToDateTime(Calendar1.SelectedDate.ToString()); app.AppointmentTime = TimeSpan.Parse(TextBox2.Text); app.AppointmentReason = TextBox3.Text; // add data to the table dbcon.AppointmentTables.Add(app); dbcon.SaveChanges(); } else { } } // show data in the GridView GridView1.DataBind(); }
//submit button method protected void SubmitButton_Click(object sender, EventArgs e) { if (ValidForm()) { string time = ListBox1.SelectedValue.ToString(); TimeSpan t = new TimeSpan(); if (!TimeSpan.TryParse(time, out t) || time.Length < 2) { ShowMessage("Please select a valid time"); } else { string location = TextBoxHospital.Text + ", " + TextBoxCity.Text; string dept = TextBoxDept.Text; string reason = TextBoxReason.Text; string provider = TextBoxProvider.Text; DateTime dt = Calendar1.SelectedDate; AppointmentTable aptTable = new AppointmentTable(); DateTime newDate = new DateTime(dt.Year, dt.Month, dt.Day, t.Hours, t.Minutes, 0); if (ValidateAppointment(dt)) { //populate new db table entry aptTable.PatientName = name; aptTable.Location = location; aptTable.Department = dept; aptTable.Time = t; aptTable.Date = newDate;//date has been assigned in calendar selection changed method aptTable.Reason = TextBoxReason.Text; //Confirmation message= ShowMessage("Your Appointment on: " + newDate.ToShortDateString() + " at: " + newDate.ToShortTimeString() + " has been confirmed."); //save changes dbcon.AppointmentTables.Add(aptTable); dbcon.SaveChanges(); } } }//end if validform() }
//Delete Button protected void Button1_Click(object sender, EventArgs e) { using (ScheduleEntities dbcon = new ScheduleEntities()) { if (GridView1.SelectedDataKey.Value != null) { // add data to the dbcon // select the row int item = Convert.ToInt32( GridView1.SelectedDataKey.Value.ToString()); AppointmentTable app = (from x in dbcon.AppointmentTables where x.AppointmentID == item select x).First(); //delete row from the table dbcon.AppointmentTables.Remove(app); dbcon.SaveChanges(); } } GridView1.DataBind(); }
/* No longer needed * private void RefreshSession() * { * using (ScheduleEntities dbcon = new ScheduleEntities()) * { * * if (Session.Count > 0) * { * advisorName = Session["User"].ToString(); * * var advisorNameToId = * (from adv in dbcon.AdvisorTables * where adv.AdvisorUserName == advisorName * select adv).First(); * * Session.Add("AdvID", advisorNameToId.AdvisorID); * * advisorID = Convert.ToInt32(Session["AdvID"].ToString()); * } * * //Add button * } * } */ protected void addBtn_Click(object sender, EventArgs e) { using (ScheduleEntities dbcon = new ScheduleEntities()) { AppointmentTable app = new AppointmentTable(); app.AppointmentDate = Convert.ToDateTime(Calendar1.SelectedDate.ToString()); app.AppointmentTime = TimeSpan.Parse(TextBox2.Text); app.AppointmentReason = TextBox3.Text; app.AdvisorID = advisorID; var advisorIDToStudentID = (from apt in dbcon.AppointmentTables where apt.AdvisorID == advisorID select apt).First(); app.StudentID = advisorIDToStudentID.StudentID; // add data to the table dbcon.AppointmentTables.Add(app); dbcon.SaveChanges(); var StudentIDToName = (from x in dbcon.StudentTables where x.StudentID == advisorIDToStudentID.StudentID select x).First(); string studentName = StudentIDToName.StudentFirstName + " " + StudentIDToName.StudentLastName; notifLb.Text = "Appointment has been created for " + Calendar1.SelectedDate.ToString() + " at " + TextBox2.Text + " with " + studentName; } // show data in the GridView GridView1.DataBind(); }
/// <summary> /// Returns a list of Appointments that match the critera given by the QueryBuilder. /// In order to get sensible results, the first part of the query should be: /// SELECT * FROM Appointment /// with only the Where changing. /// </summary> /// <param name="b">The <see cref="QueryBuilder"/> to use as the SQL query.</param> /// <returns>A <see cref="List{Appointment}"/> matching the SQL query.</returns> public List <Appointment> GetAppointments(QueryBuilder b) { List <Appointment> result = new List <Appointment>(); MySqlCommand query = new MySqlCommand(b.ToString(), dbCon.GetConnection()); MySqlDataReader reader = query.ExecuteReader(); MySql.Data.MySqlClient.MySqlHelper.EscapeString("ds"); while (reader.Read()) { Appointment a = new Appointment(); AppointmentTable pt = Tables.APPOINTMENT_TABLE; a.Id = GetInt(reader[pt.ID.Name]); a.StaffId = GetInt(reader[pt.StaffID.Name]); a.PatientId = GetInt(reader[pt.PatientID.Name]); a.AppointmentTime = GetDateTime(reader[pt.AppointmentTime.Name]); a.AppointmentDate = GetDateTime(reader[pt.AppointmentDate.Name]); a.Cause = GetString(reader[pt.Cause.Name]); a.Status = GetString(reader[pt.Status.Name]); result.Add(a); } reader.Close(); reader.Dispose(); return(result); }
public void Modify(AppointmentTable entity) { _context.Appointments.Attach(entity); _context.Entry(entity).State = EntityState.Modified; }
public void Remove(AppointmentTable entity) { _repo.Remove(entity); }
public void Modify(AppointmentTable entity) { _repo.Modify(entity); }
public int Add(AppointmentTable entity) { return(_repo.Add(entity)); }
protected void makeAppointmentButton_Click(object sender, EventArgs e) { int userID = 0; TGDBEntities dbconP = new TGDBEntities(); var patUser = (from x in dbconP.PatientTables where x.PatientUserName == User.Identity.Name select x).First(); userID = patUser.PatientId; //enter selections into variables DateTime newAppDate = Convert.ToDateTime(dateSelectionCalendar.SelectedDate); TimeSpan newAppTime = new TimeSpan(Convert.ToInt32(hourDropDownList.SelectedValue), Convert.ToInt32(minuteDropDownList.SelectedValue), 0); string newAppReason = reasonTextBox.Text; string newAppDoctorName = doctorDropDownList.SelectedItem.Value; TGDBEntities dbconD = new TGDBEntities(); var newAppDoc = (from x in dbconD.DoctorTables where x.Name == newAppDoctorName select x).First(); int newAppDoctor = newAppDoc.DoctorId; //verify input and create new Appointment //verify date is in the future if (newAppDate <= DateTime.Today) { confirmationLabel.Text = "Please schedule your appointment for a future date."; } else { //date and time is free for patient and doctor TGDBEntities dbconA = new TGDBEntities(); var existApp = (from x in dbconA.AppointmentTables where x.AppointmentDate == newAppDate select x).FirstOrDefault(); TGDBEntities dbconA2 = new TGDBEntities(); var existAppDoc = (from x in dbconA2.AppointmentTables where x.DoctorId == newAppDoctor select x).FirstOrDefault(); if (existApp != null) //there is already an appointment on the selected date { if (existApp.PatientId == userID) //the appointment belongs to the patient/user { if (existApp.AppointmentTime == newAppTime) //the appointment is for the same time { confirmationLabel.Text = "You already have an appointment for that day and time, please select another day or time to make your appointment."; } } if (existAppDoc != null) //the appointment belongs to the selected doctor { if (existAppDoc.AppointmentTime == newAppTime) //appointment is for the same time { confirmationLabel2.Text = "The selected doctor already has an appointment for that day and time, please select another day or time, or a different doctor to make your appointment."; } } } else //there is not an existing appointment for the selected date, so create appointment { AppointmentTable newAppointment = new AppointmentTable(); //add data to newAppointment newAppointment.AppointmentDate = newAppDate; newAppointment.AppointmentTime = newAppTime; newAppointment.Description = newAppReason; newAppointment.DoctorId = newAppDoctor; newAppointment.PatientId = userID; //add newAppointment to the Table dbcon = new TGDBEntities(); dbcon.AppointmentTables.Add(newAppointment); dbcon.SaveChanges(); //clear form dateSelectionCalendar.SelectedDates.Clear(); hourDropDownList.SelectedIndex = -1; minuteDropDownList.SelectedIndex = -1; hospitalDropDownList.SelectedIndex = -1; departmentDropDownList.Items.Clear(); doctorDropDownList.Items.Clear(); reasonTextBox.Text = ""; //confirm appointment confirmationLabel.Text = "Appointment was successfully created!"; confirmationLabel2.Text = "We will see you on " + newAppDate.ToShortDateString() + " at " + newAppTime + " for your appointment with " + newAppDoctorName + " for " + newAppReason; } } }
protected void submitBtn_Click(object sender, EventArgs e) { DateTime dateTime; if (DropDownList1.Items.Count != 0) { dateTime = DateTime.ParseExact(DropDownList1.SelectedItem.Value, "hh:mm tt", CultureInfo.InvariantCulture); } else { return; } string role = check_role(); NewBDcon(); dbconDate.StudentTables.Load(); dbconDate.UserTables.Load(); dbconDate.AdvisorTables.Load(); dbconDate.AppointmentTables.Load(); dbconDate.MessagesTables.Load(); TimeSpan span = dateTime.TimeOfDay; string userName = User.Identity.Name; int advisor, student; if ("advisor" == role) { advisor = (from advisors in dbconDate.AdvisorTables.Local where advisors.AdvisorUserName == userName select advisors.AdvisorID).First(); student = Convert.ToInt32(StudentsView.SelectedRow.Cells[1].Text); } else { advisor = (from students in dbconDate.StudentTables.Local where students.StudentUserName == userName select students.StudentAdvisorID).First(); student = (from students in dbconDate.StudentTables.Local where students.StudentUserName == userName select students.StudentID).First(); } AppointmentTable entry = new AppointmentTable { AdvisorID = advisor, AppointmentDate = Calendar1.SelectedDate, AppointmentReason = TextBox1.Text, StudentID = student, AppointmentTime = span, }; AdvisorTable advisorEntry = dbconDate.AdvisorTables.Find(advisor); StudentTable studentEntry = dbconDate.StudentTables.Find(student); string studentEmail, advisorEmail; if ("advisor" == role) { advisorEmail = (from advisors in dbconDate.AdvisorTables.Local where advisors.AdvisorUserName == userName join user in dbconDate.UserTables.Local on advisors.AdvisorUserName equals user.UserName select user.UserEmail).First(); studentEmail = StudentsView.SelectedRow.Cells[3].Text; } else { studentEmail = (from students in dbconDate.StudentTables.Local where students.StudentUserName == userName join user in dbconDate.UserTables.Local on students.StudentUserName equals user.UserName select user.UserEmail).First(); advisorEmail = (from students in dbconDate.StudentTables.Local where students.StudentUserName == userName join advisors in dbconDate.AdvisorTables.Local on students.StudentAdvisorID equals advisors.AdvisorID join user in dbconDate.UserTables.Local on advisors.AdvisorUserName equals user.UserName select user.UserEmail).First(); } DateTime holdTime = DateTime.Today.Add(span); string displayTime = holdTime.ToString("hh:mm tt"); string emailMessage = "Appointment date and Time: " + Calendar1.SelectedDate.ToShortDateString() + " " + displayTime + " \nAppointment Reason: " + TextBox1.Text; MessagesTable message; if ("advisor" == role) { message = new MessagesTable { EmailTime = DateTime.Now.TimeOfDay, EmailDate = DateTime.Today, EmailTo = studentEmail, EmailFrom = advisorEmail, EmailText = emailMessage }; } else { message = new MessagesTable { EmailTime = DateTime.Now.TimeOfDay, EmailDate = DateTime.Today, EmailTo = advisorEmail, EmailFrom = studentEmail, EmailText = emailMessage }; } dbconDate.MessagesTables.Add(message); dbconDate.SaveChanges(); dbconDate.AppointmentTables.Add(entry); dbconDate.SaveChanges(); Response.Redirect(ResolveUrl("Student_Home.aspx")); }
public int Add(AppointmentTable entity) { _context.Appointments.Add(entity); return(entity.Identifier); }
public void Remove(AppointmentTable entity) { _context.Appointments.Remove(entity); }