public ReturnClass.ReturnDataTable Bind_grid(bl_report bl) { string str = "", where = " where 1 = 1 "; try { List <MySqlParameter> pm = new List <MySqlParameter>(); if (bl.State != "" && bl.State != null && bl.State != "0" && bl.State != "Select") { MySqlParameter da = new MySqlParameter("state", bl.State); pm.Add(da); where += " and ofc.StateCode= @state "; } if (bl.District != "0" && bl.District != null && bl.District != "" && bl.District != "Select") { MySqlParameter ba = new MySqlParameter("dstrict", bl.District); pm.Add(ba); where += " and ofc.DistrictCodeNew = @dstrict "; } if (bl.Base_department != "" && bl.Base_department != null && bl.Base_department != "0" && bl.Base_department != "Select") { MySqlParameter ca = new MySqlParameter("bs_dept", bl.Base_department); pm.Add(ca); where += " and ofc.BaseDeptCode = @bs_dept "; } if (bl.Office_level_id != "0" && bl.Office_level_id != null && bl.Office_level_id != "" && bl.Office_level_id != "Select") { MySqlParameter da = new MySqlParameter("ofc_lvl", bl.Office_level_id); pm.Add(da); where += " and ofc.OfficeLevel = @ofc_lvl "; } if (bl.Role == "4") { MySqlParameter ea = new MySqlParameter("level", bl.Officelevelcode); pm.Add(ea); where += " and ol.OfficeLevelType=@level "; } if (bl.Category != "0" && bl.Category != null && bl.Category != "" && bl.Category != "Select") { MySqlParameter fa = new MySqlParameter("category", bl.Category); pm.Add(fa); where += " and ofc.OfficeCategory=@category "; } str = @" select ofc.NewOfficeCode , dic.District_Name_En as district, bd.dept_name as basedept, ol.OfficeLevelName as ofclvl, ofc.OfficeName as ofice, ofc.OfficeAddress as address, ofc.ContactNo as mobile, ofc.Email as email, ofc.OfficeURL as ofc_url from office ofc inner join districts dic on dic.StateCode=ofc.StateCode and dic.district_id = ofc.DistrictCodeNew inner join basedepartment bd on bd.dept_id = ofc.BaseDeptCode inner join officelevel ol on ol.OfficeLevelCode = ofc.OfficeLevel and ol.StateCode= ofc.StateCode and ol.BaseDeptCode=ofc.BaseDeptCode" + where + " order by ofc.NewOfficeCode asc"; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return(rd); }
public ReturnClass.ReturnDataTable executeSelectQuery(String _query, String ls) { ReturnClass.ReturnDataTable dt = new ReturnClass.ReturnDataTable(); try { string con_str1 = GetConnectionString(ls); using (MySqlConnection con = new MySqlConnection(con_str1)) { using (MySqlCommand cmd = new MySqlCommand()) { con.Open(); cmd.Connection = con; cmd.CommandText = _query; using (Adapter = new MySqlDataAdapter()) { Adapter.SelectCommand = cmd; Adapter.Fill(dt.table); dt.status = true; dt.value = ""; } } } } catch (MySqlException ex) { Gen_Error_Rpt.Write_Error("executeSelectQuery - Query: " + _query + "\n error - ", ex); dt.status = false; dt.message = ex.Message; } return(dt); }
public ReturnClass.ReturnDataTable Get_OfficeLevel(bl_empMap bl) { ReturnClass.ReturnDataTable rd = new ReturnClass.ReturnDataTable(); db_maria_connection db = new db_maria_connection(); string str = "select ol.OfficeLevelName as Office_level, ol.OfficeLevelCode as olc from officelevel ol "; string where = " where 1 = 1"; try { List <MySqlParameter> pm = new List <MySqlParameter>(); MySqlParameter fa = new MySqlParameter("BaseDeptCode", bl.Base_department_id); pm.Add(fa); where += " and ol.BaseDeptCode=@BaseDeptCode"; // } if (bl.Role_id == "4") { string officeLevel = "00"; MySqlParameter ca = new MySqlParameter("level", officeLevel); pm.Add(ca); where += " and OfficeLevelType=@level "; } str = str + where + " order by Office_level asc"; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return(rd); // string str = @"SELECT OfficeLevelCode, OfficeLevelName FROM officelevel WHERE officelevel.BaseDeptCode=@dept order by OfficeLevelName "; }
public ReturnClass.ReturnDataTable office_level(bl_report bl) { string str = "select ol.OfficeLevelName as Office_level, ol.OfficeLevelCode as olc from officelevel ol "; string where = " where 1 = 1"; try { List <MySqlParameter> pm = new List <MySqlParameter>(); MySqlParameter fa = new MySqlParameter("BaseDeptCode", bl.Base_department); pm.Add(fa); where += " and ol.BaseDeptCode=@BaseDeptCode"; if (bl.State != "" && bl.State != null && bl.State != "0" && bl.State != "Select") { MySqlParameter da = new MySqlParameter("state", bl.State); pm.Add(da); where += " and ol.StateCode= @state "; } if (bl.Role == "4") { MySqlParameter ca = new MySqlParameter("level", bl.Officelevelcode); pm.Add(ca); where += " and OfficeLevelType=@level "; } str = str + where + " order by Office_level asc"; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return(rd); }
/// <summary> /// Execute Select Query With Parameters using DataSet /// </summary> /// <param name="_query"></param> /// <param name="sqlParameter"></param> /// <returns></returns> public ReturnClass.ReturnDataSet executeSelectQuery_dataset(String _query, MySqlParameter[] sqlParameter) { ReturnClass.ReturnDataSet dt = new ReturnClass.ReturnDataSet(); try { using (MySqlConnection con = new MySqlConnection(con_str)) { using (MySqlCommand cmd = new MySqlCommand()) { con.Open(); cmd.Connection = con; cmd.CommandText = _query; cmd.Parameters.Clear(); cmd.Parameters.AddRange(sqlParameter); using (Adapter = new MySqlDataAdapter()) { Adapter.SelectCommand = cmd; Adapter.Fill(dt.dataset); dt.status = true; } } } } catch (MySqlException ec) { Gen_Error_Rpt.Write_Error("executeSelectQuery - Query: " + _query + "\n error - ", ec); dt.status = false; dt.message = ec.Message; } return(dt); }
public ReturnClass.ReturnBool executeDeleteQuery(String _query, MySqlParameter [] sqlParameter, String ls) { ReturnClass.ReturnBool dt = new ReturnClass.ReturnBool(); try { string con_str1 = GetConnectionString(ls); using (Adapter = new MySqlDataAdapter()) { using (MySqlConnection con = new MySqlConnection(con_str1)) { using (MySqlCommand cmd = new MySqlCommand()) { con.Open(); cmd.Connection = con; cmd.CommandText = _query; cmd.Parameters.AddRange(sqlParameter); Adapter.DeleteCommand = cmd; cmd.ExecuteNonQuery(); dt.status = true; } } } } catch (MySqlException exp) { Gen_Error_Rpt.Write_Error("executeUpdateQuery - Query: " + _query + "\n error - ", exp); dt.status = false; dt.message = exp.Message; } return(dt); }
/// <summary> /// Execute Update Query /// </summary> /// <param name="_query"></param> /// <param name="sqlParameter"></param> /// <returns></returns> /// public ReturnClass.ReturnBool executeUpdateQuery(String _query) { ReturnClass.ReturnBool dt = new ReturnClass.ReturnBool(); try { using (Adapter = new MySqlDataAdapter()) { using (MySqlConnection con = new MySqlConnection(con_str)) { using (MySqlCommand cmd = new MySqlCommand()) { con.Open(); cmd.Connection = con; cmd.CommandText = _query; Adapter.UpdateCommand = cmd; cmd.ExecuteNonQuery(); dt.status = true; } } } } catch (MySqlException exu) { Gen_Error_Rpt.Write_Error("executeUpdateQuery - Query: " + _query + "\n error - ", exu); dt.status = false; dt.message = exu.Message; } return(dt); }
/// <summary> /// This Method Exports The Given Grid View to Word File /// </summary> /// <returns>Word File</returns> public static void ExporttoWord(Page Current_Page_Name, GridView gv) { try { Current_Page_Name.Response.Clear(); Current_Page_Name.Response.Buffer = true; Current_Page_Name.Response.AddHeader("content-disposition", "attachment;filename=cgnicin.doc"); Current_Page_Name.Response.Charset = ""; Current_Page_Name.Response.ContentType = "application/vnd.ms-word "; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); gv.AllowPaging = false; gv.Caption = "Generated By http://cg.nic.in on " + System.DateTime.Now.ToString("dd MMMM yyyy") + " at " + System.DateTime.Now.ToString("h:mm:ss tt"); gv.CaptionAlign = TableCaptionAlign.Right; gv.DataBind(); gv.RenderControl(hw); Current_Page_Name.Response.Output.Write(sw.ToString()); Current_Page_Name.Response.Flush(); Current_Page_Name.Response.End(); } catch (ThreadAbortException) { } catch (Exception e) { Gen_Error_Rpt.Write_Error("Class:Utilitie | Method: ExporttoWord | Error:", e); } }
public ReturnClass.ReturnBool update_file_details(Upload_doc ud) { ReturnClass.ReturnBool rb = new ReturnClass.ReturnBool(); db_maria_connection db = new db_maria_connection(); //BA_layer ba = new BA_layer(); MySqlParameter[] param = new MySqlParameter[] { new MySqlParameter("f_id", ud.file_ID), //new MySqlParameter("file_id",ud.file_id), new MySqlParameter("Header", ud.Filename), new MySqlParameter("mime_type", ud.File_Extn), new MySqlParameter("file_data", ud.File_Data), new MySqlParameter("Client_Ip", ud.Client_ip), new MySqlParameter("User_Id", ud.User_id), new MySqlParameter("Date_Time", ud.Upload_Date) }; try { using (TransactionScope ts = new TransactionScope()) { string qur = "insert into notice_file_details_log select * from notice_file_details where file_id=@f_id"; rb = db.executeInsertQuery(qur, param); if (rb.status == true) { if (ud.Status != "Y") { string delQUr = "delete from notice_file_details where file_id=@f_id"; rb = db.executeDeleteQuery(delQUr, param); } else if (ud.Status == "Y") { string upqur = "update notice_file_details set File_Header=@Header,mime_type=@mime_type,file_data=@file_data," + "client_ip=@Client_Ip,user_code=@User_Id,upload_date=@Date_Time " + "where file_id=@f_id"; rb = db.executeUpdateQuery(upqur, param); } } if (rb.status == true) { ts.Complete(); } } } catch (Exception ex) { rb.status = false; Gen_Error_Rpt.Write_Error("Notice Edit Form - Update Method() :- " + ex.Message.ToString()); } return(rb); }
public ReturnClass.ReturnDataTable countOffice(bl_Dio bl) { string str = "", where = " where 1 = 1 "; try { List<MySqlParameter> pm = new List<MySqlParameter>(); if (bl.State != "" && bl.State != null && bl.State != "0" && bl.State != "Select") { MySqlParameter da = new MySqlParameter("state", bl.State); pm.Add(da); where += " and ofc.StateCode= @state "; } if (bl.District != "0" && bl.District != null && bl.District != "" && bl.District != "Select") { MySqlParameter ba = new MySqlParameter("district", bl.District); pm.Add(ba); where += " and ofc.DistrictCodeNew = @district "; } if (bl.Role == "4" ) { MySqlParameter ba = new MySqlParameter("officeLevelType", bl.Officelevelcode); pm.Add(ba); where += " and ol.OfficeLevelType = @officeLevelType "; } if ( bl.Role == "5") { MySqlParameter ba = new MySqlParameter("officeid", bl.Officeid); pm.Add(ba); where += " and ofc.NewOfficeCode = @officeid "; } str = @" select count(*) as office_count from office ofc inner join districts dic on dic.StateCode=ofc.StateCode and dic.district_id = ofc.DistrictCodeNew inner join basedepartment bd on bd.dept_id = ofc.BaseDeptCode inner join officelevel ol on ol.OfficeLevelCode = ofc.OfficeLevel and ol.StateCode= ofc.StateCode and ol.BaseDeptCode=ofc.BaseDeptCode " + where; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return rd; //string str = "select count(NewOfficeCode) as office_count from office"; // string str = @"select count(*) as office_count from office ofc // inner join districts dic on dic.StateCode=ofc.StateCode and dic.district_id = ofc.DistrictCodeNew // inner join basedepartment bd on bd.dept_id = ofc.BaseDeptCode // inner join officelevel ol on ol.OfficeLevelCode = ofc.OfficeLevel and ol.StateCode= ofc.StateCode and ol.BaseDeptCode=ofc.BaseDeptCode"; // rd = db.executeSelectQuery(str); // return rd; }
/// <summary> /// This Method Exports The Given Grid View to Excel File Without Formatting /// </summary> /// <returns>Excel File</returns> public static void ExporttoExcel_Withoutformatting(GridView gv) { try { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=cgnicin.xls")); HttpContext.Current.Response.ContentType = "application/ms-excel"; gv.AllowPaging = false; gv.DataBind(); using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter htw = new HtmlTextWriter(sw)) { // Create a form to contain the grid System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table(); table.GridLines = GridLines.Both; table.CaptionAlign = TableCaptionAlign.Right; table.Caption = "Generated By http://cg.nic.in on " + System.DateTime.Now.ToString("dd MMMM yyyy") + " at " + System.DateTime.Now.ToString("h:mm:ss tt"); // add the header row to the table if (gv.HeaderRow != null) { PrepareControlForExport(gv.HeaderRow); table.Rows.Add(gv.HeaderRow); } foreach (GridViewRow row in gv.Rows) { PrepareControlForExport(row); table.Rows.Add(row); } // add the footer row to the table if (gv.FooterRow != null) { PrepareControlForExport(gv.FooterRow); table.Rows.Add(gv.FooterRow); } // render the table into the htmlwriter table.RenderControl(htw); // render the htmlwriter into the response HttpContext.Current.Response.Write(sw.ToString()); HttpContext.Current.Response.End(); } } } catch (ThreadAbortException) { } catch (Exception e) { Gen_Error_Rpt.Write_Error("Class:Utilitie | Method: ExporttoExcel_Withoutformatting | Error:", e); } }
//public db_maria_connection() //{ //} /// <summary> /// Get Connection String /// </summary> /// <param name="_query"></param> /// <returns></returns> public static string GetConnectionString(string ls) { string con_str = ""; try { con_str = ConfigurationManager.ConnectionStrings[ls].ToString(); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("GetConnectionString : ", ex); } return(con_str); }
public ReturnClass.ReturnDataTable Get_DeptUserManual_File(Notice_Entry bl) { ReturnClass.ReturnDataTable rd = new ReturnClass.ReturnDataTable(); db_maria_connection db = new db_maria_connection(); string str = @" SELECT A.Dept_User_Manual_ID, A.User_ID, file_name, content_type as mime_type, file_data, file_description ,Year_Issue, dist.District_Name as dist_name, dept.dept_name as dept_name, ofc.OfficeName as ofc_name FROM dept_user_manual_file A left join districts dist on A.district_id_ofc = dist.District_ID left join basedepartment dept on A.base_department_id = dept.dept_id left join office ofc on A.office_id = ofc.NewOfficeCode and dept.dept_id= ofc.BaseDeptCode and dist.District_ID = ofc.DistrictCodeNew where 1 and 1 "; string end_where = " ORDER BY Year_Issue DESC "; string and_where = ""; try { List <MySqlParameter> pm = new List <MySqlParameter>(); if (bl.District_id != "0") { MySqlParameter fa = new MySqlParameter("District_ID", bl.District_id); pm.Add(fa); and_where += " and A.district_id_ofc = @District_ID "; } if (bl.Base_dept_id != "0") { MySqlParameter fa = new MySqlParameter("Base_department_id", bl.Base_dept_id); pm.Add(fa); and_where += " and base_department_id = @Base_department_id "; } if (bl.Office_id != "0") { MySqlParameter fa = new MySqlParameter("Office_id", bl.Office_id); pm.Add(fa); and_where += " and office_id = @Office_id "; } if ((bl.IssueYear != "0") && (bl.IssueYear != "")) { MySqlParameter fa = new MySqlParameter("issueYear", bl.IssueYear); pm.Add(fa); and_where += " and Year_Issue = @issueYear "; } str = str + and_where + end_where; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return(rd); }
public ReturnClass.ReturnDataTable GetTotalEmpMapInGrid(bl_Dio bl) { string str = "", where = " where 1 = 1 "; try { List<MySqlParameter> pm = new List<MySqlParameter>(); if (bl.District != "0" && bl.District != null && bl.District != "") { MySqlParameter ba = new MySqlParameter("district", bl.District); pm.Add(ba); where += " and A.district_id_ofc = @district "; } if (bl.Role == "4") { MySqlParameter ba = new MySqlParameter("officeLevelType", bl.Officelevelcode); pm.Add(ba); where += " and E.OfficeLevelType = @officeLevelType "; } if (bl.Role == "5") { MySqlParameter ba = new MySqlParameter("office_id", bl.Officeid); pm.Add(ba); where += " and C.NewOfficeCode = @office_id "; } str = @"select distinct A.office_mapping_id as mapping_id, A.emp_code as EmployeeCode, B.Name_en as EmpName, C.OfficeName as officeName, D.dept_name as DeptName , E.OfficeLevelName as OfficeLevelName , F.District_Name_En as DistName_En , G.OfficeCategoryName as OfficeCategoryName, A.user_id as UserID , H.DisplayName_en as ChangeTypeName, IF(A.active = 'Y', 'YES', 'No') as activeStatus from emp_office_mapping as A inner join employee_table as B on A.emp_code = B.emp_id inner join office as C on A.office_id = C.NewOfficeCode inner join basedepartment as D on A.base_department_id = D.dept_id inner join officelevel as E on A.office_level_id = E.OfficeLevelCode and A.base_department_id=E.BaseDeptCode inner join districts as F on A.district_id_ofc = F.District_ID inner join officecategory as G on A.office_category = G.OfficeCategoryCode inner join ddl_list as H on A.charge_type = H.DDL_Name_Value " + where + " order by A.office_mapping_id "; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return rd; }
public void bind_grid() { ReturnClass.ReturnDataTable dt = new ReturnClass.ReturnDataTable(); Notice_Entry ne = new Notice_Entry(); try { ne.pending = "P"; //ne.district_id = Session["Dist_Code"].ToString(); dt = dl.pending_for_approval(ne); //if (dt.table.Rows.Count > 0) //{ // GridView1.DataSource = dt.table; // GridView1.DataBind(); //} //else //{ // btnapprove.Visible = false; // } if (dt.table.Rows.Count > 0) { GridView1.DataSource = dt.table; GridView1.DataBind(); double c = Convert.ToInt32(dt.table.Rows.Count.ToString()); double cal = Math.Ceiling(c / 30); if (cal == 0) { cal = 1; } lblTotalBoilers.Text = "Total Records : " + dt.table.Rows.Count.ToString() + " (Page : 1 to " + cal + ")"; } else { btnapprove.Visible = false; GridView1.DataSource = dt.table; GridView1.DataBind(); lblTotalBoilers.Text = "Total Records : " + dt.table.Rows.Count.ToString(); } } catch (Exception ex) { Gen_Error_Rpt.Write_Error("admin_NewsEdit_List_bind_grid()", ex); Utilities.MessageBoxShow(ex.Message); } }
protected void lknBtnEdit_Click(object sender, EventArgs e) { try { LinkButton lnkbtn = sender as LinkButton; GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow; string fid = GridView1.DataKeys[gvrow.RowIndex].Values["File_Id"].ToString(); string nid = GridView1.DataKeys[gvrow.RowIndex].Values["Notice_Id"].ToString(); Response.Redirect("~/admin/NoticeEdit_Form.aspx?nid=" + nid + "&fid=" + fid, false); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("admin_News_Edit_lknBtnEdit_Click", ex); } }
public ReturnClass.ReturnDataTable countMappedEmp(bl_report bl) { string str = "", where = " where 1 = 1 "; try { List <MySqlParameter> pm = new List <MySqlParameter>(); if (bl.District != "0" && bl.District != null && bl.District != "" && bl.District != "Select") { MySqlParameter ba = new MySqlParameter("district", bl.District); pm.Add(ba); where += " and district_id_ofc = @district "; } if (bl.Role == "4") { MySqlParameter ba = new MySqlParameter("officeLevelType", bl.Officelevelcode); pm.Add(ba); where += " and ol.OfficeLevelType = @officeLevelType "; } if (bl.Role == "5") { MySqlParameter ba = new MySqlParameter("office_id", bl.Officeid); pm.Add(ba); where += " and ofc.NewOfficeCode = @office_id "; } str = @"select count(office_mapping_id) as office_map_count from emp_office_mapping as emp_map inner join office ofc on ofc.NewOfficeCode = emp_map.office_id inner join districts dic on dic.StateCode=ofc.StateCode and dic.district_id = ofc.DistrictCodeNew inner join basedepartment bd on bd.dept_id = ofc.BaseDeptCode inner join officelevel ol on ol.OfficeLevelCode = ofc.OfficeLevel and ol.StateCode= ofc.StateCode and ol.BaseDeptCode=ofc.BaseDeptCode " + where; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return(rd); }
public ReturnClass.ReturnDataTable GetTotalDepartmentInGrid1() { ReturnClass.ReturnDataTable rt = new ReturnClass.ReturnDataTable(); db_maria_connection db = new db_maria_connection(); string str = ""; try { str = @"select dept_id, dept_name from basedepartment order by dept_id"; rt = db.executeSelectQuery(str); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return(rt); }
public ReturnClass.ReturnDataTable GetTotalEmployeeInGrid(bl_report bl) { string str = "", where = " where 1 = 1 "; try { List <MySqlParameter> pm = new List <MySqlParameter>(); if (bl.State != "" && bl.State != null && bl.State != "0") { MySqlParameter da = new MySqlParameter("state", bl.State); pm.Add(da); where += " and emp.state_id= @state "; } if (bl.District != "0" && bl.District != null && bl.District != "") { MySqlParameter ba = new MySqlParameter("district", bl.District); pm.Add(ba); where += " and emp.district_id = @district "; } if (bl.Role == "5") { MySqlParameter ba = new MySqlParameter("ofc_code", bl.Officeid); pm.Add(ba); where += " and emp.NewOfficeCode = @ofc_code "; } str = @" select emp.emp_id as id, emp.Name_en as empname,emp.mobile_no as mblname, dic.District_Name as dist, bd.dept_name as depnm, ofc.OfficeName as office, emp.email_id as email, st.state_name_e as state from employee_table emp left join office ofc on ofc.DistrictCodeNew=emp.district_id and ofc.BaseDeptCode= emp.base_department_id and ofc.StateCode = emp.state_id and ofc.NewOfficeCode=emp.NewOfficeCode left join districts dic on dic.StateCode = emp.state_id and dic.District_ID = emp.district_id left join basedepartment bd on bd.dept_id = emp.base_department_id left join state st on st.state_id=emp.state_id " + where + " order by emp.emp_id "; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return(rd); }
public ReturnClass.ReturnDataTable GetTotalPIOInGrid(bl_report bl) { ReturnClass.ReturnDataTable rt = new ReturnClass.ReturnDataTable(); db_maria_connection db = new db_maria_connection(); string str = ""; try { str = @"select emp.Name_en from employee_table emp inner join emp_office_mapping eom on eom.emp_code=emp.emp_id where eom.designation_id='2' "; rt = db.executeSelectQuery(str); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return(rt); }
/// <summary> /// This Method Exports The Given Grid View to PDF /// </summary> /// <returns>PDF File</returns> public static void ExporttoPDF(Page Current_Page_Name, GridView gv) { try { Current_Page_Name.Response.ContentType = "application/pdf"; Current_Page_Name.Response.AddHeader("content-disposition", "attachment;filename=cgnicin.pdf"); Current_Page_Name.Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); //iTextSharp.text.pdf.BaseFont STF_Mangal = iTextSharp.text.pdf.BaseFont.CreateFont(@"C:\Windows\Fonts\Mangal.ttf", "Identity-H", iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED); //iTextSharp.text.Font fontNormal = new iTextSharp.text.Font(STF_Mangal, 12, iTextSharp.text.Font.NORMAL); gv.AllowPaging = false; gv.DataBind(); gv.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Current_Page_Name.Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Current_Page_Name.Response.Write(pdfDoc); Current_Page_Name.Response.Flush(); Current_Page_Name.Response.End(); } catch (ThreadAbortException) { } catch (Exception e) { Gen_Error_Rpt.Write_Error("Class:Utilitie | Method: ExporttoPDF | Error:", e); } }
public ReturnClass.ReturnDataTable countEmp(bl_Dio bl) { string str = "", where = " where 1 = 1 "; try { List<MySqlParameter> pm = new List<MySqlParameter>(); if (bl.State != "" && bl.State != null && bl.State != "0" && bl.State != "Select") { MySqlParameter da = new MySqlParameter("state", bl.State); pm.Add(da); where += " and state_id= @state "; } if (bl.District != "0" && bl.District != null && bl.District != "" && bl.District != "Select") { MySqlParameter ba = new MySqlParameter("district", bl.District); pm.Add(ba); where += " and district_id = @district "; } if (bl.Role == "5") { MySqlParameter ba = new MySqlParameter("ofc_code", bl.Officeid); pm.Add(ba); where += " and NewOfficeCode = @ofc_code "; } str = @" select count(Name_en) as empcount from employee_table " + where ; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return rd; }
/// <summary> /// This Method Exports The Given Grid View to Excel File With Formatting /// </summary> /// <returns>Excel File</returns> public static void ExporttoExcel_WithFormatting(Page Current_Page_Name, GridView gv) { try { Current_Page_Name.Response.Clear(); Current_Page_Name.Response.AddHeader("content-disposition", "attachment;filename=cgnicin.xls"); gv.AllowPaging = false; gv.Caption = "Generated By http://cg.nic.in on " + System.DateTime.Now.ToString("dd MMMM yyyy") + " at " + System.DateTime.Now.ToString("h:mm:ss tt"); gv.CaptionAlign = TableCaptionAlign.Right; gv.DataBind(); Current_Page_Name.Response.Charset = ""; // If you want the option to open the Excel file without saving than // comment out the line below // Response.Cache.SetCacheability(HttpCacheability.NoCache); Current_Page_Name.Response.ContentType = "application/vnd.xls"; using (System.IO.StringWriter stringWrite = new System.IO.StringWriter()) { using (System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite)) { gv.RenderControl(htmlWrite); Current_Page_Name.Response.Write(stringWrite.ToString()); Current_Page_Name.Response.End(); } } } catch (ThreadAbortException) { } catch (Exception e) { Gen_Error_Rpt.Write_Error("Class:Utilitie | Method: ExporttoExcel_WithFormatting | Error:", e); } }
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); } } } }
protected void Button1_Click(object sender, EventArgs e) { try { if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString()) { Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString()); Echallan_DS ds = new Echallan_DS(); echallanSoapClient cl = new echallanSoapClient(); ds = cl.eChallan_srv(txt_Ref_No.Text.Trim(), "11"); // ds = cl.eChallan_srv(txt_Ref_No.Text.Trim(), "01"); if (ds.TR_REFNO == txt_Ref_No.Text.Trim()) { // Minor head can be 000 ,103, 105, 108 //if (ds.MAJORHEAD == "0051" && ds.SUBMAJORHEAD == "00" && (ds.MINORHEAD == "000" || ds.MINORHEAD == "103" || ds.MINORHEAD == "105" || ds.MINORHEAD == "108") && ds.SUBHEAD == "0000") if (ds.MAJORHEAD == "1475" && ds.SUBMAJORHEAD == "00" && ds.MINORHEAD == "200" && ds.SUBHEAD == "0000") { txt_tin_cin.Text = ds.TIN_CIN; txtamount.Text = ds.AMOUNT; txt_ent_date.Text = ds.ENTRYDATE; txt_acc_date.Text = ds.DATE_AC; txt_major_head.Text = ds.MAJORHEAD; txt_sub_major_head.Text = ds.SUBMAJORHEAD; txt_sub_head.Text = ds.SUBHEAD; txt_major_head.Text = ds.MAJORHEAD; txt_purpose.Text = ds.PURPOSE; txt_minor_head.Text = ds.MINORHEAD; } else { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Please Enter Correct Treasury Reference Number...(Treasury Heads are Incorrect)"); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "कृपया सही खजाना संदर्भ संख्या दर्ज करें...(खजाना हेड्स गलत हैं)"); } } } else { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Please Enter Correct Treasury Reference Number..."); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "कृपया सही खजाना संदर्भ संख्या दर्ज करें."); } } } } catch (Exception ex) { Gen_Error_Rpt.Write_Error("PayFees.aspx.cs-Button1_Click", ex); if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Unable to get Challan details..."); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "चालान विवरण प्राप्त करने में असमर्थ..."); } } }
protected void Button2_Click(object sender, EventArgs e) { ReturnClass.ReturnDataTable dt = new ReturnClass.ReturnDataTable(); try { if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString()) { Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString()); if (Page.IsValid) { ec.Tr_ref_no = txt_Ref_No.Text.Trim(); ec.Serial_no = serialno(); ec.Amount = txtamount.Text.Trim(); ec.Major_head = txt_major_head.Text; ec.Sub_major_head = txt_sub_major_head.Text; ec.Sub_head = txt_sub_head.Text; ec.Minor_head = txt_minor_head.Text; ec.Purpose = txt_purpose.Text; ec.Challan_Category = "RTI Registration"; // ec.Challan_Category = "Society Registration"; //ec.Firm_society_category = "Society"; ec.Fees_master_code = fee; if (txt_acc_date.Text.Trim() == "") { ec.Date_ac = ""; } else { DateTime date_ac = Convert.ToDateTime(txt_acc_date.Text); ec.Date_ac = date_ac.ToString("yyyy/MM/dd"); } if (txt_ent_date.Text.Trim() == "") { ec.Tr_entry_date = ""; } else { DateTime tr_entry_date = Convert.ToDateTime(txt_ent_date.Text); ec.Tr_entry_date = tr_entry_date.ToString("yyyy/MM/dd"); } ec.Tin_cin = txt_tin_cin.Text; ec.Society_provisional_no = Session["RTI_ID"].ToString(); try { dt = dl.select_tr_ref_no(ec); if (dt.table.Rows.Count > 0) { if (dt.table.Rows[0]["tr_ref_no"].ToString() == txt_Ref_No.Text.Trim()) { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Ref No. Already Exists..."); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "संदर्भ संख्या पहले से मौजूद है..."); } } MYClear(); } else { ec.Date_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); ec.Client_ip = util.GetClientIpAddress(this.Page); ec.User_id = Session["username"].ToString(); //ec.User_id = "12345"; rb = dl.insert_echallan_details(ec); if (rb.status == true) { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "e-challan details saved successfully"); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "ई-चालान विवरण सफलतापूर्वक सुरक्षित किए गए"); } MYClear(); btn_close.Visible = true; } else { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Records could not be saved: Please Try Again"); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "रिकॉर्ड्स को सुरक्षित नहीं किया जा सका: कृपया पुनः प्रयास करें"); } } getrecord(); } } catch (Exception ex) { Gen_Error_Rpt.Write_Error("eChallan.aspx (save) :", ex); if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Records could not be saved: Please Try Again"); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "रिकॉर्ड्स को सुरक्षित नहीं किया जा सका: कृपया पुनः प्रयास करें"); } // Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Records could not be saved: Please Try Again"); } finally { } } else { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Please fill all the required fields."); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "कृपया सभी आवश्यक फ़ील्ड भरें।"); } } } else { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Page refresh or back button is not allowed."); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, " पेज रिफ्रेश या बैक बटन की अनुमति नहीं है"); } // Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Page refresh or back button is not allowed."); } } catch { if (Session["language"].ToString() == "en-GB") { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Records could not be saved: Please Try Again"); } else { Utilities.MessageBox_UpdatePanel(UpdatePanel3, "रिकॉर्ड्स को सुरक्षित नहीं किया जा सका: कृपया पुनः प्रयास करें"); } //Utilities.MessageBox_UpdatePanel(UpdatePanel3, "Records could not be saved: Please Try Again"); } finally { } }// Button2_click End
public ReturnClass.ReturnDataTable Get_NoticeRecords(Notice_Entry bl) { ReturnClass.ReturnDataTable rd = new ReturnClass.ReturnDataTable(); db_maria_connection db = new db_maria_connection(); string str = @" SELECT A.Notice_Id, Header, A.File_Id, DATE_FORMAT(Validity_From,'%d/%m/%Y') as publishdate, ( CASE WHEN File_Header is NULL THEN 'No File' ELSE File_Header END ) as filename, mime_type, file_data, dist.District_Name as dist_name, dept.dept_name as dept_name, ofc.OfficeName as ofc_name FROM notice_board A left join notice_file_details B on A.File_Id=B.file_id left join districts dist on A.district_id = dist.District_ID left join basedepartment dept on A.base_dept_id = dept.dept_id left join office ofc on A.office_id = ofc.NewOfficeCode and dept.dept_id= ofc.BaseDeptCode and dist.District_ID = ofc.DistrictCodeNew where 1 and 1 "; string end_where = " ORDER BY Validity_From DESC "; string and_where = ""; try { List <MySqlParameter> pm = new List <MySqlParameter>(); if (bl.NoticeID != null && bl.NoticeID != "") { MySqlParameter fa = new MySqlParameter("notice_id", "%" + bl.NoticeID + "%"); pm.Add(fa); and_where += " and A.Notice_Id LIKE @notice_id "; } if (bl.Header != null && bl.Header != "") { MySqlParameter fa = new MySqlParameter("Header", "%" + bl.Header + "%"); pm.Add(fa); and_where += " and Header LIKE @Header "; } if (bl.Validity_From != null && bl.Validity_From != "" && bl.Validity_To != null & bl.Validity_To != "") { MySqlParameter fa = new MySqlParameter("Start_Date", bl.Validity_From); pm.Add(fa); fa = new MySqlParameter("End_Date", bl.Validity_To); pm.Add(fa); and_where += " and ( Validity_From >= @Start_Date and Validity_To <= @End_Date ) "; } else if (bl.Validity_From != null && bl.Validity_From != "" && (bl.Validity_To == null || bl.Validity_To == "")) { MySqlParameter fa = new MySqlParameter("Start_Date", bl.Validity_From); pm.Add(fa); fa = new MySqlParameter("NextDate", bl.Next_date); pm.Add(fa); and_where += " and startdate >= @Start_Date and startdate < @NextDate "; } if (bl.KeywordSearch != null && bl.KeywordSearch != "") { MySqlParameter fa = new MySqlParameter("KeywordSearch", "%" + bl.KeywordSearch + "%"); pm.Add(fa); and_where += " and Notice_keyword LIKE @KeywordSearch "; } if (bl.District_id != "0") { MySqlParameter fa = new MySqlParameter("District_ID", bl.District_id); pm.Add(fa); and_where += " and A.district_id = @District_ID "; } if (bl.Base_dept_id != "0") { MySqlParameter fa = new MySqlParameter("Base_department_id", bl.Base_dept_id); pm.Add(fa); and_where += " and base_dept_id = @Base_department_id "; } if (bl.Office_id != "0") { MySqlParameter fa = new MySqlParameter("Office_id", bl.Office_id); pm.Add(fa); and_where += " and office_id = @Office_id "; } str = str + and_where + end_where; rd = db.executeSelectQuery(str, pm.ToArray()); } catch (Exception ex) { Gen_Error_Rpt.Write_Error("../dio/dl_Dio/Bind_Grid log.txt"); } return(rd); }
public ReturnClass.ReturnBool update_notice(Notice_Entry ne) { ReturnClass.ReturnBool rb = new ReturnClass.ReturnBool(); db_maria_connection db = new db_maria_connection(); //BA_layer ba = new BA_layer(); MySqlParameter[] param = new MySqlParameter[] { new MySqlParameter("Header", ne.Header), new MySqlParameter("Pernament", ne.Permanent), new MySqlParameter("Publish_Date", ne.Publish_date), new MySqlParameter("Validity_From", ne.Datefrom), new MySqlParameter("Validity_To", ne.Dateto), new MySqlParameter("Active", ne.Active), new MySqlParameter("Hyperlink", ne.Hyperlink), new MySqlParameter("File_Type", ne.Filetype), new MySqlParameter("File_Id", ne.file_ID), new MySqlParameter("Url", ne.Url), new MySqlParameter("Client_Ip", ne.Client_ip), new MySqlParameter("User_Id", ne.User_id), new MySqlParameter("Date_Time", ne.Datetime), new MySqlParameter("Notice_Id", ne.NoticeID), new MySqlParameter("bold", ne.Bold), new MySqlParameter("blink", ne.Blink), new MySqlParameter("priority", ne.Priority), new MySqlParameter("color", ne.Color), new MySqlParameter("image", ne.Image), new MySqlParameter("district_id", ne.District_id), new MySqlParameter("dept_id", ne.Base_dept_id), new MySqlParameter("ofc_id", ne.Office_id) }; try { using (TransactionScope ts = new TransactionScope()) { string qur = "insert into notice_board_log select * from Notice_Board where Notice_Id=@Notice_Id"; rb = db.executeInsertQuery(qur, param); if (rb.status == true) { string upqur = "update notice_board set Header=@Header,Permanent=@Pernament,Publish_Date=@Publish_Date,Validity_From=@Validity_From, " + " Validity_To=@Validity_To,Active=@Active,Hyperlink=@Hyperlink,File_Type=@File_Type, " + " Url=@Url,Client_Ip=@Client_Ip,User_Id=@User_Id,Date_Time=@Date_Time,bold=@bold,blink=@blink,priority=@priority,color=@color,image=@image,File_Id=@File_Id , " + " district_id=@district_id, base_dept_id=@dept_id, office_id=@ofc_id " + " where Notice_Id=@Notice_Id "; rb = db.executeUpdateQuery(upqur, param); } if (rb.status == true) { ts.Complete(); } } } catch (Exception ex) { rb.status = false; Gen_Error_Rpt.Write_Error("Notice Edit Form - Update Method() :- " + ex.Message.ToString()); } return(rb); }
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); } } } }
public void show() { ReturnClass.ReturnDataTable dt = new ReturnClass.ReturnDataTable(); dl_rti_notice dl = new dl_rti_notice(); Notice_Entry ba = new Notice_Entry(); ba.NoticeID = Request.QueryString["nid"].ToString(); try { dt = dl.LoadNotice(ba); if (dt.table.Rows.Count > 0) { ddl_department.SelectedValue = dt.table.Rows[0]["base_dept_id"].ToString(); ddl_district.SelectedValue = dt.table.Rows[0]["district_id"].ToString(); OfficeBind(); ddl_office.SelectedValue = dt.table.Rows[0]["office_id"].ToString(); txtHeader.Text = dt.table.Rows[0]["header"].ToString(); //lblpreview.Text = txtHeader.Text; //Image1.ImageUrl = dt.table.Rows[0]["image"].ToString(); if (dt.table.Rows[0]["permanent"].ToString() == "Yes") { ddlPermanent.SelectedValue = "Y"; //divPublishDate.Visible = true; // txtPublishDate.Text = Convert.ToDateTime(dt.table.Rows[0]["Publish_Date"]).ToString("dd/MM/yyyy HH:mm:ss"); txtPublishDate.Text = Convert.ToString(dt.table.Rows[0]["Publish_Date"].ToString()); RequiredFieldValidator9.Enabled = false; RequiredFieldValidator9.ValidationGroup = "x"; RegularExpressionValidator10.Enabled = false; RegularExpressionValidator10.ValidationGroup = "x"; RequiredFieldValidator10.Enabled = false; RequiredFieldValidator10.ValidationGroup = "x"; RegularExpressionValidator17.Enabled = false; RegularExpressionValidator17.ValidationGroup = "x"; } else if (dt.table.Rows[0]["permanent"].ToString() == "No") { ddlPermanent.SelectedValue = "N"; // divPublishDate.Visible = false; // divFrom.Visible = true; // divTo.Visible = true; txtDateFrom.Text = Convert.ToString(dt.table.Rows[0]["Validity_From"].ToString()); txtDateTo.Text = Convert.ToString(dt.table.Rows[0]["Validity_To"].ToString()); RequiredFieldValidator7.Enabled = false; RequiredFieldValidator7.ValidationGroup = "x"; RegularExpressionValidator1.Enabled = false; RegularExpressionValidator1.ValidationGroup = "x"; } if (dt.table.Rows[0]["active"].ToString() == "Active") { ddlActive.SelectedValue = "A"; } else if (dt.table.Rows[0]["active"].ToString() == "Inactive") { ddlActive.SelectedValue = "D"; } if (dt.table.Rows[0]["hyperlink"].ToString() == "Yes") { ddlHyperlink.SelectedValue = "Y"; RequiredFieldValidator3.Enabled = false; RequiredFieldValidator3.ValidationGroup = "x"; //divType.Visible = true; } else if (dt.table.Rows[0]["hyperlink"].ToString() == "No") { 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; } else { RequiredFieldValidator3.Enabled = true; RequiredFieldValidator3.ValidationGroup = "a"; } if (dt.table.Rows[0]["file_type"].ToString() == "Internal") { ddlType.SelectedValue = "I"; //divFileUpload.Visible = true; RequiredFieldValidator6.Enabled = true; RequiredFieldValidator6.ValidationGroup = "a"; RequiredFieldValidator4.Enabled = false; RequiredFieldValidator4.ValidationGroup = "x"; regUrl.ValidationGroup = "x"; regUrl.Enabled = false; } else if (dt.table.Rows[0]["file_type"].ToString() == "External") { ddlType.SelectedValue = "E"; //divUrl.Visible = true; txtUrl.Text = dt.table.Rows[0]["url"].ToString(); RequiredFieldValidator6.Enabled = false; RequiredFieldValidator6.ValidationGroup = "x"; } if (dt.table.Rows[0]["bold"].ToString() == "Y") { RadioButtonListbold.SelectedValue = "Yes"; } else if (dt.table.Rows[0]["bold"].ToString() == "N") { RadioButtonListbold.SelectedValue = "No"; } if (dt.table.Rows[0]["blink"].ToString() == "Y") { RadioButtonListblink.SelectedValue = "Yes"; } else if (dt.table.Rows[0]["blink"].ToString() == "N") { RadioButtonListblink.SelectedValue = "No"; } if (dt.table.Rows[0]["priority"].ToString() == "H") { ddlpriority.SelectedValue = "H"; } else if (dt.table.Rows[0]["priority"].ToString() == "M") { ddlpriority.SelectedValue = "M"; } else if (dt.table.Rows[0]["priority"].ToString() == "L") { ddlpriority.SelectedValue = "L"; } color.Text = dt.table.Rows[0]["color"].ToString(); // ColorPicker1.SelectedColor = color.Text; } } catch (Exception ex) { Gen_Error_Rpt.Write_Error("admin_NewsEdit_Form.aspx_show()", ex); } }