protected void Page_Load(object sender, EventArgs e) { // Hide database error on page load DataBaseError.Visible = false; // Enable submit button on page load SubmitButton.Enabled = true; // Redirect to login if not logged in if (Session[Global.user] == null) { Response.Redirect("Login.aspx"); } // If logged in attempt to pull data from database try { List <Visit> visits = VisitUtility.GetVisits(); VisitGridView.DataSource = visits; VisitGridView.DataBind(); } // If exception caught show database error and // disable submit button catch (Exception) { DataBaseError.Visible = true; SubmitButton.Enabled = false; } }
// Find and bind search results to grid view based // on radio button choice protected void SearchClick(object sender, EventArgs e) { List <Visit> visits = VisitUtility.GetVisits(); List <Visit> searchReturn = new List <Visit>(); string choice = radiolist1.SelectedItem.Text; // Hide error message NotFoundError.Visible = false; // If name selected search for name if (choice == "Name") { foreach (Visit visit in visits) { if (PatientUtility.GetPatient(visit.patientId). name.ToString().Contains(Search.Text)) { searchReturn.Add(visit); } } } // If date of visit selected search for date if (choice == "Date of Visit") { foreach (Visit visit in visits) { if (visit.date.ToString().Contains(Search.Text)) { searchReturn.Add(visit); } } } // If date of discharge selected search for date if (choice == "Date of Discharge") { foreach (Visit visit in visits) { if (visit.discharge.ToString().Contains(Search.Text)) { searchReturn.Add(visit); } } } // If results found bind to grid view if (searchReturn.Any()) { VisitGridView.DataSource = searchReturn; VisitGridView.DataBind(); } // If no results found show error else { NotFoundError.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["Permission"] == null) { Response.Redirect("~/Default.aspx"); } else if (Session["Permission"].Equals("9")) { SetLabels(); lbl_error.Text = ""; VisitGridView.DataBind(); MonthVisitGridView.DataBind(); } else { Response.Redirect("~/Default.aspx"); } }
protected void VisitDetailsFormView_ItemDeleted(object sender, FormViewDeletedEventArgs e) { VisitGridView.DataBind(); //ChildrenServedFormView.DataBind(); }