public static void SetNotDeleted(int note_id, int un_deleted_by) { Note note = NoteDB.GetByID(note_id); NoteHistoryDB.Insert(note.NoteID, note.NoteType.ID, note.BodyPart.ID, note.Text, note.DateAdded, note.DateModified, note.DateDeleted, note.AddedBy == null ? -1 : note.AddedBy.StaffID, note.ModifiedBy == null ? -1 : note.ModifiedBy.StaffID, note.DeletedBy == null ? -1 : note.DeletedBy.StaffID, note.Site == null ? -1 : note.Site.SiteID); string sql = "UPDATE Note SET date_deleted = NULL, deleted_by = NULL, date_modified = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',modified_by = " + un_deleted_by + " WHERE note_id = " + note_id.ToString(); DBBase.ExecuteNonResult(sql); }
public static void Update(int note_id, DateTime date_added, int modified_by, int note_type_id, int body_part_id, int medical_service_type_id, string text, int site_id) { Note note = NoteDB.GetByID(note_id); NoteHistoryDB.Insert(note.NoteID, note.NoteType.ID, note.BodyPart.ID, note.Text, note.DateAdded, note.DateModified, note.DateDeleted, note.AddedBy == null ? -1 : note.AddedBy.StaffID, note.ModifiedBy == null ? -1 : note.ModifiedBy.StaffID, note.DeletedBy == null ? -1 : note.DeletedBy.StaffID, note.Site == null ? -1 : note.Site.SiteID); text = text.Replace("'", "''"); string sql = "UPDATE Note SET note_type_id = " + note_type_id + ",body_part_id = " + (body_part_id == -1 ? "NULL" : body_part_id.ToString()) + ",medical_service_type_id = " + (medical_service_type_id == -1 ? "NULL" : medical_service_type_id.ToString()) + ",date_added = '" + date_added.ToString("yyyy-MM-dd HH:mm:ss") + "'" + ",text = '" + text + "',date_modified = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',modified_by = " + modified_by + ",site_id = " + (site_id == -1 ? "NULL" : site_id.ToString()) + " WHERE note_id = " + note_id.ToString(); DBBase.ExecuteNonResult(sql); }
private Note GetFormNote() { try { string id = Request.QueryString["id"]; return((id == null || !Regex.IsMatch(id, @"^\d+$")) ? null : NoteDB.GetByID(Convert.ToInt32(id))); } catch (Exception ex) { return(null); } }
protected void Send() { string[] attachments = null; try { // Output.Text = FreeTextBox1.Text; if (txtEmailTo.Text.Trim().Length == 0) { Page.Form.DefaultFocus = txtSubject.ClientID; throw new CustomMessageException("Please enter an email address to send to"); } if (!Utilities.IsValidEmailAddresses(txtEmailTo.Text.Trim(), false)) { Page.Form.DefaultFocus = txtSubject.ClientID; throw new CustomMessageException("Please enter valid email address(es) to send to"); } if (txtSubject.Text.Trim().Length == 0) { Page.Form.DefaultFocus = txtSubject.ClientID; throw new CustomMessageException("Please enter an email subject"); } string to = txtEmailTo.Text; string subject = txtSubject.Text; string message = FreeTextBox1.Text; attachments = GetAttachments(new System.Web.UI.HtmlControls.HtmlInputFile[] { inpAttachment1, inpAttachment2, inpAttachment3 }); // make sure org and patient selected if (txtUpdatePatientID.Text.Length == 0) { throw new CustomMessageException("Please select a patient."); } //if (txtUpdateOrganisationID.Text.Length == 0) //--- checking in javascript .. cuz can be blank and use site info in place of org info // throw new CustomMessageException("Please select an organisation."); Letter letter = null; string sourchTemplatePath = null; if (lstLetters.GetSelectedIndices().Length > 0) { // get letter and make sure it exists letter = LetterDB.GetByID(Convert.ToInt32(lstLetters.SelectedValue)); sourchTemplatePath = letter.GetFullPath(Convert.ToInt32(Session["SiteID"])); if (!File.Exists(sourchTemplatePath)) { throw new CustomMessageException("File doesn't exist."); } } // get list of selected notes! ArrayList list = new ArrayList(); foreach (RepeaterItem item in lstNotes.Items) { if (((CheckBox)item.FindControl("chkUseNote")).Checked) { Label lblNoteID = (Label)item.FindControl("lblNoteID"); Note note = NoteDB.GetByID(Convert.ToInt32(lblNoteID.Text)); list.Add(Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + "Treatment Note (" + note.DateAdded.ToString("dd-MM-yyyy") + "):" + Environment.NewLine + Environment.NewLine + ((Label)item.FindControl("lblOriginalText")).Text); } } string[] notes = (string[])list.ToArray(typeof(string)); string tmpFinalFileName = null; if (letter != null) { tmpFinalFileName = Letter.CreateLetterAndReturnTempFile( Letter.FileFormat.PDF, SiteDB.GetByID(Convert.ToInt32(Session["SiteID"])), letter.LetterID, txtUpdateOrganisationID.Text == "" ? 0 : Convert.ToInt32(txtUpdateOrganisationID.Text), Convert.ToInt32(txtUpdatePatientID.Text), Convert.ToInt32(Session["StaffID"]), Request.QueryString["booking"] == null ? -1 : Convert.ToInt32(Request.QueryString["booking"]), -1, 1, notes, true, 1); if (attachments == null) { attachments = new string[] { } } ; string[] newAttachments = new string[attachments.Length + 1]; newAttachments[0] = tmpFinalFileName; Array.Copy(attachments, 0, newAttachments, 1, attachments.Length); attachments = newAttachments; } Emailer.SimpleEmail( (string)Session["SiteName"], to, subject, message, true, attachments, null); //RemoveDraft(); SetErrorMessage("Email Sent!"); } catch (CustomMessageException cmEx) { SetErrorMessage(cmEx.Message); } catch (Exception ex) { SetErrorMessage("", ex.ToString()); } finally { if (attachments != null) { foreach (string file in attachments) { System.IO.File.Delete(file); } } } }
protected void btnPrint_Click(object sender, EventArgs e) { try { //ScriptManager.RegisterClientScriptBlock(this, GetType(), "fancyBox", "alert('a');", true); int letterPrintHistorySendMethodID = 1; // send by mail // make sure org and patient selected if (txtUpdatePatientID.Text.Length == 0) { throw new CustomMessageException("Please select a patient."); } //if (txtUpdateOrganisationID.Text.Length == 0) //--- checking in javascript .. cuz can be blank and use site info in place of org info // throw new CustomMessageException("Please select an organisation."); if (lstLetters.GetSelectedIndices().Length == 0) { throw new CustomMessageException("Please select a letter."); } // get letter and make sure it exists Letter letter = LetterDB.GetByID(Convert.ToInt32(lstLetters.SelectedValue)); string sourchTemplatePath = letter.GetFullPath(Convert.ToInt32(Session["SiteID"])); if (!File.Exists(sourchTemplatePath)) { throw new CustomMessageException("File doesn't exist."); } // get list of selected notes! ArrayList list = new ArrayList(); foreach (RepeaterItem item in lstNotes.Items) { if (((CheckBox)item.FindControl("chkUseNote")).Checked) { Label lblNoteID = (Label)item.FindControl("lblNoteID"); Note note = NoteDB.GetByID(Convert.ToInt32(lblNoteID.Text)); list.Add(Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + "Treatment Note (" + note.DateAdded.ToString("dd-MM-yyyy") + "):" + Environment.NewLine + Environment.NewLine + ((Label)item.FindControl("lblOriginalText")).Text); } } string[] notes = (string[])list.ToArray(typeof(string)); int bookingID = -1; if (Request.QueryString["booking"] != null) { bookingID = Convert.ToInt32(Request.QueryString["booking"]); } if (Request.QueryString["bookingpatient"] != null) { BookingPatient bp = BookingPatientDB.GetByID(Convert.ToInt32(Request.QueryString["bookingpatient"])); bookingID = bp.Booking.BookingID; } Letter.SendLetter(Response, Letter.FileFormat.Word, // .pdf SiteDB.GetByID(Convert.ToInt32(Session["SiteID"])), letter.LetterID, txtUpdateOrganisationID.Text == "" ? 0 : Convert.ToInt32(txtUpdateOrganisationID.Text), Convert.ToInt32(txtUpdatePatientID.Text), Convert.ToInt32(Session["StaffID"]), bookingID, -1, 1, notes, true, letterPrintHistorySendMethodID); } catch (CustomMessageException cmEx) { SetErrorMessage(cmEx.Message); return; } }