protected void btnPublishToCrew_Click(object sender, EventArgs e) { int ItemId = 0; string sFileName = "CTRN_" + Guid.NewGuid().ToString() + ".pdf"; string htmlStr = ""; string Question = ""; string Answer = ""; if (Get_FAQ_ID() > 0) { DataTable dt = BLL_LMS_FAQ.Get_FAQ_Details(Get_FAQ_ID()); Question = Convert.ToString(dt.Rows[0]["Question"]); Answer = Convert.ToString(dt.Rows[0]["Answer"]); htmlStr += "<table style='width:100%' ><tr><td style='font-size:14;color:navy;font-family:verdana;border-bottom:1px solid black' ><b> " + Question + "</b></td> </tr> <tr> <td style='font-size:11;color:black;font-family:verdana' >" + Answer + "</td> </tr></table> "; string filePath = Server.MapPath("~/") + "Uploads\\TrainingItems\\" + sFileName; EO.Pdf.HtmlToPdf.Options.AfterRenderPage = new EO.Pdf.PdfPageEventHandler(On_AfterRenderPage); // This use For IIS EO.Pdf.HtmlToPdf.Options.BaseUrl = "http://" + HttpContext.Current.Request.Url.Host + "/"; //This use For Local machine EO.Pdf.HtmlToPdf.ConvertHtml(@"<html><head></head><body><div>" + htmlStr + "</div></body></html> ", filePath); if (Question.Length > 250) { Question = Question.Substring(0, 250); } int Result = BLL_LMS_Training.Ins_Training_Items(Question, null, "ARTICLE", "0", sFileName, sFileName, Convert.ToInt32(Session["USERID"]), 1, ref ItemId); string js = "alert(' FAQ published successfully! !');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert2", js, true); txtquestion.Text = string.Empty; txtProcedureSectionDetails.Content = string.Empty; } else { string js = "alert('Please save the FAQ to proceed!');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert3", js, true); } }
protected void AddItem(object sender) { string fileName; string Attachment_Name; Byte[] fileBytes = (Byte[])Session["vsAttachmentData"]; if (Session["vsAttachmentFileName"] != null) { fileName = Session["vsAttachmentFileName"].ToString(); } else { fileName = string.Empty; } string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\TrainingItems"); Guid GUID = Guid.NewGuid(); Attachment_Name = Path.GetFileName(fileName); string Flag_Attach = "LMS_" + GUID.ToString() + Path.GetExtension(fileName); int ItemId = 0; if (ddlItemType.SelectedValue == "2") { Flag_Attach = GetPathforFBMNumber(); } int Result = BLL_LMS_Training.Ins_Training_Items(txtItemName.Text.Trim(), txtDescription.Text.Trim(), UDFLib.ConvertStringToNull(ddlItemType.SelectedItem), txtDuration.Text, Flag_Attach, ddlItemType.SelectedValue == "1" ? Attachment_Name : null, Convert.ToInt32(Session["USERID"]), 1, ref ItemId); if (ddlItemType.SelectedValue == "1") { string FullFilename = Path.Combine(sPath, "LMS_" + GUID.ToString() + Path.GetExtension(fileName)); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); } Session["vsAttachmentData"] = null; Session["vsAttachmentFileName"] = null; txtItemName.Text = ""; txtDuration.Text = ""; txtDescription.Text = ""; if (ddlItemType.SelectedValue == "2") { txtItemName.Text = ""; ddlFBMNumber.Visible = true; txtItemName.Enabled = false; if (ViewState["dt_FBM_Number"] != null) { ddlFBMNumber.DataSource = (ViewState["dt_FBM_Number"]); ddlFBMNumber.DataBind(); } else { FillFBMNumber(); txtItemName.Text = ddlFBMNumber.SelectedValue; txtItemName.Enabled = false; } if (txtItemName.Text == "") { txtItemName.Text = ddlFBMNumber.SelectedValue; txtItemName.Enabled = false; } } if (Result >= 0) { if ((sender as Button).ID.ToUpper() == "BTNSAVEANDCLOSE") { string js = String.Format("parent.ReloadParent_ByButtonID();"); ScriptManager.RegisterStartupScript(this, this.GetType(), "ReloadParent", js, true); } } }