protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["title"])) { oDocument_BLogic = new Document_BLogic(); oDocument = new MailDocument(); oDocument.Documentpath = Server.MapPath("~/Documents/AdmissionDocument"); oDocument.Title = Request.QueryString["title"]; ViewState["title"] = Request.QueryString["title"]; if (oDocument_BLogic.BAL_Document_CheckExists(oDocument)) { DataTable oTable = oDocument_BLogic.BAL_Document_Select(oDocument); txttitle.Text = Convert.ToString(oTable.Rows[0]["title"]); txttitle.Enabled = false; txtmail.Content = Convert.ToString(oTable.Rows[0]["body"]); txtmail.ActiveMode = AjaxControlToolkit.HTMLEditor.ActiveModeType.Preview; txtmail.Enabled = false; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["title"])) { oDocument_BLogic = new Document_BLogic(); oDocument = new MailDocument(); oDocument.Documentpath = Server.MapPath("~/Documents/AdmissionDocument"); oDocument.Title = Request.QueryString["title"]; ViewState["title"] = Request.QueryString["title"]; if (oDocument_BLogic.BAL_Document_CheckExists(oDocument)) { btnSubmit.Text = "Update"; lblTitle.Text = "Update Document"; DataTable oTable = oDocument_BLogic.BAL_Document_Select(oDocument); txttitle.Text = Convert.ToString(oTable.Rows[0]["title"]); txtmail.Content = Convert.ToString(oTable.Rows[0]["body"]); ViewState["Mode"] = "Update"; } else { ViewState["Mode"] = "Add"; } } else { ViewState["Mode"] = "Add"; } BindTagDropDown(); } }
/// <summary> /// Generate Document And Add it in list. /// </summary> /// <param name="documentList"></param> /// <param name="admissionId"></param> /// <returns></returns> private ArrayList GenerateDocument(ArrayList documentList, string admissionId) { ArrayList FileList = new ArrayList(); oAdmission = new Admission(); oAdmission_BLogic = new Admission_BLogic(); oAdmission.AdmissionId = admissionId; ViewState["AdmissionStudentData"] = oAdmission_BLogic.Admission_Select_ByAdmissionId(oAdmission); ViewState["TagMasterData"] = oAdmission_BLogic.AdmissionTagMaster_Select_All(); foreach (string filename in DocumentList) { oDocument_BLogic = new Document_BLogic(); oDocument = new MailDocument(); oDocument.Documentpath = Server.MapPath("~/Documents/AdmissionDocument"); oDocument.Title = Convert.ToString(filename); StringBuilder WordContent = new StringBuilder(); if (oDocument_BLogic.BAL_Document_CheckExists(oDocument)) { DataTable oTable = oDocument_BLogic.BAL_Document_Select(oDocument); string title = Convert.ToString(oTable.Rows[0]["title"]); string body = Convert.ToString(oTable.Rows[0]["body"]); body = ReplaceTag(body); WordContent.Append("<html " + "xmlns:o='urn:schemas-microsoft-com:office:office' " + "xmlns:w='urn:schemas-microsoft-com:office:word'" + "xmlns='http://www.w3.org/TR/REC-html40'>" + "<head><title>Time</title>"); WordContent.Append("<!--[if gte mso 9]>" + "<xml>" + "<w:WordDocument>" + "<w:View>Print</w:View>" + "<w:Zoom>90</w:Zoom>" + "<w:DoNotOptimizeForBrowser/>" + "</w:WordDocument>" + "</xml>" + "<![endif]-->"); WordContent.Append("<style>" + "<!-- /* Style Definitions */" + "@page Section1" + " {size:8.5in 11.0in; " + " margin:0.6in 0.6in 0.6in 0.6in ; " + " mso-header-margin:.1in; " + " mso-footer-margin:.1in; mso-paper-source:0;}" + " div.Section1" + " {page:Section1;}" + "-->" + "</style></head>"); WordContent.Append("<body lang=EN-US style='tab-interval:.5in'>" + "<div class=Section1>" + body + "</div></body></html>"); string AutoGenerateDocumentPath = Server.MapPath("~/Documents/AutoGeneratedAdmissionDocument"); using (TextWriter writer = File.CreateText(Path.Combine(AutoGenerateDocumentPath, title + "_" + admissionId + ".doc"))) { writer.Write(Convert.ToString(WordContent)); } FileList.Add(Path.Combine(AutoGenerateDocumentPath, title + "_" + admissionId + ".doc")); AutoGeneratedDocumentList.Add(string.Format("{0}/{1}", "../Documents/AutoGeneratedAdmissionDocument", title + "_" + admissionId + ".doc")); } } return(FileList); }