/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ImgExpExcel_Click(object sender, EventArgs e) { try { int rowcount = ucCustomPagerItems.isCountRecord; string sortbycoloumn = (ViewState["SORTBYCOLOUMN"] == null) ? null : (ViewState["SORTBYCOLOUMN"].ToString()); int? sortdirection = null; if (ViewState["SORTDIRECTION"] != null) { sortdirection = Int32.Parse(ViewState["SORTDIRECTION"].ToString()); } BLL_Crew_Admin objBLL = new BLL_Crew_Admin(); DataTable dt = objBLL.CRUD_School("", "R", 0, 0, txtfilter.Text != "" ? txtfilter.Text : null, sortbycoloumn, sortdirection, null, null, ref rowcount, ref Result); string[] HeaderCaptions = { "School" }; string[] DataColumnsName = { "School" }; GridViewExportUtil.ShowExcel(dt, HeaderCaptions, DataColumnsName, "School", "School", ""); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
/// <summary> /// Delete Oil Major /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void onDelete(object source, CommandEventArgs e) { try { int rowcount = 0; BLL_Crew_Admin objBLL = new BLL_Crew_Admin(); DataTable dt = objBLL.CRUD_School("", "D", GetSessionUserID(), Convert.ToInt32(e.CommandArgument.ToString()), null, "", null, null, null, ref rowcount, ref Result); if (Result > 0) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ShowMessage", "alert('Record deleted successfully')", true); } BindSchool(); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
/// <summary> /// To save or update oil major /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnsave_OnClick(object sender, EventArgs e) { try { if (Convert.ToInt32(hdnSchoolID.Value) > 0) { int rowcount = 0; BLL_Crew_Admin objBLL = new BLL_Crew_Admin(); DataTable dt = objBLL.CRUD_School(txtSchool.Text.Trim(), "U", GetSessionUserID(), Convert.ToInt32(hdnSchoolID.Value), null, "", null, null, null, ref rowcount, ref Result); ///Result == 2 Already exists if (Result < 0) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('The selected School already exist in the system');showModal('divadd', false);", true); } else if (Result > 0) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('" + UDFLib.GetException("SuccessMessage/UpdateMessage") + "');hideModal('divadd');", true); BindSchool(); } } else { int rowcount = 0; BLL_Crew_Admin objBLL = new BLL_Crew_Admin(); DataTable dt = objBLL.CRUD_School(txtSchool.Text.Trim(), "I", GetSessionUserID(), 0, null, "", null, null, null, ref rowcount, ref Result); ///Result == 2 Already exists if (Result < 0) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('The selected School already exist in the system');showModal('divadd', false);", true); } else if (Result > 0) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('" + UDFLib.GetException("SuccessMessage/SaveMessage") + "');hideModal('divadd');", true); BindSchool(); } } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
/// <summary> /// Bind School /// </summary> public void BindSchool() { try { int rowcount = ucCustomPagerItems.isCountRecord; string sortbycoloumn = (ViewState["SORTBYCOLOUMN"] == null) ? null : (ViewState["SORTBYCOLOUMN"].ToString()); int? sortdirection = null; if (ViewState["SORTDIRECTION"] != null) { sortdirection = Int32.Parse(ViewState["SORTDIRECTION"].ToString()); } BLL_Crew_Admin objBLL = new BLL_Crew_Admin(); DataTable dt = objBLL.CRUD_School("", "R", 0, 0, txtfilter.Text != "" ? txtfilter.Text : null, sortbycoloumn, sortdirection , ucCustomPagerItems.CurrentPageIndex, ucCustomPagerItems.PageSize, ref rowcount, ref Result); if (ucCustomPagerItems.isCountRecord == 1) { ucCustomPagerItems.CountTotalRec = rowcount.ToString(); ucCustomPagerItems.BuildPager(); } if (dt.Rows.Count > 0) { gvSchool.DataSource = dt; gvSchool.DataBind(); ImgExpExcel.Visible = true; } else { gvSchool.DataSource = null; gvSchool.DataBind(); ImgExpExcel.Visible = false; } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }