protected void BindUnion() { ddlUnion.DataSource = objCrewAdmin.CRUD_Union("", "R", 0, 0, null, null, null, 1, 100, ref i, ref i); ddlUnion.DataValueField = "ID"; ddlUnion.DataTextField = "UnionName"; ddlUnion.DataBind(); ddlUnion.Items.Insert(0, new ListItem("-SELECT-", "0")); }
/// <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_Union("", "D", GetSessionUserID(), Convert.ToInt32(e.CommandArgument.ToString()), null, "", null, null, null, ref rowcount, ref Result).Tables[0]; if (Result > 0) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ShowMessage", "alert('Record deleted successfully')", true); } BindUnion(); } 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(hdnUnionID.Value) > 0) { int rowcount = 0; BLL_Crew_Admin objBLL = new BLL_Crew_Admin(); DataTable dt = objBLL.CRUD_Union(txtUnion.Text.Trim(), "U", GetSessionUserID(), Convert.ToInt32(hdnUnionID.Value), null, "", null, null, null, ref rowcount, ref Result).Tables[0]; ///Result == 2 Already exists if (Result < 0) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('The selected Union 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); BindUnion(); } } else { int rowcount = 0; BLL_Crew_Admin objBLL = new BLL_Crew_Admin(); DataTable dt = objBLL.CRUD_Union(txtUnion.Text.Trim(), "I", GetSessionUserID(), 0, null, "", null, null, null, ref rowcount, ref Result).Tables[0]; ///Result == 2 Already exists if (Result < 0) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('The selected Union 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); BindUnion(); } } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
/// <summary> /// Bind Union /// </summary> public void BindUnion() { 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(); DataSet dt = objBLL.CRUD_Union("", "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.Tables[0].Rows.Count > 0) { gvUnion.DataSource = dt.Tables[0]; gvUnion.DataBind(); drpUnion.DataSource = dt.Tables[0]; drpUnion.DataTextField = "UnionName"; drpUnion.DataValueField = "ID"; drpUnion.DataBind(); drpUnion.Items.Insert(0, new ListItem() { Text = "-Select-", Value = "0" }); divBranch.Visible = false; gvUnionBranch.DataSource = null; gvUnionBranch.DataBind(); } else { gvUnion.DataSource = null; gvUnion.DataBind(); } if (dt.Tables[1].Rows.Count > 0) { drpCountry.DataSource = dt.Tables[1]; drpCountry.DataTextField = "Country_Name"; drpCountry.DataValueField = "ID"; drpCountry.DataBind(); drpCountry.Items.Insert(0, new ListItem() { Text = "-Select-", Value = "0" }); dt.Tables[1].DefaultView.RowFilter = ""; dt.Tables[1].DefaultView.RowFilter = "ISO_Code='US'"; if (dt.Tables[1].DefaultView.Count > 0) { hdnUSCountryID.Value = Convert.ToString(dt.Tables[1].DefaultView[0]["ID"]); } } if (dt.Tables[2].Rows.Count > 0) { ///0- US Client ///1- International Client if (Convert.ToInt32(dt.Tables[2].Rows[0]["Value"]) == 0) { hdnAddressType.Value = "0"; trUSAddress.Visible = true; trInternationAddress.Visible = false; } else { hdnAddressType.Value = "1"; trInternationAddress.Visible = true; trUSAddress.Visible = false; } } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }