/// <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_Race("", "R", 0, 0, txtfilter.Text != "" ? txtfilter.Text : null, sortbycoloumn, sortdirection, null, null, ref rowcount, ref Result);

            string[] HeaderCaptions  = { "Race" };
            string[] DataColumnsName = { "Race" };

            GridViewExportUtil.ShowExcel(dt, HeaderCaptions, DataColumnsName, "Race", "Race", "");
        }
        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_Race("", "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);
            }

            BindRace();
        }
        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(hdnRaceID.Value) > 0)
            {
                int            rowcount = 0;
                BLL_Crew_Admin objBLL   = new BLL_Crew_Admin();
                DataTable      dt       = objBLL.CRUD_Race(txtRace.Text.Trim(), "U", GetSessionUserID(), Convert.ToInt32(hdnRaceID.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 Race 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);
                    BindRace();
                }
            }
            else
            {
                int            rowcount = 0;
                BLL_Crew_Admin objBLL   = new BLL_Crew_Admin();
                DataTable      dt       = objBLL.CRUD_Race(txtRace.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 Race 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);
                    BindRace();
                }
            }
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
        }
    }
    /// <summary>
    /// Bind Race
    /// </summary>
    public void BindRace()
    {
        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_Race("", "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)
            {
                gvRace.DataSource = dt;
                gvRace.DataBind();
                ImgExpExcel.Visible = true;
            }
            else
            {
                gvRace.DataSource = null;
                gvRace.DataBind();
                ImgExpExcel.Visible = false;
            }
        }
        catch (Exception ex) { UDFLib.WriteExceptionLog(ex); }
    }