public static Hashtable GetMostRecentRecallHashByPatients(int[] patient_ids) { if (patient_ids == null || patient_ids.Length == 0) { return(new Hashtable()); } string sql = JoinedSql + @" --SELECT * from LetterPrintHistory lph WHERE lph.patient_id in (" + string.Join(",", patient_ids) + @") and lph.letter_print_history_id = ( SELECT TOP 1 letter_print_history_id FROM LetterPrintHistory lph2 INNER JOIN Letter l ON lph2.letter_id = l.letter_id WHERE lph2.patient_id = lph.patient_id AND l.letter_type_id = 390 ORDER BY lph2.date DESC )"; Hashtable hash = new Hashtable(); DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0]; for (int i = 0; i < tbl.Rows.Count; i++) { LetterPrintHistory lph = LoadAll(tbl.Rows[i]); hash[lph.Patient.PatientID] = lph; } return(hash); }
protected void GrdLetterPrintHistory_RowDataBound(object sender, GridViewRowEventArgs e) { DataTable dt = Session["letterprinthistory_data"] as DataTable; bool tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value); if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow) { Label lblId = (Label)e.Row.FindControl("lblId"); DataRow[] foundRows = dt.Select("lph_letter_print_history_id=" + lblId.Text); DataRow thisRow = foundRows[0]; LetterPrintHistory letterPrintHistory = LetterPrintHistoryDB.LoadAll(thisRow); Button btnRetrieveFlatFile = (Button)e.Row.FindControl("btnRetrieveFlatFile"); if (btnRetrieveFlatFile != null && btnRetrieveFlatFile.CssClass != "hiddencol") { string historyDir = Letter.GetLettersHistoryDirectory(thisRow["lph_organisation_id"] == DBNull.Value ? 0 : Convert.ToInt32(thisRow["lph_organisation_id"])); string filePath = historyDir + letterPrintHistory.LetterPrintHistoryID + System.IO.Path.GetExtension(letterPrintHistory.DocName); string filePathPDF = historyDir + letterPrintHistory.LetterPrintHistoryID + ".pdf"; btnRetrieveFlatFile.Visible = System.IO.File.Exists(filePath) || System.IO.File.Exists(filePathPDF); } HyperLink lnkBookingSheetForPatient = (HyperLink)e.Row.FindControl("lnkBookingSheetForPatient"); if (lnkBookingSheetForPatient != null) { if (thisRow["lph_booking_id"] == DBNull.Value) { lnkBookingSheetForPatient.Visible = false; } else { int booking_id = Convert.ToInt32(thisRow["lph_booking_id"]); Booking booking = BookingDB.GetByID(booking_id); lnkBookingSheetForPatient.NavigateUrl = booking.GetBookingSheetLinkV2(); } } Utilities.AddConfirmationBox(e); if ((e.Row.RowState & DataControlRowState.Edit) > 0) { Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow); } } if (e.Row.RowType == DataControlRowType.Footer) { } }
protected void GrdLetterPrintHistory_RowCommand(object sender, GridViewCommandEventArgs e) { //if (e.CommandName.Equals("Insert")) //{ // DropDownList ddlTitle = (DropDownList)GrdLetterPrintHistory.FooterRow.FindControl("ddlNewTitle"); // TextBox txtFirstname = (TextBox)GrdLetterPrintHistory.FooterRow.FindControl("txtNewFirstname"); // TextBox txtMiddlename = (TextBox)GrdLetterPrintHistory.FooterRow.FindControl("txtNewMiddlename"); // TextBox txtSurname = (TextBox)GrdLetterPrintHistory.FooterRow.FindControl("txtNewSurname"); // DropDownList ddlGender = (DropDownList)GrdLetterPrintHistory.FooterRow.FindControl("ddlNewGender"); // TextBox txtDOB = (TextBox)GrdLetterPrintHistory.FooterRow.FindControl("txtNewDOB"); // CheckBox chkIsDeceased = (CheckBox)GrdLetterPrintHistory.FooterRow.FindControl("chkNewIsDeceased"); // string[] dobParts = txtDOB.Text.Trim().Split(new char[] { '-' }); // DateTime dob = new DateTime(Convert.ToInt32(dobParts[2]), Convert.ToInt32(dobParts[1]), Convert.ToInt32(dobParts[0])); // Staff loggedInStaff = StaffDB.GetByID(Convert.ToInt32(Session["StaffID"])); // int person_id = PersonDB.Insert(loggedInStaff.Person.PersonID, ddlTitle.SelectedValue, Utilities.FormatName(txtFirstname.Text), Utilities.FormatName(txtMiddlename.Text), Utilities.FormatName(txtSurname.Text), ddlGender.SelectedValue, dob); // LetterPrintHistoryDB.Insert(person_id, chkIsDeceased.Checked, "", ""); // FillGrid(); //} if (e.CommandName.Equals("RetrieveLetterDB")) { int index = Int32.Parse((string)e.CommandArgument); Label lblId = (Label)GrdLetterPrintHistory.Rows[index].FindControl("lblId"); LetterFile letterFile = LetterPrintHistoryDB.GetLetterFile(Convert.ToInt32(lblId.Text)); if (letterFile == null) { throw new CustomMessageException("No file with selected ID"); } Letter.DownloadDocument(Response, letterFile.Contents, letterFile.Name); } if (e.CommandName.Equals("RetrieveLetterFlatFile")) { int index = Int32.Parse((string)e.CommandArgument); Label lblId = (Label)GrdLetterPrintHistory.Rows[index].FindControl("lblId"); LetterPrintHistory letterPrintHistory = LetterPrintHistoryDB.GetByID(Convert.ToInt32(lblId.Text)); DataTable dt = Session["letterprinthistory_data"] as DataTable; DataRow[] foundRows = dt.Select("lph_letter_print_history_id=" + lblId.Text); DataRow thisRow = foundRows[0]; string historyDir = Letter.GetLettersHistoryDirectory(thisRow["lph_organisation_id"] == DBNull.Value ? 0 : Convert.ToInt32(thisRow["lph_organisation_id"])); string filePath = historyDir + letterPrintHistory.LetterPrintHistoryID + System.IO.Path.GetExtension(letterPrintHistory.DocName); string filePathPDF = historyDir + letterPrintHistory.LetterPrintHistoryID + ".pdf"; if (!System.IO.File.Exists(filePath) && !System.IO.File.Exists(filePathPDF)) { throw new CustomMessageException("No file with selected ID"); } bool isPDF = System.IO.File.Exists(filePathPDF); byte[] fileContents = isPDF ? System.IO.File.ReadAllBytes(filePathPDF) : System.IO.File.ReadAllBytes(filePath); Letter.DownloadDocument(Response, fileContents, isPDF ? System.IO.Path.ChangeExtension(letterPrintHistory.DocName, ".pdf") : letterPrintHistory.DocName); } }
public static LetterPrintHistory LoadAll(DataRow row) { LetterPrintHistory lph = Load(row, "lph_"); lph.Letter = LetterDB.Load(row, "letter_"); lph.SendMethod = new IDandDescr(Convert.ToInt32(row["lph_send_method_letter_print_history_send_method_id"]), Convert.ToString(row["lph_send_method_descr"])); lph.Letter.LetterType = IDandDescrDB.Load(row, "lettertype_letter_type_id", "lettertype_descr"); if (row["letterorg_organisation_id"] != DBNull.Value) { lph.Letter.Organisation = OrganisationDB.Load(row, "letterorg_"); } if (row["organisation_organisation_id"] != DBNull.Value) { lph.Organisation = OrganisationDB.Load(row, "organisation_"); } if (row["patient_patient_id"] != DBNull.Value) { lph.Patient = PatientDB.Load(row, "patient_"); } if (row["patient_patient_id"] != DBNull.Value) { lph.Patient.Person = PersonDB.Load(row, "person_patient_"); lph.Patient.Person.Title = IDandDescrDB.Load(row, "title_patient_title_id", "title_patient_descr"); } if (row["staff_staff_id"] != DBNull.Value) { lph.Staff = StaffDB.Load(row, "staff_"); } if (row["staff_staff_id"] != DBNull.Value) { lph.Staff.Person = PersonDB.Load(row, "person_staff_"); lph.Staff.Person.Title = IDandDescrDB.Load(row, "title_staff_title_id", "title_staff_descr"); } if (row["regref_register_referrer_id"] != DBNull.Value) { lph.RegisterReferrer = RegisterReferrerDB.Load(row, "regref_"); } if (row["regreforg_organisation_id"] != DBNull.Value) { lph.RegisterReferrer.Organisation = OrganisationDB.Load(row, "regreforg_"); } if (row["referrer_referrer_id"] != DBNull.Value) { lph.RegisterReferrer.Referrer = ReferrerDB.Load(row, "referrer_"); } if (row["referrer_referrer_id"] != DBNull.Value) { lph.RegisterReferrer.Referrer.Person = PersonDB.Load(row, "person_referrer_"); lph.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(row, "title_referrer_title_id", "title_referrer_descr"); } if (row["lph_health_card_action_id"] != DBNull.Value) { lph.HealthCardAction = HealthCardActionDB.Load(row, "hca_"); lph.HealthCardAction.healthCardActionType = IDandDescrDB.Load(row, "hcat_health_card_action_type_id", "hcat_descr"); lph.HealthCardAction.HealthCard = HealthCardDB.Load(row, "hc_"); } if (row["lph_booking_id"] != DBNull.Value) { lph.Booking = BookingDB.Load(row, "booking_"); } return(lph); }