protected void btnSave_FAQ_Click(object sender, EventArgs e) { //if (!check(txtquestion.Text.ToString(), (txtProcedureSectionDetails.Content))) //{ // string js = "alert('Faq Question AllReady Exist!');"; // ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js, true); // txtquestion.Focus(); // return; //} if (ddlModule.SelectedValue == "0") { string js2 = "alert('Please select Module to save FAQ!');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert11", js2, true); ddlTopic.Focus(); return; } if (ddlTopic.SelectedValue == "0") { string js1 = "alert('Please select Topic to save FAQ!');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert10", js1, true); ddlTopic.Focus(); return; } int FAQ_ID = Get_FAQ_ID(); string successmsg = ""; if (FAQ_ID == 0) { successmsg = "FAQ created successfully!"; } else { successmsg = "FAQ updated successfully!"; } int Sync_To_Vessel = 0; if (chkvessel.Checked) { Sync_To_Vessel = 1; } try { // Validate your data, if any //FAQ_ID = BLL_LMS_FAQ.Upd_Faq_Details(FAQ_ID, txtquestion.Text.Trim(), txtProcedureSectionDetails.Content, UDFLib.ConvertToInteger(Session["userid"])); FAQ_ID = BLL_LMS_FAQ.Upd_Faq_Details(FAQ_ID, txtquestion.Text.Trim(), txtProcedureSectionDetails.Content, UDFLib.ConvertToInteger(Session["userid"]), UDFLib.ConvertToInteger(ddlTopic.SelectedValue)); if (FAQ_ID > 0) { DataTable dt_FAQ_Attachments = new DataTable(); dt_FAQ_Attachments.Columns.Add("ID", typeof(Int32)); dt_FAQ_Attachments.Columns.Add("ATTACHMENT_NAME", typeof(String)); string[] FAQ_Attachs = txtProcedureSectionDetails.Content.Split(new string[] { "Uploads/FAQ/" }, StringSplitOptions.None); foreach (string Attach in FAQ_Attachs) { if (Attach.StartsWith("FAQ_", StringComparison.OrdinalIgnoreCase)) { DataRow dr = dt_FAQ_Attachments.NewRow(); dr["ID"] = FAQ_ID.ToString(); dr["ATTACHMENT_NAME"] = Attach.Substring(0, 44); dt_FAQ_Attachments.Rows.Add(dr); } } DataTable dtAttachToDelete = BLL_LMS_FAQ.Ins_Attachment(FAQ_ID, Convert.ToInt32(Session["userid"]), dt_FAQ_Attachments, Sync_To_Vessel); // delete file not in use foreach (DataRow drAttach in dtAttachToDelete.Rows) { File.Delete(HttpContext.Current.Server.MapPath("~/Uploads/FAQ/" + drAttach["ATTACHMENT_NAME"])); BLL_LMS_FAQ.Del_Faq_Attachment(Convert.ToString(drAttach["ATTACHMENT_NAME"]), Sync_To_Vessel); } btnPublishToCrew.Enabled = true; btnSave_FAQ.Visible = false; btn_Update_FAQ.Visible = true; string js = "alert('" + successmsg + "');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert1", js, true); btnSave_FAQ.Attributes.Add("OnClick", "self.close()"); } else { btnPublishToCrew.Enabled = false; string js = "alert('Question and Answer is mandatory field...!');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert2", js, true); } hdnFaq_Id.Value = UDFLib.ConvertToInteger(FAQ_ID).ToString(); } catch (Exception ee) { //"Error occured. " + ee.Message; } }