protected void Button1_Click(object sender, EventArgs e) { int i = 0; if (int.TryParse(IDTextBox.Text, out i) == true) { try { int found = ConnectionClass.IsPatientAppointmentFound(i); Session["PatientID"] = i; errorLabel.ForeColor = System.Drawing.Color.Green; errorLabel.Text = "Records Found"; if (found > 0) { errorLabel.ForeColor = System.Drawing.Color.Green; errorLabel.Text = "Records Found after Query"; Response.Redirect("ViewPatientsAppointmentPage.aspx"); } if (found == 0) { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "No Appointment Records Found"; } } catch { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Search Failed"; } } else { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "No Records Found"; } }
protected void submitBtn_Click(object sender, EventArgs e) { String firstName = firstNameTxtBox.Text; String lastName = lastNameTxtBox.Text; String address = addressTxtBox.Text; String phoneNumber = phoneTxtBox.Text; int wardId = int.Parse(wardList.SelectedValue); //Tried using Entity Framework but didnt worked //Ward ward = context.Wards.FirstOrDefault(x => x.WardID == wardId); //ward.Patients.Add(new Patient //{ // FirstName = firstName, // LastName = lastName, // Address = address, // PhoneNumber = phoneNumber //}); Patient newPatient = new Patient { FirstName = firstName, LastName = lastName, Address = address, PhoneNumber = phoneNumber, Ward = wardId }; try { //Means the insertion is done if (ConnectionClass.addPatient(newPatient) == 1) { errorMessageDiv.Visible = true; errorMessageDiv.Attributes["class"] = "alert alert-success"; errorMessage.Text = "Patient Is Registered"; } } catch (NullReferenceException ex) { errorMessageDiv.Visible = true; errorMessage.Text = ex.Message; } }
protected void Button1_Click(object sender, EventArgs e) { //Holds employee id from textbox int patientID = 0; //Holds patient id from textbox int employeeID = 0; int reportID = (int)Session["ReportID"]; //the employee ID variable if (int.TryParse(EmployeeIDTextBox.Text, out employeeID) == true && int.TryParse(PatientIDTextBox.Text, out patientID) && String.IsNullOrWhiteSpace(PrescriptionTextBox.Text) == false && String.IsNullOrWhiteSpace(DiagnosisTextBox.Text) == false) { try { ConnectionClass.UpdateReport(Convert.ToInt32(EmployeeIDTextBox.Text), Convert.ToInt32(PatientIDTextBox.Text), DiagnosisTextBox.Text, PrescriptionTextBox.Text, reportID); errorLabel.ForeColor = System.Drawing.Color.Green; errorLabel.Text = "Report Was Updated Successfully"; } catch { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Report Could not Be Updated"; } } else { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Report Could not Be Updated, Please fill out all fields"; } }
protected void Button1_Click(object sender, EventArgs e) { int i = 0; if (int.TryParse(IDTextBox.Text, out i) == true) { try { int found = ConnectionClass.IsRecordFound(i); Session["ReportID"] = i; if (found > 0) { Response.Redirect("UpdateReportPage.aspx"); errorLabel.Text = "Records Found after Query"; } if (found == 0) { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "No Medical Reports Found"; } } catch { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Search Failed"; } } else { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "No Records Found"; } }
/* * protected override void OnPreInit(EventArgs e) * { * int position = 0; * string variable = "Login to continue"; * //Checks which user is entering the system and chooses the master pages for them * //checks if the session is null or not * if (Session.Count > 0) * * * { * position = ((Employee)Session["employee"]).EmployeeType.Value; * if (position == 5) * { * MasterPageFile = "~/Receptionist.Master"; * } * else if (position == 4) * { * MasterPageFile = "~/Laboratory.Master"; * } * else if (position == 3) * { * MasterPageFile = "~/Nurse.Master"; * } * else if (position == 2) * { * MasterPageFile = "~/Pharmacist.Master"; * } * else if (position == 1) * { * MasterPageFile = "~/Doctor.Master"; * } * else * { * MasterPageFile = "~/Site1.Master"; * } * } * else * { * ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + variable + "');", true); * Response.Redirect("LoginPage.aspx"); * } * } */ //Event handler for the create apointment button protected void Button1_Click(object sender, EventArgs e) { //DB context var context = new HospitalDBEntities(); //Holds employee id from textbox int i = 0; //Holds patient id from textbox int p = 0; //the employee ID variable if (int.TryParse(EmployeeTextBox.Text, out i) == true && int.TryParse(PatientTextBox.Text, out p) && Begin_Calendar.SelectedDate != DateTime.MinValue) { i = Convert.ToInt32(EmployeeTextBox.Text); p = Convert.ToInt32(PatientTextBox.Text); //the patient //One Appointment Appointment appointment = context.Appointments.FirstOrDefault(x => x.Employee == i); Employee employee1 = context.Employees.FirstOrDefault(x => x.EmployeeID == i); // Query for all appointments with names starting with employee ID var appoint = from b in context.Appointments where b.Employee.Value.Equals(i) select b; //gets patient Patient patient = context.Patients.FirstOrDefault(x => (x.PatientID == p)); //converting all the appointments found to a list List <Appointment> listOfAppointments = appoint.ToList(); DateTime startCalendarValue = Begin_Calendar.SelectedDate; Label2.Text = listOfAppointments.Count.ToString(); //Value will be tue if appointment is valid if (appoint.Count() != 0 && patient != null) { //Dispose of db Context context.Dispose(); //Adds the appointment to the database Appointment appointmentToBeAdded = new Appointment(); string start = startCalendarValue.ToShortDateString() + " " + BeginTime.Text; appointmentToBeAdded.StartTime = start; appointmentToBeAdded.Patient = p; appointmentToBeAdded.Employee = i; appointmentToBeAdded.Diagnosis = " "; appointmentToBeAdded.Prescription = " "; try { ConnectionClass.AddSchedule(appointmentToBeAdded); errorLabel.ForeColor = System.Drawing.Color.Green; errorLabel.Text = "Appointment Added Successfully"; } catch (Exception f) { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Appointment Could not be Added"; } } }//End of if else { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Appointment Could not Be Added, Please fill out all fields"; } }