using framework_business; using framework_library; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.IO; using System.Reflection; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using Telerik.Web.UI; public partial class controls_admin_notes : System.Web.UI.UserControl, IControlBase { #region methods /// /// Method to Bind Note Data /// private void BindNoteData() { try { //Setup heading if (utils.verifySession("noteEntityId") && utils.verifySession("noteModuleId")) { int moduleId = int.Parse(Session["noteModuleId"].ToString()); int entityId = int.Parse(Session["noteEntityId"].ToString()); int typeId = 0; string fieldName = String.Empty; if (utils.verifySession("fieldNameNote")) fieldName = Session["fieldNameNote"].ToString(); pNums.Module mod = (pNums.Module)Enum.ToObject(typeof(pNums.Module), moduleId); switch (mod) { case pNums.Module.Surface: Session["surfaceItem"] = (oSurfaceItem)xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceItem), "recId", entityId.ToString())[0]; Session["surface"] = (oSurface)xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "recId", ((oSurfaceItem)Session["surfaceItem"]).surfaceId.ToString())[0]; //lblEntityName.Text = ((oSurface)Session["surface"]).surface; //DataTable surfaceItemGridData = xData.GetSurfaceItemGridData(((oSurface)Session["surface"]).recId,entityId); //dgInfoBar.DataSource = surfaceItemGridData; //dgInfoBar.DataBind(); //dgInfoBar.Visible = true; break; case pNums.Module.Task: oTaskHistory taskHistory = (oTaskHistory)xData.GetTypedByCriteriaSpecific("recId", typeof(oTaskHistory), "recId", entityId.ToString())[0]; oTask task = (oTask)xData.GetTypedByCriteriaSpecific("recId", typeof(oTask), "recId", taskHistory.taskId.ToString())[0]; Session["task"] = task; break; default: break; } /* CVH 2016-09-06 Merging TSP */ DataTable NoteList = new DataTable(); if (mod == pNums.Module.Task) { List list = new List(); oDynamicParam param1 = new oDynamicParam(); param1.paramDisplayName = "moduleId"; param1.paramObject = moduleId; list.Add(param1); oDynamicParam param2 = new oDynamicParam(); param2.paramDisplayName = "taskId"; param2.paramObject = ((oTask)Session["task"]).recId; list.Add(param2); NoteList = xData.GetTypedTableByProc("recId", typeof(oNote), "sp_TaskNotes", list); } else { if (fieldName != String.Empty) { if (typeId > 0) { NoteList = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oNote), "moduleId,entityId,typeId,fieldName", moduleId + "," + entityId + "," + typeId + "," + fieldName, "recId DESC"); } else { NoteList = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oNote), "moduleId,entityId,fieldName", moduleId + "," + entityId + "," + fieldName, "recId DESC"); } } else { if (typeId > 0) { NoteList = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oNote), "moduleId,entityId,typeId", moduleId + "," + entityId + "," + typeId, "recId DESC"); } else { NoteList = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oNote), "moduleId,entityId", moduleId + "," + entityId, "recId DESC"); } } } oSetup setup = (oSetup)(xData.GetTypedByCriteriaSpecific("recId", typeof(oSetup), "isActive", "1")[0]); NoteList.Columns.Add("userNameSaved"); NoteList.Columns.Add("dataSaveFormatted"); NoteList.Columns.Add("collapseId"); NoteList.Columns.Add("collapseHeadId"); ArrayList userList = xData.GetTypedCollection("recId", typeof(oUser)); foreach (DataRow row in NoteList.Rows) { int userId = (int)row["userIdSaved"]; foreach (oUser usr in userList) { if (usr.recId == userId) row["userNameSaved"] = usr.name + " " + usr.surname; } row["dataSaveFormatted"] = utils.fixDate(row["dateSaved"].ToString()); row["collapseId"] = "collapse" + row["recId"].ToString(); row["collapseHeadId"] = "collapseHead" + row["recId"].ToString(); int noteTypeId = int.Parse(row["typeId"].ToString()); /* CVH 2016-04-21 Hard code to "Patient". Only 1 surface app in TSP. In Palette replace with Surface.surface */ string title = row["title"].ToString(); string caption = row["caption"].ToString(); if (setup.code == "SHOU-1") title = title.Replace("Surface Item", "Patient"); if (noteTypeId == (int)pNums.NoteType.Statement) caption = "A statement was created."; else if (setup.code == "SHOU-1") caption = caption.Replace("surface item details", "patient profile details").Replace("surface item", "patient profile"); row["title"] = title; row["caption"] = caption; } rptNotes.DataSource = NoteList; rptNotes.DataBind(); } } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["note"]); Response.Redirect("/error", false); } } private string BuildSurfaceGridHeaderFields(ArrayList fields) { string result = String.Empty; StringBuilder fieldBuilder = new StringBuilder(); try { foreach (oSurfaceField field in fields) { if (field.surfaceFieldTypeId != pNums.FieldType.Tab.GetHashCode() && field.surfaceFieldTypeId != pNums.FieldType.Group.GetHashCode() && field.isGrid) //JasR 2016-01-27 - if something is hidden and on grid - then it shows on the gird if (field.isHidden && !field.isGrid) { fieldBuilder.AppendLine("" + field.surfaceFieldDisplay + ""); } else { fieldBuilder.AppendLine("" + field.surfaceFieldDisplay + ""); // fieldBuilder.AppendLine("" + field.surfaceFieldDisplay + ""); } } result = fieldBuilder.ToString(); } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["note"]); Response.Redirect("/error", false); } return result; } private string BuildSurfaceGridDataFields(ArrayList fields) { string result = String.Empty; StringBuilder fieldBuilder = new StringBuilder(); try { foreach (oSurfaceField field in fields) { if (field.surfaceFieldTypeId != pNums.FieldType.Tab.GetHashCode() && field.surfaceFieldTypeId != pNums.FieldType.Group.GetHashCode() && field.isGrid) { fieldBuilder.AppendLine(""); if (field.surfaceFieldTypeId != pNums.FieldType.Checkbox.GetHashCode()) { fieldBuilder.AppendLine(""); } fieldBuilder.AppendLine(""); } } result = fieldBuilder.ToString(); } catch (Exception ex) { exception.HandleException("handler:", MethodBase.GetCurrentMethod().Name, ex, HttpContext.Current.Session["user"]); } return result; } /// /// Method to Bind the slide Order Drop down /// private void BindNoteTypes() { try { DataTable typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oNoteType), "isActive", "1", "noteType"); ddNoteType.DataSource = typeData; ddNoteType.DataTextField = "noteType"; ddNoteType.DataValueField = "recId"; ddNoteType.DataBind(); } catch (Exception ex) { exception.HandleException("Products:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Populate Form Values /// /// private void PopulatePageFormValues(ref oNote _note) { try { chkActive.Checked = _note.isActive; txtTitle.Value = _note.title; txtCaption.Value = _note.caption; if (_note.typeId > 0) ddNoteType.SelectedValue = _note.typeId.ToString(); pNums.Module mod = (pNums.Module)Enum.ToObject(typeof(pNums.Module), _note.moduleId); switch (mod) { case pNums.Module.Surface: break; default: break; } divEditNoteFiles.InnerHtml = ""; if (_note.recId != 0) LoadAttachmentList(divEditNoteFiles, _note.recId); } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Save Form Values /// /// private void SavePageFormValues(ref oNote _note) { try { _note.isActive = chkActive.Checked; _note.title = txtTitle.Value; _note.caption = txtCaption.Value; _note.typeId = int.Parse(ddNoteType.SelectedValue); } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Method to Toggle Panels /// /// private void TogglePanels(string panelName) { switch (panelName) { case "pnlNotePage": pnlNotePage.Visible = true; pnlNoteList.Visible = false; pnlNoteAttachments.Visible = false; btnAttachments.Visible = true; btnNewNote.Visible = true; lblNoteHeading.Text = "History"; break; case "pnlNoteList": pnlNotePage.Visible = false; pnlNoteList.Visible = true; pnlNoteAttachments.Visible = false; btnAttachments.Visible = true; btnNewNote.Visible = true; lblNoteHeading.Text = "History"; break; case "pnlNoteAttachments": pnlNotePage.Visible = false; pnlNoteList.Visible = false; pnlNoteAttachments.Visible = true; btnAttachments.Visible = false; btnNewNote.Visible = false; lblNoteHeading.Text = "History - Files"; break; } //clear result pnlResult.Visible = false; } /// /// Setup Note Screen /// private void SetupNoteScreen() { try { TogglePanels("pnlNoteList"); } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Get's the file type image (.pdf, .xlsx, .jpeg) and returns the icon as a base 64 string that can be used as an image source /// /// /// private string GetFileTypeImage(string fileLocation) { try { string imgSrc = "/images/doc.png"; if (File.Exists(fileLocation)) { System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(fileLocation); System.Drawing.Image img = icon.ToBitmap(); byte[] byteArray = new byte[0]; using (System.IO.MemoryStream stream = new System.IO.MemoryStream()) { img.Save(stream, System.Drawing.Imaging.ImageFormat.Png); stream.Close(); byteArray = stream.ToArray(); } string base64 = Convert.ToBase64String(byteArray); imgSrc = String.Format("data:image/png;base64,{0}", base64); } return imgSrc; } catch (Exception ex) { throw new Exception("Icon conversion to image failed. " + ex.Message); } } private void LoadAttachmentList(HtmlGenericControl divAttachments, int noteId) { StringBuilder formBuilder = new StringBuilder(); ArrayList files = xData.GetTypedByCriteriaSpecific("recId", typeof(oAttachment), "moduleId,entityId", (int)pNums.Module.Notes + "," + noteId.ToString()); if (files.Count > 0) { formBuilder.AppendLine("
"); foreach (oAttachment att in files) { string user = ""; foreach (ovUserShared usr in xData.GetTypedByCriteriaSpecific("recId", typeof(ovUserShared), "recId", att.userIdSaved.ToString())) { user = usr.name; break; } string details = "(" + user + " - " + utils.fixDate(att.dateSaved) + ")"; string fileLocation = ""; string pathLocation = ""; string hyperlink = ""; if (att.typeId == (int)pNums.AttachmentType.Document) { fileLocation = Server.MapPath("~/upload/" + att.folderName + "/file/" + att.fileName); pathLocation = att.sourcePath + "/upload/" + att.folderName + "/file/" + att.fileName; if (!File.Exists(fileLocation)) { fileLocation = fileLocation.Replace("/file", ""); pathLocation = pathLocation.Replace("/file", ""); } hyperlink = "" + att.display + ""; } else { fileLocation = Server.MapPath("~/upload/" + att.folderName + "/image/" + att.fileName); pathLocation = att.sourcePath + "/upload/" + att.folderName + "/image/" + att.fileName; hyperlink = "" + att.display + ""; } formBuilder.AppendLine(hyperlink); } formBuilder.Append("
"); } divAttachments.InnerHtml = formBuilder.ToString(); } #endregion #region events /// /// Event fires from control base /// public void ReloadControl() { try { SetupNoteScreen(); BindNoteData(); } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } public void SaveControlData() { } /// /// Page Load Event /// /// /// protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { BindNoteTypes(); SetupNoteScreen(); } //BindNoteData(); } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["note"]); Response.Redirect("/error", false); } } /// /// New Note Click /// /// /// protected void btnNewNote_Click(object sender, EventArgs e) { try { //show Content Specific TogglePanels("pnlNotePage"); Session["noteId"] = 0; utils.disposeSession("note"); oNote Note = new oNote(); Note.isActive = true; Note.typeId = (int)pNums.NoteType.General; PopulatePageFormValues(ref Note); if (utils.verifySession("noteModuleId")) { int moduleId = int.Parse(Session["noteModuleId"].ToString()); pNums.Module mod = (pNums.Module)Enum.ToObject(typeof(pNums.Module), moduleId); switch (mod) { case pNums.Module.Surface: if (utils.verifySession("surface")) { oSurface surface = (oSurface)Session["surface"]; txtTitle.Value = "Note - " + surface.surface;//not ideal - should rather try and get field that is more specific to the surface item //show Content Specific TogglePanels("pnlNotePage"); } break; case pNums.Module.Task: if (utils.verifySession("task")) { oTask task = (oTask)Session["task"]; txtTitle.Value = "Note for Task: " + task.name; //show Content Specific TogglePanels("pnlNotePage"); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myModal", "$('#modNotes').modal();", true); } break; default: break; } } } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["note"]); Response.Redirect("/error", false); } } /// /// Edit the Note page /// /// /// protected void lnkEdit_Click(object sender, EventArgs e) { oNote _Note = new oNote(); ArrayList noteList = new ArrayList(); try { if (sender.GetType() == typeof(LinkButton)) { int recId = int.Parse(((LinkButton)sender).CommandArgument); if (recId > 0) { Session["noteId"] = recId; //get cat noteList = xData.GetTypedByCriteriaSpecific("recId", typeof(oNote), "recId", recId.ToString()); //enumerate list foreach (oNote note in noteList) { //assign object _Note = note; //populate page form PopulatePageFormValues(ref _Note); Session["note"] = _Note; break; } //show Note Form TogglePanels("pnlNotePage"); } } } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["note"]); Response.Redirect("/error", false); } } /// /// Remove the Note /// /// /// protected void lnkRemove_Click(object sender, EventArgs e) { try { if (sender.GetType() == typeof(LinkButton)) { int recId = int.Parse(((LinkButton)sender).CommandArgument); foreach (oNote note in xData.GetTypedByCriteriaSpecific("recId", typeof(oNote), "recId", recId.ToString())) { //Delete Note record if (xData.DeleteTyped("recId", note.recId.ToString(), typeof(oNote))) { //rebind pages grid BindNoteData(); pnlResult.Visible = true; //display successful result lblResult.Text = "the selected note was deleted successfully."; } break; } } } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["note"]); Response.Redirect("/error", false); } } /// /// Cancel /// /// /// protected void btnCancel_Click(object sender, EventArgs e) { try { Session["noteId"] = 0; utils.disposeSession("note"); //BindNoteData(); //show cat list TogglePanels("pnlNoteList"); } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["note"]); Response.Redirect("/error", false); } } /// /// Save Click /// /// /// protected void btnSave_Click(object sender, EventArgs e) { oNote note = new oNote(); try { if (utils.verifySession("noteEntityId") && utils.verifySession("noteModuleId")) { if (ViewState["newNote"] == null) { if (utils.verifySession("note") && Session["noteId"].ToString() != "0")//update mode { note = (oNote)Session["note"]; } int moduleId = int.Parse(Session["noteModuleId"].ToString()); int entityId = int.Parse(Session["noteEntityId"].ToString()); note.entityId = entityId; note.moduleId = moduleId; string fieldName = String.Empty; if (utils.verifySession("fieldNameNote")) fieldName = Session["fieldNameNote"].ToString(); note.fieldName = fieldName; //save form values SavePageFormValues(ref note); if (note.recId > 0) { note.dateUpdated = DateTime.Now; if (utils.verifySession("user")) { oUser user = (oUser)Session["user"]; note.userIdUpdated = user.recId; } xData.UpdateTyped("recId", note.recId.ToString(), typeof(oNote), note); } else { note.dateSaved = DateTime.Now; if (utils.verifySession("user")) { oUser user = (oUser)Session["user"]; note.userIdSaved = user.recId; } note.recId = xData.SaveTyped("recId", typeof(oNote), note); } if (utils.verifySession("note"))//update mode { utils.disposeSession("note"); } } else { ViewState["newNote"] = null; } BindNoteData(); SetupNoteScreen(); } } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["note"]); Response.Redirect("/error", false); } } /// /// Item Data Bound /// /// /// protected void rptNotes_ItemDataBound(object sender, RepeaterItemEventArgs e) { try { //edit button should only be visible for General type notes LinkButton lnkEdit = e.Item.FindControl("lnkEdit") as LinkButton; HiddenField hfType = e.Item.FindControl("hfType") as HiddenField; if (hfType != null && lnkEdit != null) { if (hfType.Value == pNums.NoteType.General.GetHashCode().ToString()) lnkEdit.Visible = true; else lnkEdit.Visible = false; } if (e.Item.ItemIndex != -1) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { /* CVH 2016-03-09 Set attachments column to not visible if this is a Task note */ if (utils.verifySession("noteModuleId")) { int moduleId = int.Parse(Session["noteModuleId"].ToString()); pNums.Module mod = (pNums.Module)Enum.ToObject(typeof(pNums.Module), moduleId); if (mod == pNums.Module.Task) { HtmlTableCell td = (HtmlTableCell)e.Item.FindControl("tdAttachments"); if (td != null) td.Visible = false; } else { /* CVH 2016-09-06 TSP merge */ //load attachments HtmlGenericControl divNoteAttachments = e.Item.FindControl("divNoteAttachments") as HtmlGenericControl; if (divNoteAttachments != null && lnkEdit != null) { int noteId = int.Parse(lnkEdit.CommandArgument.ToString()); LoadAttachmentList(divNoteAttachments, noteId); } } } } } /* CVH 2016-09-09 There is no "edTemplate", exception thrown when binding grid. Removing code, it's not doing anything at the moment */ //Label lblCaption = e.Item.FindControl("lblCaption") as Label; //if (lblCaption != null) //{ // //lblCaption.Text = Server.HtmlEncode(lblCaption.Text); // RadEditor edTemplate = e.Item.FindControl("edTemplate") as RadEditor; // edTemplate.Content = lblCaption.Text; //} } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Item Created event /// /// /// protected void rptNotes_ItemCreated(object sender, RepeaterItemEventArgs e) { } /// /// Attachment click event /// /// /// protected void lnkAttachments_Click(object sender, EventArgs e) { //setup attachments utils.disposeSession("note"); int itemId = int.Parse(((LinkButton)sender).CommandArgument); ArrayList noteList = new ArrayList(); noteList = xData.GetTypedByCriteriaSpecific("recId", typeof(oNote), "recId", itemId.ToString()); //enumerate list foreach (oNote note in noteList) { Session["note"] = note; break; } Session["moduleId"] = pNums.Module.Notes.GetHashCode(); Session["entityId"] = itemId; string fieldName = String.Empty; if (utils.verifySession("fieldNameNote")) fieldName = Session["fieldNameNote"].ToString(); Session["fieldNameFile"] = fieldName; dynamic attachments = this.Parent.FindControl("attachments"); attachments.ReloadControl(); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myModal", "$('#modAttachments').modal();", true); //Page.ClientScript.RegisterStartupScript(this.GetType(), "myModal", "$('#modAttachments').modal();", true); } /// /// Close button method /// /// /// protected void btnClose_Click(object sender, EventArgs e) { try { //Response.Redirect(Request.Url.AbsoluteUri.Split('?')[0], false); //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myModal", "$('#modAttachments').modal('toggle');", true); } catch (Exception ex) { exception.HandleException("Notes:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } protected void radUploadNotes_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { oAttachment Attachment = new oAttachment(); try { string fieldName = String.Empty; if (utils.verifySession("fieldNameNote")) fieldName = Session["fieldNameNote"].ToString(); if (!utils.verifySession("user")) { Response.Redirect("/home", false); return; } oUser user = (oUser)Session["user"]; if (!utils.verifySession("noteEntityId") || !utils.verifySession("noteModuleId")) throw new Exception("The note entity ID or note module ID could not be determined."); oNote note = new oNote(); //first check if we're updating an existing note if (utils.verifySession("note") && Session["noteId"].ToString() != "0") { note = (oNote)Session["note"]; } else { //check if a new note has already been saved on previous attachment added if (ViewState["newNote"] == null) { int moduleId = int.Parse(Session["noteModuleId"].ToString()); int entityId = int.Parse(Session["noteEntityId"].ToString()); note.entityId = entityId; note.moduleId = moduleId; note.fieldName = fieldName; //save form values SavePageFormValues(ref note); //save new note to link attachment to note.dateSaved = System.DateTime.Now; note.userIdSaved = user.recId; note.recId = xData.SaveTyped("recId", typeof(oNote), note); ViewState["newNote"] = note; } else { note = (oNote)ViewState["newNote"]; } } Attachment.isActive = true; Attachment.entityId = note.recId; Attachment.moduleId = (int)pNums.Module.Notes; Attachment.fieldName = fieldName; Attachment.typeId = e.File.ContentType.StartsWith("image") ? (int)pNums.AttachmentType.Image : (int)pNums.AttachmentType.Document; /* CVH 2016-04-15 Add date and user */ int userId = user.recId; if (Attachment.recId > 0) { Attachment.userIdUpdated = userId; Attachment.dateUpdated = System.DateTime.Now; } else { Attachment.userIdSaved = userId; Attachment.dateSaved = System.DateTime.Now; } string notefolderName = "note/"; notefolderName += note.recId.ToString(); Attachment.folderName = notefolderName; Attachment.display = e.File.FileName.Remove(e.File.FileName.LastIndexOf(".")); Attachment.fileName = Attachment.entityId + "_" + utils.RandomString(9, true) + e.File.FileName.Substring(e.File.FileName.LastIndexOf(".")); if (Attachment.typeId == pNums.AttachmentType.Document.GetHashCode()) { string docPath = Server.MapPath("~/upload/" + Attachment.folderName + "/"); utils.validateFolder(docPath); //upload file e.File.SaveAs(docPath + Attachment.fileName); } else { string imagePath = Server.MapPath("~/upload/" + Attachment.folderName + "/image/"); string thumbPath = Server.MapPath("~/upload/" + Attachment.folderName + "/thumb/"); string tempPath = Server.MapPath("~/upload/" + Attachment.folderName + "/temp/"); utils.validateFolder(imagePath); utils.validateFolder(thumbPath); utils.validateFolder(tempPath); //upload file e.File.SaveAs(tempPath + Attachment.fileName); //resize and compress utils.ResizeImage(tempPath + Attachment.fileName, imagePath, Attachment.fileName, 400, true); //resize and crop utils.ResizeCropImagePrecise(imagePath + Attachment.fileName, thumbPath, Attachment.fileName, 383, 264, false); } if (Attachment.recId > 0) { xData.UpdateTyped("recId", Attachment.recId.ToString(), typeof(oAttachment), Attachment); utils.disposeSession("Attachment"); } else { Attachment.recId = xData.SaveTyped("recId", typeof(oAttachment), Attachment); if (Attachment.recId > 0) { } } } catch (Exception ex) { exception.HandleException("Attachments:", MethodBase.GetCurrentMethod().Name, ex, Session["attachment"]); Response.Redirect("/error", false); } } protected void btnAttachments_Click(object sender, EventArgs e) { try { if (utils.verifySession("noteEntityId")) { Session["moduleId"] = pNums.Module.Notes.GetHashCode(); Session["entityId"] = 0; //will be creating a new note for the attachment string fieldName = String.Empty; if (utils.verifySession("fieldNameNote")) fieldName = Session["fieldNameNote"].ToString(); Session["fieldNameFile"] = fieldName; Session["HistorySurfaceItemId"] = int.Parse(Session["noteEntityId"].ToString()); //surface item Id dynamic attachments = this.FindControl("noteAttachments"); attachments.ReloadControl(); TogglePanels("pnlNoteAttachments"); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myModal", "$('#modNotes').modal();", true); } } catch (Exception ex) { exception.HandleException("Attachments:", MethodBase.GetCurrentMethod().Name, ex, Session["attachment"]); Response.Redirect("/error", false); } } /// /// Raised from the attachments control when the Back button is clicked /// /// /// /// protected override bool OnBubbleEvent(object source, EventArgs args) { try { CommandEventArgs e = (CommandEventArgs)args; if (e.CommandName == "LoadNotesList") { ReloadControl(); upNotes.Update(); } return true; } catch (Exception) { return false; } } #endregion }