protected void btnUpdate_Click(object sender, EventArgs e) { Notice_Entry ne = new Notice_Entry(); Upload_doc ud = new Upload_doc(); ReturnClass.ReturnBool rb = new ReturnClass.ReturnBool(); dl_rti_notice dl = new dl_rti_notice(); ud.Status = "N"; if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString()) { Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString()); if (ddlPermanent.SelectedValue == "Y") { RequiredFieldValidator10.Enabled = false; RequiredFieldValidator10.ValidationGroup = "x"; RequiredFieldValidator9.Enabled = false; RequiredFieldValidator9.ValidationGroup = "x"; RegularExpressionValidator10.Enabled = false; RegularExpressionValidator10.ValidationGroup = "x"; RegularExpressionValidator17.Enabled = false; RegularExpressionValidator17.ValidationGroup = "x"; RequiredFieldValidator7.Enabled = true; RequiredFieldValidator7.ValidationGroup = "a"; RegularExpressionValidator1.Enabled = true; RegularExpressionValidator1.ValidationGroup = "a"; } else if (ddlPermanent.SelectedValue == "N") { RequiredFieldValidator10.Enabled = true; RequiredFieldValidator9.Enabled = true; RequiredFieldValidator10.ValidationGroup = "a"; RequiredFieldValidator9.ValidationGroup = "a"; RegularExpressionValidator10.Enabled = true; RegularExpressionValidator10.ValidationGroup = "a"; RegularExpressionValidator17.Enabled = true; RegularExpressionValidator17.ValidationGroup = "a"; RequiredFieldValidator7.Enabled = false; RequiredFieldValidator7.ValidationGroup = "x"; RegularExpressionValidator1.Enabled = false; RegularExpressionValidator1.ValidationGroup = "x"; } if (ddlHyperlink.SelectedValue == "Y") { RequiredFieldValidator3.Enabled = true; RequiredFieldValidator3.ValidationGroup = "a"; } else if (ddlHyperlink.SelectedValue == "N") { RequiredFieldValidator3.Enabled = false; RequiredFieldValidator3.ValidationGroup = "x"; RequiredFieldValidator6.Enabled = false; RequiredFieldValidator6.ValidationGroup = "x"; RequiredFieldValidator4.Enabled = false; RequiredFieldValidator4.ValidationGroup = "x"; regUrl.ValidationGroup = "x"; regUrl.Enabled = false; } if (ddlType.SelectedValue == "E") { RequiredFieldValidator6.Enabled = false; RequiredFieldValidator6.ValidationGroup = "x"; RequiredFieldValidator4.Enabled = true; RequiredFieldValidator4.ValidationGroup = "a"; regUrl.ValidationGroup = "a"; regUrl.Enabled = true; } else if (ddlType.SelectedValue == "I") { RequiredFieldValidator6.Enabled = true; RequiredFieldValidator6.ValidationGroup = "a"; RequiredFieldValidator4.Enabled = false; RequiredFieldValidator4.ValidationGroup = "x"; regUrl.ValidationGroup = "x"; regUrl.Enabled = false; } if (Page.IsValid) { Boolean st = true; try { using (TransactionScope ts = new TransactionScope()) { ne.District_id = ddl_district.SelectedValue; ne.Base_dept_id = ddl_department.SelectedValue; ne.Office_id = ddl_office.SelectedValue; ne.NoticeID = Request.QueryString["nid"].ToString(); ne.Header = txtHeader.Text; ne.Permanent = ddlPermanent.SelectedValue; ne.Active = ddlActive.SelectedValue; ne.Hyperlink = ddlHyperlink.SelectedValue.ToString(); ne.Client_ip = util.GetClientIpAddress(this.Page); ne.User_id = Session["username"].ToString(); ne.Datetime = Convert.ToDateTime(System.DateTime.Now).ToString("yyyy/MM/dd HH:mm:ss"); if (ddlPermanent.SelectedValue == "N") { ne.Publish_date = null; //string datefrom = Convert.ToDateTime(txtDateFrom.Text.Trim()).ToString("yyyy/MM/dd HH:mm:ss"); //string dateto = Convert.ToDateTime(txtDateTo.Text.Trim()).ToString("yyyy/MM/dd HH:mm:ss"); //ne.Datefrom = datefrom.ToString(); //ne.Dateto = dateto.ToString(); DateTime datefrom = DateTime.ParseExact(txtDateFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); ne.Datefrom = datefrom.ToString("yyyy/MM/dd HH:mm:ss"); DateTime dateto = DateTime.ParseExact(txtDateTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); ne.Dateto = dateto.ToString("yyyy/MM/dd HH:mm:ss"); } else if (ddlPermanent.SelectedValue == "Y") { DateTime Publish_date = DateTime.ParseExact(txtPublishDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); ne.Publish_date = Publish_date.ToString("yyyy/MM/dd HH:mm:ss"); //ne.Publish_date = Convert.ToDateTime(txtPublishDate.Text.Trim()).ToString("yyyy/MM/dd HH:mm:ss"); ne.Datefrom = null; ne.Dateto = null; } if (ddlHyperlink.SelectedValue == "Y") { ne.Filetype = ddlType.SelectedValue; if (ddlType.SelectedValue == "I") { ne.Url = null; if (FileUpload1.HasFile) { if (FileUpload1.PostedFile.ContentType == "application/x-pdf" || FileUpload1.PostedFile.ContentType == "application/pdf") { if (FileUpload1.PostedFile.ContentLength > maxSizePdf) { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow("This PDF File Is too Big...Maximum Size allowed is 10 Mb"); } else { Utilities.MessageBoxShow("यह PDF बहुत बड़ा है...अधिकतम साइज़ 10 Mb की अनुमति है"); } // Utilities.MessageBoxShow("This PDF File Is too Big...Maximum Size allowed is 10 Mb"); st = false; } } else if (FileUpload1.PostedFile.ContentType == "image/jpg" || FileUpload1.PostedFile.ContentType == "image/jpeg") { if (FileUpload1.PostedFile.ContentLength > maxSizeJpg) { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow("This JPG File Is too Big...Maximum Size allowed is 1 Mb"); } else { Utilities.MessageBoxShow("यह JPG बहुत बड़ा है...अधिकतम साइज़ 1 Mb की अनुमति है"); } // Utilities.MessageBoxShow("This JPG File Is too Big...Maximum Size allowed is 1 Mb"); st = false; } } if (st) { if (FileUpload1.PostedFile.ContentType == "application/x-pdf" || FileUpload1.PostedFile.ContentType == "application/pdf" || FileUpload1.PostedFile.ContentType == "image/jpg" || FileUpload1.PostedFile.ContentType == "image/jpeg") { string file_ext = Path.GetExtension(FileUpload1.PostedFile.FileName).ToString(); Stream fs = default(Stream); fs = FileUpload1.PostedFile.InputStream; BinaryReader br1 = new BinaryReader(fs); byte[] pdfbytes = br1.ReadBytes(FileUpload1.PostedFile.ContentLength); ud.File_Extn = file_ext; ud.File_Data = pdfbytes; ud.Filename = FileUpload1.PostedFile.FileName; ud.Client_ip = util.GetClientIpAddress(this.Page); ud.Upload_Date = Convert.ToDateTime(System.DateTime.Now).ToString("yyyy/MM/dd HH:mm:ss"); ud.User_id = Session["username"].ToString(); } else { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow("Only PDF and JPG files are allowed"); } else { Utilities.MessageBoxShow(" केवल PDF और JPG फाईल की अनुमति है"); } //Utilities.MessageBoxShow("Only PDF and JPG files are allowed"); st = false; } } } } else if (ddlType.SelectedValue == "E") { ne.file_id = null; ne.Url = txtUrl.Text.Trim(); nb = ",File_Id=@file_id"; int fid = Convert.ToInt32(Request.QueryString["fid"].ToString()); if (fid != 0) { ud.file_id = Request.QueryString["fid"].ToString(); rb = dl.update_file_details(ud); } } } else if (ddlHyperlink.SelectedValue == "N") { ud.file_id = null; ud.File_Extn = null; ud.Content_type = null; ud.File_Data = new byte[] { }; ud.URL = null; // nb = ",File_Id=@File_id"; // nb = ",File_Id=@file_id"; int fid = Convert.ToInt32(Request.QueryString["fid"].ToString()); if (fid != 0) { ud.file_ID = Convert.ToInt32(Request.QueryString["fid"].ToString()); rb = dl.update_file_details(ud); } } if (FileUpload1.HasFile) { if (st) { int fid = Convert.ToInt32(Request.QueryString["fid"].ToString()); if (fid == 0) { //if (rb.status == true) //{ ud.Filename = FileUpload1.PostedFile.FileName; ud.Client_ip = util.GetClientIpAddress(this.Page); ud.User_id = Session["username"].ToString(); ud.Upload_Date = Convert.ToDateTime(System.DateTime.Now).ToString("yyyy/MM/dd HH:mm:ss"); rb = dl.Insert_FileDetails(ud); // } if (rb.status == true) { ne.file_ID = Convert.ToInt32(dl.Get_Max_ID().table.Rows[0][0].ToString()); //nb = ",File_Id=@file_ID"; } } else if (fid != 0) { ud.file_id = Request.QueryString["fid"].ToString(); ud.Status = "Y"; rb = dl.update_file_details(ud); } } } if (st) { if (RadioButtonListbold.SelectedValue == "Yes") { ne.Bold = "Y"; } else { ne.Bold = "N"; } if (RadioButtonListblink.SelectedValue == "Yes") { ne.Blink = "Y"; } else { ne.Blink = "N"; } ne.Priority = ddlpriority.SelectedValue; ne.Color = color.Text.Trim(); if (ddlimage.SelectedValue == "") { ne.Image = Image1.ImageUrl; } else { //ne.Image = ddlimage.SelectedValue; ne.Image = ddlimage.SelectedItem.Text; } if (ne.Image.StartsWith("..")) { string imgPath = ne.Image; string cut_imgPath = imgPath.Remove(0, 3); ne.Image = cut_imgPath; } rb = dl.update_notice(ne); // rb = dl.update_notice(ne, nb); } if (rb.status == true) { ts.Complete(); clear(); if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow_Redirect("Notice Updated successfully", "NoticeEdit_List.aspx"); } else { Utilities.MessageBoxShow_Redirect("रिकार्ड सफलतापूर्वक सुरक्षित हुआ", "NoticeEdit_List.aspx"); } // Utilities.MessageBoxShow_Redirect("Notice Updated successfully", "NoticeEdit_List.aspx"); } } } catch (Exception ex) { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow("Record could not be updated."); } else { Utilities.MessageBoxShow("रिकार्ड सुरक्षित नहीं हुआ |"); } // Utilities.MessageBoxShow("Record could not be updated."); Gen_Error_Rpt.Write_Error("admin_NewsEdit_Form.aspx_btnUpdate_Click", ex); } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { Upload_doc bl = new Upload_doc(); Notice_Entry n = new Notice_Entry(); ReturnClass.ReturnBool rb = new ReturnClass.ReturnBool(); if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString()) { Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString()); if (ddlPermanent.SelectedValue == "Y") { RequiredFieldValidator10.Enabled = false; RequiredFieldValidator10.ValidationGroup = "x"; RequiredFieldValidator9.Enabled = false; RequiredFieldValidator9.ValidationGroup = "x"; RegularExpressionValidator10.Enabled = false; RegularExpressionValidator10.ValidationGroup = "x"; RegularExpressionValidator17.Enabled = false; RegularExpressionValidator17.ValidationGroup = "x"; RequiredFieldValidator7.Enabled = true; RequiredFieldValidator7.ValidationGroup = "a"; RegularExpressionValidator1.Enabled = true; RegularExpressionValidator1.ValidationGroup = "a"; } else if (ddlPermanent.SelectedValue == "N") { RequiredFieldValidator10.Enabled = true; RequiredFieldValidator9.Enabled = true; RequiredFieldValidator10.ValidationGroup = "a"; RequiredFieldValidator9.ValidationGroup = "a"; RegularExpressionValidator10.Enabled = true; RegularExpressionValidator10.ValidationGroup = "a"; RegularExpressionValidator17.Enabled = true; RegularExpressionValidator17.ValidationGroup = "a"; RequiredFieldValidator7.Enabled = false; RequiredFieldValidator7.ValidationGroup = "x"; RegularExpressionValidator1.Enabled = false; RegularExpressionValidator1.ValidationGroup = "x"; } if (ddlHyperlink.SelectedValue == "Y") { RequiredFieldValidator3.Enabled = true; RequiredFieldValidator3.ValidationGroup = "a"; } else if (ddlHyperlink.SelectedValue == "N") { RequiredFieldValidator3.Enabled = false; RequiredFieldValidator3.ValidationGroup = "x"; RequiredFieldValidator6.Enabled = false; RequiredFieldValidator6.ValidationGroup = "x"; RequiredFieldValidator4.Enabled = false; RequiredFieldValidator4.ValidationGroup = "x"; regUrl.ValidationGroup = "x"; regUrl.Enabled = false; } if (ddlType.SelectedValue == "E") { RequiredFieldValidator6.Enabled = false; RequiredFieldValidator6.ValidationGroup = "x"; RequiredFieldValidator4.Enabled = true; RequiredFieldValidator4.ValidationGroup = "a"; regUrl.ValidationGroup = "a"; regUrl.Enabled = true; } else if (ddlType.SelectedValue == "I") { RequiredFieldValidator6.Enabled = true; RequiredFieldValidator6.ValidationGroup = "a"; RequiredFieldValidator4.Enabled = false; RequiredFieldValidator4.ValidationGroup = "x"; regUrl.ValidationGroup = "x"; regUrl.Enabled = false; } if (HiddenField1.Value == "0" || HiddenField1.Value == "Select") { RFV_Image_Icon.ValidationGroup = "a"; RFV_Image_Icon.Enabled = true; } else { RFV_Image_Icon.ValidationGroup = "x"; RFV_Image_Icon.Enabled = false; } if (Page.IsValid) { Boolean st = true; try { using (TransactionScope ts = new TransactionScope()) { n.District_id = ddl_district.SelectedValue;// Session["Dist_Code"].ToString(); n.Base_dept_id = ddl_department.SelectedValue; n.Office_id = ddl_office.SelectedValue; n.Header = txtHeader.Text.Trim(); n.Permanent = ddlPermanent.SelectedValue; n.Active = ddlActive.SelectedValue; n.Hyperlink = ddlHyperlink.SelectedValue.ToString(); n.Client_ip = util.GetClientIpAddress(this.Page); n.User_id = Session["username"].ToString(); // n.Datetime = Convert.ToDateTime(System.DateTime.Now).ToString("yyyy/MM/dd HH:mm:ss"); DateTime today = DateTime.Today; n.Datetime = today.ToString("yyyy/MM/dd"); if (ddlPermanent.SelectedValue == "N") { n.Publish_date = null; //string datefrom = Convert.ToDateTime(txtDateFrom.Text.Trim()).ToString("yyyy/MM/dd HH:mm:ss"); //string dateto = Convert.ToDateTime(txtDateTo.Text.Trim()).ToString("yyyy/MM/dd HH:mm:ss"); //n.Datefrom = datefrom.ToString(); //n.Dateto = dateto.ToString(); DateTime datefrom = DateTime.ParseExact(txtDateFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); n.Datefrom = datefrom.ToString("yyyy/MM/dd HH:mm:ss"); DateTime dateto = DateTime.ParseExact(txtDateTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); n.Dateto = dateto.ToString("yyyy/MM/dd HH:mm:ss"); } else if (ddlPermanent.SelectedValue == "Y") { DateTime Publish_date = DateTime.ParseExact(txtPublishDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); n.Publish_date = Publish_date.ToString("yyyy/MM/dd HH:mm:ss"); //n.Publish_date = Convert.ToDateTime(txtPublishDate.Text.Trim()).ToString("yyyy/MM/dd HH:mm:ss"); n.Datefrom = null; n.Dateto = null; } if (ddlHyperlink.SelectedValue == "Y") { n.Filetype = ddlType.SelectedValue; if (ddlType.SelectedValue == "I") { if (FileUpload1.HasFile) { if (FileUpload1.PostedFile.ContentType == "application/x-pdf" || FileUpload1.PostedFile.ContentType == "application/pdf") { if (FileUpload1.PostedFile.ContentLength > maxSizePdf) { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow("This PDF File Is too Big...Maximum Size allowed is 10 Mb"); } else { Utilities.MessageBoxShow("यह PDF बहुत बड़ा है...अधिकतम साइज़ 10 Mb की अनुमति है"); } // Utilities.MessageBoxShow("This PDF File Is too Big...Maximum Size allowed is 10 Mb"); st = false; preview(); } } else if (FileUpload1.PostedFile.ContentType == "image/jpg" || FileUpload1.PostedFile.ContentType == "image/jpeg") { if (FileUpload1.PostedFile.ContentLength > maxSizeJpg) { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow("This JPG File Is too Big...Maximum Size allowed is 1 Mb"); } else { Utilities.MessageBoxShow("यह JPG बहुत बड़ा है...अधिकतम साइज़ 1 Mb की अनुमति है"); } //Utilities.MessageBoxShow("This JPG File Is too Big...Maximum Size allowed is 1 Mb"); st = false; preview(); } } if (st) { if (FileUpload1.PostedFile.ContentType == "application/x-pdf" || FileUpload1.PostedFile.ContentType == "application/pdf" || FileUpload1.PostedFile.ContentType == "image/jpg" || FileUpload1.PostedFile.ContentType == "image/jpeg") { //string content_type = FileUpload1.PostedFile.ContentType.ToString(); string file_ext = Path.GetExtension(FileUpload1.PostedFile.FileName).ToString(); Stream fs = default(Stream); fs = FileUpload1.PostedFile.InputStream; BinaryReader br1 = new BinaryReader(fs); byte[] pdfbytes = br1.ReadBytes(FileUpload1.PostedFile.ContentLength); bl.File_Extn = file_ext; bl.File_Data = pdfbytes; bl.URL = null; bl.Filename = FileUpload1.PostedFile.FileName; } else { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow("Only PDF and JPG files are allowed"); } else { Utilities.MessageBoxShow(" केवल PDF और JPG फाईल की अनुमति है"); } // Utilities.MessageBoxShow("Only PDF and JPG files are allowed"); st = false; preview(); } } } } else if (ddlType.SelectedValue == "E") { n.File_id = null; n.url = txtUrl.Text.Trim(); } } else if (ddlHyperlink.SelectedValue == "N") { bl.File_id = null; bl.File_Extn = null; bl.Content_type = null; bl.File_Data = new byte[] { }; bl.URL = null; bl.Filename = null; } if (FileUpload1.HasFiles) { if (st) { bl.Filename = FileUpload1.PostedFile.FileName; bl.Client_ip = util.GetClientIpAddress(this.Page); bl.User_id = Session["username"].ToString(); bl.Upload_Date = Convert.ToDateTime(System.DateTime.Now).ToString("yyyy/MM/dd HH:mm:ss"); rb = dl.Insert_FileDetails(bl); // inserting file details.. if (rb.status == true) { n.file_ID = Convert.ToInt32(dl.Get_Max_ID().table.Rows[0][0].ToString()); } } } if (st) { //new if (RadioButtonListbold.SelectedValue == "Yes") { n.Bold = "Y"; } else { n.Bold = "N"; } if (RadioButtonListblink.SelectedValue == "Yes") { n.Blink = "Y"; } else { n.Blink = "N"; } n.Priority = ddlpriority.SelectedValue; n.Color = color.Text.Trim(); // n.Image = ddlimage.SelectedItem.Text; string imgPath = HiddenField1.Value.ToString(); string cut_imgPath = imgPath.Remove(0, 3); n.Image = cut_imgPath; //HiddenField1.Value; n.status = "P"; rb = dl.Insert_Notice(n); // inserting notice details } if (rb.status == true) { ts.Complete(); if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow_Redirect("Record Saved Successfully", "../admin/notice_entry.aspx"); } else { Utilities.MessageBoxShow_Redirect("रिकार्ड सफलतापूर्वक सुरक्षित हुआ", "../admin/notice_entry.aspx"); } // Utilities.MessageBoxShow_Redirect("Record Save Successfully", "../admin/notice_entry.aspx"); clear(); // BindDropDownList(); // BindTitles(); } } } catch (Exception ex) { rb.status = false; if (Session["language"].ToString() == "en-GB") { Utilities.MessageBoxShow("Record could not be saved."); } else { Utilities.MessageBoxShow("रिकार्ड सुरक्षित नहीं हुआ |"); } // Utilities.MessageBoxShow("Record could not be saved."); Gen_Error_Rpt.Write_Error("Notice_Entry.aspx_btnSubmit_Click", ex); } } } }