using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;


public partial class Masters_TA_UI_Master_TaxPolicyModify : Base.BasePage 
{
    cls_Common objCommon = new cls_Common();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    ResourceManager rm;
    CultureInfo ci;
    PayrollConfigurationEventData objPayrollEventData = new PayrollConfigurationEventData();
    ShiftEvenData objShift = new ShiftEvenData();
    EmployeeEventData objEmployeeEventData = new EmployeeEventData();
    string gstrUserGroupName = string.Empty;
    Table tbl_TdsSlab = new Table();
    Table tbl_ProfessSlab = new Table();
    DataSet dsTaxPolicy = new DataSet();
    //Tbl_Class tblClass;
    List<string> controlList = new List<string>();
    Dictionary<string, string> txtDiscValue;
    int counter = 0;
    string source_Language;
    string strScript = string.Empty;
    Int32 intPolicyID;
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);

        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        //LoadStrings Function fills the Label from the Resource File

        LoadStrings(ci);
        gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
        intPolicyID = Convert.ToInt32(Request.QueryString["Policy_Id"]);
        Hashtable tdsTable = new Hashtable();
        tdsTable.Add("@tag", "P");
        tdsTable.Add("@TaxPolicyID", intPolicyID);
        dsTaxPolicy = objPayrollEventData.InsertTaxPolicy(tdsTable);


        if (!IsPostBack)
        {
            Session["ddlCompanyName"] = Convert.ToInt16(ddlCompany.SelectedValue);
            Session["ddlEmployeeCategory"] = Convert.ToInt16(ddlEmpCatagory.SelectedValue);
            Session["ddlEmployeeType"] = Convert.ToInt16(ddlEmpType.SelectedValue);
            Session["ddlGender"] = Convert.ToInt16(ddlGender.SelectedValue);
            BindingEmployeeCategoryandType();
            objCommon.menu("PayrollMaster", "317");
            CompanyBinding();
            Session["SlabCount"] = dsTaxPolicy.Tables[1].Rows.Count;
            Session["ProfSlabCount"] =dsTaxPolicy.Tables[2].Rows.Count;
            TableCreate();
            BindTdsData();
            PH_DynmCtrl.Controls.Add(tbl_TdsSlab);
            ProfessionalTaxTableCreate();
            BindProfData();
            PHProfess_DynCtrl.Controls.Add(tbl_ProfessSlab);

           
        }
        else
        {

            TaxSlabAutoGenerate(Session["SlabCount"]);
            PH_DynmCtrl.Controls.Add(tbl_TdsSlab);
           
            DynamicProfessionalSlabCreate(Session["ProfSlabCount"]);
            PHProfess_DynCtrl.Controls.Add(tbl_ProfessSlab);
        }

    }


    private void BindTdsData()
    {
        if (dsTaxPolicy != null && dsTaxPolicy.Tables[0].Rows.Count > 0)
        {

            if (Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["companyid"]) != null)
            {
                ddlCompany.SelectedValue = Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["companyid"]);
            }

            if (Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["TaxPolicyName"]) != null)
            {
                txt_PolicyName.Text = Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["TaxPolicyName"]);
            }
            if (Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["Gender"]) != null)
            {
                if(Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["Gender"])=="Male")
                {
                    ddlGender.SelectedIndex =1;
                }
                else if(Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["Gender"]) == "Female")
                {
                    ddlGender.SelectedIndex = 2;
                }
                else
                {
                    ddlGender.SelectedIndex = 0;
                }
               
            }
            else
            {
                ddlGender.SelectedIndex = 0;
            }
           if (Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["EmployeeType"]) != null)
            {
                ddlEmpType.SelectedValue = Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["EmployeeType"]);
            }
            else
            {
                ddlEmpType.SelectedIndex = 0;
            }
            if (Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["EmployeeCategory"]) != null)
            {
                ddlEmpCatagory.SelectedValue = Convert.ToString(dsTaxPolicy.Tables[0].Rows[0]["EmployeeCategory"]);
            }
            else
            {
                ddlEmpCatagory.SelectedIndex = 0;
            }

            int i = 1;
            //Session["TdsSlab"] = dsTaxPolicy.Tables[1]; 
            #region Policy Detail
            foreach (DataRow dr1 in dsTaxPolicy.Tables[1].Rows)
            {
                TableRow tr = new TableRow();
                tr.ID = "tr_" + i;
                tr.CssClass = "row form-group col-md-12";

                TableCell tc_Slab = new TableCell();
                tc_Slab.CssClass = "col-md-2";



                tc_Slab.HorizontalAlign = HorizontalAlign.Left;
                tc_Slab.Width = Unit.Percentage(1);
                Label lbl_Slab = new Label();
                lbl_Slab.ID = "lbl_TdsSlab" + i;
                lbl_Slab.Text = "TDS Slab" + i;
                lbl_Slab.Text = Convert.ToString(dr1["Tds_SlabNo"]);
               
                tc_Slab.Controls.Add(lbl_Slab);
                tr.Cells.Add(tc_Slab);


                TableCell tc_RangeFrom = new TableCell();
                tc_RangeFrom.CssClass = "col-md-2";
                tc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
                tc_RangeFrom.Width = Unit.Percentage(1);
                TextBox tb_SlabFrom = new TextBox();
                tb_SlabFrom.ID = "txt_TdsRangeFrom_" + i;
                tb_SlabFrom.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
                tb_SlabFrom.Attributes.Add("onpaste", "return false;");
                tb_SlabFrom.Attributes.Add("ondrop", "return false;");
                tb_SlabFrom.Attributes.Add("runnat", "Server");
                tb_SlabFrom.Attributes.Add("Placeholder", " ₹ INR");
                tb_SlabFrom.MaxLength = 12;
                tb_SlabFrom.CssClass = "form-control ";
                tb_SlabFrom.Text = Convert.ToString(dr1["Tds_RangeFrom"]);
                tc_RangeFrom.Controls.Add(tb_SlabFrom);
                tr.Cells.Add(tc_RangeFrom);


                TableCell tc_RangeTO = new TableCell();
                tc_RangeTO.CssClass = "col-md-2";
                tc_RangeTO.HorizontalAlign = HorizontalAlign.Center;
                tc_RangeTO.Width = Unit.Percentage(1);
                TextBox tb_SlabTO = new TextBox();
                tb_SlabTO.ID = "txt_TdsRangeTo_" + i;
                tb_SlabTO.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
                tb_SlabTO.Attributes.Add("onpaste", "return false;");
                tb_SlabTO.Attributes.Add("ondrop", "return false;");
                tb_SlabTO.Attributes.Add("runnat", "Server");
                tb_SlabTO.Attributes.Add("Placeholder", " ₹ INR");
                tb_SlabTO.Text = Convert.ToString(dr1["Tds_RangeTo"]);
                tb_SlabTO.MaxLength = 12;
                tb_SlabTO.CssClass = "form-control";

                tc_RangeTO.Controls.Add(tb_SlabTO);
                tr.Cells.Add(tc_RangeTO);

                TableCell tc_TdsPercent = new TableCell();
                tc_TdsPercent.CssClass = "col-md-2";
                tc_TdsPercent.HorizontalAlign = HorizontalAlign.Center;
                tc_TdsPercent.Width = Unit.Percentage(1);
                TextBox tb_SlabPercent = new TextBox();
                tb_SlabPercent.ID = "txt_TdsRangePercent_" + i;
                tb_SlabPercent.Attributes.Add("onkeypress", "return number_dot(event,this);");
                tb_SlabPercent.Attributes.Add("onpaste", "return false;");
                tb_SlabPercent.Attributes.Add("ondrop", "return false;");
                tb_SlabPercent.Attributes.Add("Placeholder", " %");
                tb_SlabPercent.Text = Convert.ToString(dr1["Tds_Percentage"]);
                tb_SlabPercent.MaxLength = 5;
                tb_SlabPercent.CssClass = "form-control ";
                tc_TdsPercent.Controls.Add(tb_SlabPercent);
                tr.Cells.Add(tc_TdsPercent);

                TableCell tc_Plus = new TableCell();
                tc_Plus.CssClass = "Col-md-1";
                tc_Plus.HorizontalAlign = HorizontalAlign.Center;
                tc_Plus.Width = Unit.Percentage(0);
                Label lbl_plus = new Label();
                lbl_plus.ID = "lbl_plus" + i;
                lbl_plus.CssClass = "col-md-12 control-label con-top";
                lbl_plus.Text = "+";

                tc_Plus.Controls.Add(lbl_plus);

                tr.Cells.Add(tc_Plus);

                TableCell tc_CessPercent = new TableCell();
                tc_CessPercent.HorizontalAlign = HorizontalAlign.Center;
                tc_CessPercent.Width = Unit.Percentage(1);
                tc_CessPercent.CssClass = "col-md-2";
                TextBox tb_SlabAdditional = new TextBox();
                tb_SlabAdditional.ID = "txt_TdsCess_" + i;
                tb_SlabAdditional.Attributes.Add("onkeypress", "return number_dot(event,this);");
                tb_SlabAdditional.Attributes.Add("onpaste", "return false;");
                tb_SlabAdditional.Attributes.Add("ondrop", "return false;");
                tb_SlabAdditional.Attributes.Add("Placeholder", " %");
                tb_SlabAdditional.MaxLength = 5;
                tb_SlabAdditional.CssClass = "form-control";
                tb_SlabAdditional.Text = Convert.ToString(dr1["Tds_CessPercentage"]);
                tc_CessPercent.Controls.Add(tb_SlabAdditional);
                tr.Cells.Add(tc_CessPercent);

                TableCell tc_deletebtn = new TableCell();
                tc_deletebtn.ID = "tc_delete_btn_" + i;
                tc_deletebtn.HorizontalAlign = HorizontalAlign.Center;
                tc_deletebtn.CssClass = "col-sm-2";
                tc_deletebtn.Width = Unit.Percentage(1);
                //tc_deletebtn.Style.Add("Position", "relative");
                //tc_deletebtn.Style.Add("left","-10px");
                LinkButton btnDelete = new LinkButton();
                btnDelete.ID = "tds_SlabDelete_" + i;
                btnDelete.ToolTip = "TDSSlab Delete";
                btnDelete.CommandName = "Delete";
                btnDelete.CssClass = "btn del-btn fa-trash-o";
                btnDelete.CommandArgument = i.ToString();
                btnDelete.Click += new EventHandler(btnDelete_Click);
                btnDelete.Visible = false;
                tc_deletebtn.Controls.Add(btnDelete);
                tr.Cells.Add(tc_deletebtn);

                int count = Convert.ToInt32(Session["SlabCount"]);

                if (i == (count) && i != 3)
                {
                    tc_deletebtn.Width = Unit.Percentage(0.55);
                    btnDelete.Visible = true;
                }
                else
                {
                    btnDelete.Visible = false;
                }

                tbl_TdsSlab.Rows.Add(tr);
                hdnTaxPolicyCount.Value = Convert.ToString(i);
                i = i + 1;

            }
            #endregion
          
        }
        }

    private void BindProfData()
    {

        if(Convert.ToInt32(dsTaxPolicy.Tables[2].Rows[0]["IsPercentage"])==0)
        {
            rbtn_Amount.Checked = true;
        }
        else
        {
            rbtn_Percentage.Checked = true;
        }

        int i = 1;
        foreach (DataRow dr in dsTaxPolicy.Tables[2].Rows)
        {
            TableRow tr = new TableRow();
            tr.ID = "tr_Prof_" + i;
            tr.CssClass = "row form-group col-md-12";

            TableCell tc_Slab = new TableCell();
            tc_Slab.CssClass = "col-md-2";
           
            tc_Slab.HorizontalAlign = HorizontalAlign.Left;
            tc_Slab.Width = Unit.Percentage(0.4);
            Label lbl_Slab = new Label();
            lbl_Slab.ID = "lbl_ProfSlab" + i;
            lbl_Slab.Text = Convert.ToString(dr["Prof_SlabName"]);
            tc_Slab.Controls.Add(lbl_Slab);
            tr.Cells.Add(tc_Slab);


            TableCell tc_RangeFrom = new TableCell();
            tc_RangeFrom.CssClass = "col-md-2 ";
            tc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
            tc_RangeFrom.Width = Unit.Percentage(1);
            TextBox tb_SlabFrom = new TextBox();
            tb_SlabFrom.ID = "txt_ProfRangeFrom_" + i;
            tb_SlabFrom.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
            tb_SlabFrom.Attributes.Add("onpaste", "return false;");
            tb_SlabFrom.Attributes.Add("ondrop", "return false;");
            tb_SlabFrom.Attributes.Add("runnat", "Server");
            tb_SlabFrom.Attributes.Add("Placeholder", " ₹ INR");
            tb_SlabFrom.MaxLength = 12;
            tb_SlabFrom.CssClass = "form-control ";
            tb_SlabFrom.Text = Convert.ToString(dr["Prof_RangeFrom"]);
            tc_RangeFrom.Controls.Add(tb_SlabFrom);
            tr.Cells.Add(tc_RangeFrom);


            TableCell tc_RangeTO = new TableCell();
            tc_RangeTO.CssClass = "col-md-2";
            tc_RangeTO.HorizontalAlign = HorizontalAlign.Center;
            tc_RangeTO.Width = Unit.Percentage(1);
            TextBox tb_SlabTO = new TextBox();
            tb_SlabTO.ID = "txt_ProfRangeTo_" + i;
            tb_SlabTO.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
            tb_SlabTO.Attributes.Add("onpaste", "return false;");
            tb_SlabTO.Attributes.Add("ondrop", "return false;");
            tb_SlabTO.Attributes.Add("runnat", "Server");
            tb_SlabTO.Attributes.Add("Placeholder", " ₹ INR");
            tb_SlabTO.Text = Convert.ToString(dr["Prof_RangeTO"]);
            tb_SlabTO.MaxLength = 12;
            tb_SlabTO.CssClass = "form-control";

            tc_RangeTO.Controls.Add(tb_SlabTO);
            tr.Cells.Add(tc_RangeTO);

            TableCell tc_ProfPercent = new TableCell();
            tc_ProfPercent.ID = "tc_ProfTaxPercentage_" + i;
            tc_ProfPercent.CssClass = "col-md-2";
            tc_ProfPercent.HorizontalAlign = HorizontalAlign.Center;
            tc_ProfPercent.Width = Unit.Percentage(1);

            TextBox tb_SlabPercent = new TextBox();
            tb_SlabPercent.ID = "txt_ProfRangePercent_" + i;
            tb_SlabPercent.Attributes.Add("onkeypress", "return number_dot(event,this);");
            tb_SlabPercent.Attributes.Add("onpaste", "return false;");
            tb_SlabPercent.Attributes.Add("ondrop", "return false;");
            tb_SlabPercent.Attributes.Add("Placeholder", " %");
            tb_SlabPercent.MaxLength = 5;
            tb_SlabPercent.CssClass = "form-control ";
            tc_ProfPercent.Controls.Add(tb_SlabPercent);
            tc_ProfPercent.Visible = true;
           
            //TableCell tc_ProfAmount = new TableCell();
            //tc_ProfAmount.ID = "tc_ProfAmount_" + i;
            //tc_ProfAmount.CssClass = "col-md-2";
            //tc_ProfAmount.HorizontalAlign = HorizontalAlign.Center;
            //tc_ProfAmount.Width = Unit.Percentage(1);
            TextBox tb_SlabAmonunt = new TextBox();
            tb_SlabAmonunt.ID = "txt_ProfRangeAmount_" + i;
            tb_SlabAmonunt.Attributes.Add("onkeypress", "return number_dot(event,this);");
            tb_SlabAmonunt.Attributes.Add("onpaste", "return false;");
            tb_SlabAmonunt.Attributes.Add("ondrop", "return false;");
            tb_SlabAmonunt.Attributes.Add("Placeholder", "₹ INR");
            tb_SlabAmonunt.MaxLength = 5;
            tb_SlabAmonunt.CssClass = "form-control ";
            tb_SlabAmonunt.Visible = true;
            tc_ProfPercent.Controls.Add(tb_SlabAmonunt);
            tc_ProfPercent.Visible = true;
            //tr.Cells.Add(tc_ProfAmount);


            if(Convert.ToInt32(dr["IsPercentage"])==1)
            {
                tb_SlabPercent.Text = Convert.ToString(dr["Prof_Amount"]);
                tb_SlabAmonunt.Text = "";
                tb_SlabAmonunt.Visible = false;

                //tc_ProfAmount.Visible = false;
            }
            else
            {
                tb_SlabAmonunt.Text = Convert.ToString(dr["Prof_Amount"]);
                tb_SlabPercent.Text = "";
                tb_SlabPercent.Visible = false;
                //tc_ProfAmount.Visible = true;
            }
            tr.Cells.Add(tc_ProfPercent);

            TableCell tc_deletebtn = new TableCell();
            tc_deletebtn.ID = "tc_Prodelete_btn_" + i;
            tc_deletebtn.HorizontalAlign = HorizontalAlign.Center;
            tc_deletebtn.Width = Unit.Percentage(0.55);
            LinkButton btnDelete = new LinkButton();
            btnDelete.ID = "Prof_SlabDelete_" + i;

            btnDelete.ToolTip = "Professional Slab Delete";
            btnDelete.CssClass = "btn del-btn fa-trash-o";
            btnDelete.CommandArgument = i.ToString();
            btnDelete.Click += new EventHandler(btnDeleteProf_Click);
            btnDelete.Visible = false;
            tc_deletebtn.Controls.Add(btnDelete);
            tr.Cells.Add(tc_deletebtn);

              int count = Convert.ToInt32(Session["ProfSlabCount"]);

                if (i == (count) && i != 3)
                {
                    tc_deletebtn.Width = Unit.Percentage(0.33);
                    btnDelete.Visible = true;
                }
                else
                {
                    btnDelete.Visible = false;
                }




            tbl_ProfessSlab.Rows.Add(tr);

            hdnProfPolicyCount.Value = Convert.ToString(i);
            i = i + 1;

        }
    }

    #region Auto generate Table
    private void TaxSlabAutoGenerate(object v)
    {
        tbl_TdsSlab.ID = "tbl_Slab";
        tbl_TdsSlab.CssClass = "Col-md-12 ";

        //tbl_TdsSlab.Attributes["Class"] = "tb_Slab";

        TableHeaderRow hr = new TableHeaderRow();
        hr.CssClass = "row form-group col-md-12";

        TableHeaderCell hc_slabName = new TableHeaderCell();
        hc_slabName.CssClass = "col-md-2 lvepo-tblHeader";
        hc_slabName.VerticalAlign = VerticalAlign.Top;
        hc_slabName.HorizontalAlign = HorizontalAlign.Left;
        hc_slabName.Text = "Tax slab No";
        hc_slabName.Style.Add("opacity", "0");
        hc_slabName.Width = Unit.Percentage(1);
        Label lbl_hcSlab = new Label();

        hr.Cells.Add(hc_slabName);

        TableHeaderCell hc_RangeFrom = new TableHeaderCell();
        hc_RangeFrom.CssClass = "col-md-2 lvepo-tblHeader";
        hc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
        hc_RangeFrom.Width = Unit.Percentage(1);
        hc_RangeFrom.Style.Add("Position", "relative");
        hc_RangeFrom.Style.Add("left", "30px");
        hc_RangeFrom.Text = "Range From";
        hr.Cells.Add(hc_RangeFrom);

        TableHeaderCell hc_RangeTo = new TableHeaderCell();
        hc_RangeTo.CssClass = "col-md-2 lvepo-tblHeader";
        hc_RangeTo.VerticalAlign = VerticalAlign.Middle;
        hc_RangeTo.HorizontalAlign = HorizontalAlign.Center;
        hc_RangeTo.Style.Add("Position", "relative");
        hc_RangeTo.Style.Add("left", "40px");
        hc_RangeTo.Width = Unit.Percentage(1);
        hc_RangeTo.Text = "Range To";
        hr.Cells.Add(hc_RangeTo);

        TableHeaderCell hc_TdsPercent = new TableHeaderCell();
        hc_TdsPercent.CssClass = "col-md-2 lvepo-tblHeader";
        hc_TdsPercent.VerticalAlign = VerticalAlign.Middle;
        hc_TdsPercent.HorizontalAlign = HorizontalAlign.Center;
        hc_TdsPercent.Style.Add("Position", "relative");
        hc_TdsPercent.Style.Add("left", "50px");
        hc_TdsPercent.Width = Unit.Percentage(1);
        hc_TdsPercent.Text = "TDS %";
        hr.Cells.Add(hc_TdsPercent);

        TableHeaderCell hc_Plus = new TableHeaderCell();
        hc_Plus.CssClass = "col-md-1 lvepo-tblHeader";
        hc_Plus.VerticalAlign = VerticalAlign.Middle;
        hc_Plus.HorizontalAlign = HorizontalAlign.Center;
        hc_Plus.Width = Unit.Percentage(0);
        hc_Plus.Text = "Symbol";
        hc_Plus.Style.Add("opacity", "0");
        hr.Cells.Add(hc_Plus);

        TableHeaderCell hc_Cess = new TableHeaderCell();
        hc_Cess.CssClass = "col-md-2 lvepo-tblHeader";
        hc_Cess.VerticalAlign = VerticalAlign.Middle;
        hc_Cess.HorizontalAlign = HorizontalAlign.Center;
        hc_Cess.Width = Unit.Percentage(1);
        //hc_Cess.Style.Add("Position", "relative");
        //hc_Cess.Style.Add("left", "30px");
        hc_Cess.Text = "Additional Cess";
        hr.Cells.Add(hc_Cess);

        TableHeaderCell hc_Delete = new TableHeaderCell();
        hc_Delete.CssClass = "col-md-1 lvepo-tblHeader";
        hc_Delete.VerticalAlign = VerticalAlign.Middle;
        hc_Delete.Width = Unit.Percentage(0.9);
        hc_Delete.HorizontalAlign = HorizontalAlign.Center;
        
        hc_Delete.Style.Add("opacity", "0");
        hr.Cells.Add(hc_Delete);
        tbl_TdsSlab.Rows.Add(hr);


        int id = Convert.ToInt32(v);

        for (int i = 1; i <= id; i++)
        {
            TableRow tr = new TableRow();
            tr.ID = "tr_" + i;
            tr.CssClass = "row form-group col-md-12";

            TableCell tc_Slab = new TableCell();
            tc_Slab.CssClass = "col-md-2";


            tc_Slab.HorizontalAlign = HorizontalAlign.Left;
            tc_Slab.Width = Unit.Percentage(1);
            Label lbl_Slab = new Label();
            lbl_Slab.ID = "lbl_TdsSlab" + i;
            lbl_Slab.Text = "TDS Slab" + i;

            tc_Slab.Controls.Add(lbl_Slab);
            tr.Cells.Add(tc_Slab);


            TableCell tc_RangeFrom = new TableCell();
            tc_RangeFrom.CssClass = "col-md-2";
            tc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
            tc_RangeFrom.Width = Unit.Percentage(1);
            TextBox tb_SlabFrom = new TextBox();
            tb_SlabFrom.ID = "txt_TdsRangeFrom_" + i;
            tb_SlabFrom.Attributes.Add("onkeypress", "return OnlyNumberValuewithzero(event,this);");
            tb_SlabFrom.Attributes.Add("onpaste", "return false;");
            tb_SlabFrom.Attributes.Add("ondrop", "return false;");
            tb_SlabFrom.Attributes.Add("runnat", "Server");
            tb_SlabFrom.Attributes.Add("Placeholder", " ₹ INR");
            tb_SlabFrom.MaxLength = 12;
            tb_SlabFrom.CssClass = "form-control ";
            tc_RangeFrom.Controls.Add(tb_SlabFrom);
            tr.Cells.Add(tc_RangeFrom);


            TableCell tc_RangeTO = new TableCell();
            tc_RangeTO.CssClass = "col-md-2";
            tc_RangeTO.HorizontalAlign = HorizontalAlign.Center;
            tc_RangeTO.Width = Unit.Percentage(1);
            TextBox tb_SlabTO = new TextBox();
            tb_SlabTO.ID = "txt_TdsRangeTo_" + i;
            tb_SlabTO.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
            tb_SlabTO.Attributes.Add("onpaste", "return false;");
            tb_SlabTO.Attributes.Add("ondrop", "return false;");
            tb_SlabTO.Attributes.Add("runnat", "Server");
            tb_SlabTO.Attributes.Add("Placeholder", " ₹ INR");
            tb_SlabTO.MaxLength = 12;
            tb_SlabTO.CssClass = "form-control";

            tc_RangeTO.Controls.Add(tb_SlabTO);
            tr.Cells.Add(tc_RangeTO);

            TableCell tc_TdsPercent = new TableCell();
            tc_TdsPercent.CssClass = "col-md-2";
            tc_TdsPercent.HorizontalAlign = HorizontalAlign.Center;
            tc_TdsPercent.Width = Unit.Percentage(1);
            TextBox tb_SlabPercent = new TextBox();
            tb_SlabPercent.ID = "txt_TdsRangePercent_" + i;
            tb_SlabPercent.Attributes.Add("onkeypress", "return number_dot(event,this);");
            tb_SlabPercent.Attributes.Add("onpaste", "return false;");
            tb_SlabPercent.Attributes.Add("ondrop", "return false;");
            tb_SlabPercent.Attributes.Add("Placeholder", " %");
            tb_SlabPercent.MaxLength = 5;
            tb_SlabPercent.CssClass = "form-control ";
            tc_TdsPercent.Controls.Add(tb_SlabPercent);
            tr.Cells.Add(tc_TdsPercent);

            TableCell tc_Plus = new TableCell();
            tc_Plus.CssClass = "Col-md-1";
            tc_Plus.HorizontalAlign = HorizontalAlign.Center;
            tc_Plus.Width = Unit.Percentage(0);
            Label lbl_plus = new Label();
            lbl_plus.ID = "lbl_plus" + i;
            lbl_plus.CssClass = "col-md-12 control-label con-top";
            lbl_plus.Text = "+";

            tc_Plus.Controls.Add(lbl_plus);

            tr.Cells.Add(tc_Plus);

            TableCell tc_CessPercent = new TableCell();
            tc_CessPercent.HorizontalAlign = HorizontalAlign.Center;
            tc_CessPercent.Width = Unit.Percentage(1);
            tc_CessPercent.CssClass = "col-md-2";
            TextBox tb_SlabAdditional = new TextBox();
            tb_SlabAdditional.ID = "txt_TdsCess_" + i;
            tb_SlabAdditional.Attributes.Add("onkeypress", "return number_dot(event,this);");
            tb_SlabAdditional.Attributes.Add("onpaste", "return false;");
            tb_SlabAdditional.Attributes.Add("ondrop", "return false;");
            tb_SlabAdditional.Attributes.Add("Placeholder", " %");
            tb_SlabAdditional.MaxLength = 5;
            tb_SlabAdditional.CssClass = "form-control";
            tc_CessPercent.Controls.Add(tb_SlabAdditional);
            tr.Cells.Add(tc_CessPercent);

            TableCell tc_deletebtn = new TableCell();
            tc_deletebtn.ID = "tc_delete_btn_" + i;
            tc_deletebtn.HorizontalAlign = HorizontalAlign.Center;
            tc_deletebtn.CssClass = "col-sm-2";
            tc_deletebtn.Width = Unit.Percentage(1);
            tc_deletebtn.Style.Add("Position", "relative");
            tc_deletebtn.Style.Add("left", "0px");
            LinkButton btnDelete = new LinkButton();
            btnDelete.ID = "tds_SlabDelete_" + i;
            btnDelete.ToolTip = "TDSSlab Delete";
            btnDelete.CommandName = "Delete";
            btnDelete.CssClass = "btn del-btn fa-trash-o";
            btnDelete.CommandArgument = i.ToString();
            btnDelete.Click += new EventHandler(btnDelete_Click);
            btnDelete.Visible = false;
            tc_deletebtn.Controls.Add(btnDelete);
            tr.Cells.Add(tc_deletebtn);




            //TableCell tc_deletebtn = new TableCell();
            //tc_deletebtn.ID = "tc_delete_btn_" + i;
            //tc_deletebtn.HorizontalAlign = HorizontalAlign.Center;
            //tc_deletebtn.Width = Unit.Percentage(1);
            //LinkButton btnDelete = new LinkButton();
            //btnDelete.ID = "tds_SlabDelete_" + i;

            //btnDelete.ToolTip = "TDSSlab Delete";

            //btnDelete.CommandArgument = i.ToString();
            //btnDelete.Click += new EventHandler(btnDelete_Click);
            //btnDelete.Visible = false;
            //tc_deletebtn.Controls.Add(btnDelete);
            //tr.Cells.Add(tc_deletebtn);

            int count = Convert.ToInt32(Session["SlabCount"]);

            if (i == (count) && i != 3)
            {
                tc_deletebtn.Width = Unit.Percentage(0.55);
                btnDelete.Visible = true;
            }
            else
            {
                btnDelete.Visible = false;
            }

            tbl_TdsSlab.Rows.Add(tr);
            hdnTaxPolicyCount.Value = Convert.ToString(i);

        }


    }
    #endregion

    private void LoadStrings(CultureInfo ci)
    {
        lbl_HeaderTaxPolicy.Text = rm.GetString("Masters_TaxPolicy", ci);
        lblCompany.Text = rm.GetString("EntranceMaster_Company", ci);
        lbl_PolicyName.Text = rm.GetString("TaxPolicy_Name", ci);
        lblGender.Text = rm.GetString("EmployeeMaster_Gender", ci);
        lbl_IndicatesMandatoryFields.Text = rm.GetString("IndicatesMandatoryFields", ci);
        lblEmpCategory.Text = rm.GetString("Master_Category", ci);
        lblEmpType.Text = rm.GetString("Master_Type", ci);
        chkTDS.Text = rm.GetString("UserGroups_TDS", ci);
        btn_AddSlab.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Add", ci);
        chkProfessionalTax.Text = rm.GetString("UserGroup_Professional", ci);
        btn_ProfessAddSlab.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Add", ci);

        //btn_DeleteSlab.Text= "&nbsp;&nbsp;" + rm.GetString("btn_Delete", ci);
        //btn_ProfessDelete.Text= "&nbsp;&nbsp;" + rm.GetString("btn_Delete", ci);

        btn_save.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Save", ci);
        btn_cancel.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Back", ci);


    }

    protected void btn_save_Click(object sender, EventArgs e)
    {
        //string scrt = "<script>Validation()</script>";

        //Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "ValidateAll();", true);

        //this.Page.RegisterStartupScript("a", scrt);

        string chck = hdnValidation.Value;

        //if (!IsPostBack)
        //{
            InsertTaxPolicy();
        //}
        btn_save.OnClientClick = "if(Page_ClientValidate()) return confirm('" + rm.GetString("Alert_ConfirmSave", ci) + "');return false;";


        //else
        //{ 
        //    InsertTaxPolicy();
        //}

    }

    private void InsertTaxPolicy()
    {
        Int32 flag = 0;
        DataSet dsPolicy = new DataSet();
        Hashtable chkpolicy = new Hashtable();
        DataSet ds_PolicyName = new DataSet();
        chkpolicy.Add("@tag", "CP");
        chkpolicy.Add("@TaxPolicyName", Convert.ToString(txt_PolicyName.Text));
        ds_PolicyName = objPayrollEventData.InsertTaxPolicy(chkpolicy);
        int PolicyNameCount = Convert.ToInt32(ds_PolicyName.Tables[0].Rows.Count);
        if(rbtn_Amount.Checked)
        {
            flag = 0;
        }
        else
        {
            flag = 1;
        }


        if (PolicyNameCount <= 1)
        {

            int taxSlabcout = tbl_TdsSlab.Rows.Count;

            DataSet InsertTaxPolicy = new DataSet();
            Hashtable htable = new Hashtable();
            htable.Add("@tag", "U");
            htable.Add("@TaxPolicyName", Convert.ToString(txt_PolicyName.Text));
            htable.Add("@companyID", Convert.ToInt16(ddlCompany.SelectedValue));
            htable.Add("@EmployeeCategory", Convert.ToInt16(ddlEmpCatagory.SelectedValue));
            htable.Add("@EmployeeType", Convert.ToInt16(ddlEmpType.SelectedValue));
            htable.Add("@Gender", Convert.ToString(ddlGender.SelectedItem));
            htable.Add("@Employee_Id", Convert.ToInt32(Session["EmpAutoID"]));
            htable.Add("@TdsSlabCount", taxSlabcout);
            htable.Add("@TaxPolicyID", intPolicyID);


            InsertTaxPolicy = objPayrollEventData.InsertTaxPolicy(htable);

            for (int j = 1; j < tbl_TdsSlab.Rows.Count; j++)
            {
                Label lblSlabName = new Label();
                lblSlabName = (Label)tbl_TdsSlab.Rows[j].FindControl("lbl_TdsSlab" + j);

                TextBox txt_FromRange = new TextBox();
                txt_FromRange = (TextBox)tbl_TdsSlab.Rows[j].FindControl("txt_TdsRangeFrom_" + j);

                TextBox txt_ToRange = new TextBox();
                txt_ToRange = (TextBox)tbl_TdsSlab.Rows[j].FindControl("txt_TdsRangeTo_" + j);

                TextBox txt_TdsPercentage = new TextBox();
                txt_TdsPercentage = (TextBox)tbl_TdsSlab.Rows[j].FindControl("txt_TdsRangePercent_" + j);

                TextBox txt_AddCess = new TextBox();
                txt_AddCess = (TextBox)tbl_TdsSlab.Rows[j].FindControl("txt_TdsCess_" + j);

                Hashtable tdsHash = new Hashtable();
                tdsHash.Add("@tag", "UTS");
                tdsHash.Add("@TaxPolicyId", Convert.ToInt32(InsertTaxPolicy.Tables[0].Rows[0]["PolicyID"].ToString()));
                tdsHash.Add("@TDSSlabName", lblSlabName.Text);
                tdsHash.Add("@TDSSalaryFrom", Convert.ToInt64(txt_FromRange.Text));
                tdsHash.Add("@TDSSalaryTO", Convert.ToInt64(txt_ToRange.Text));
                tdsHash.Add("@TDSPercentage", Convert.ToDouble(txt_TdsPercentage.Text));
                tdsHash.Add("@TDSCessPercentage", (txt_AddCess.Text == "" ? 0.0 : Convert.ToDouble(txt_AddCess.Text)));

                objPayrollEventData.InsertTaxSlabValues(tdsHash);

            }

            if(rbtn_Amount.Checked)
            {
                
                for (int j = 1; j < tbl_ProfessSlab.Rows.Count; j++)
                {
                    Label lblSlabName = new Label();
                    lblSlabName = (Label)tbl_ProfessSlab.Rows[j].FindControl("lbl_ProfSlab" + j);

                    TextBox txt_FromRange = new TextBox();
                    txt_FromRange = (TextBox)tbl_ProfessSlab.Rows[j].FindControl("txt_ProfRangeFrom_" + j);

                    TextBox txt_ToRange = new TextBox();
                    txt_ToRange = (TextBox)tbl_ProfessSlab.Rows[j].FindControl("txt_ProfRangeTo_" + j);

                    TextBox txt_TdsPercentage = new TextBox();
                    txt_TdsPercentage = (TextBox)tbl_ProfessSlab.Rows[j].FindControl("txt_ProfRangeAmount_" + j);


                    Hashtable ProfHash = new Hashtable();
                    ProfHash.Add("@tag", "UPS");
                    ProfHash.Add("@TaxPolicyId", Convert.ToInt32(InsertTaxPolicy.Tables[0].Rows[0]["PolicyID"].ToString()));
                    ProfHash.Add("@ProfSlabName", lblSlabName.Text);
                    ProfHash.Add("@ProfSalaryFrom", Convert.ToInt64(txt_FromRange.Text));
                    ProfHash.Add("@ProfSalaryTo", Convert.ToInt64(txt_ToRange.Text));
                    ProfHash.Add("@ProfTaxAmount", Convert.ToString(txt_TdsPercentage.Text));
                    ProfHash.Add("@ProfISFlag", flag);
                    objPayrollEventData.InsertTaxSlabValues(ProfHash);

                }
            }
            else
            {
                for (int j = 1; j < tbl_ProfessSlab.Rows.Count; j++)
                {
                    Label lblSlabName = new Label();
                    lblSlabName = (Label)tbl_ProfessSlab.Rows[j].FindControl("lbl_ProfSlab" + j);

                    TextBox txt_FromRange = new TextBox();
                    txt_FromRange = (TextBox)tbl_ProfessSlab.Rows[j].FindControl("txt_ProfRangeFrom_" + j);

                    TextBox txt_ToRange = new TextBox();
                    txt_ToRange = (TextBox)tbl_ProfessSlab.Rows[j].FindControl("txt_ProfRangeTo_" + j);

                    TextBox txt_TdsPercentage = new TextBox();
                    txt_TdsPercentage = (TextBox)tbl_ProfessSlab.Rows[j].FindControl("txt_ProfRangePercent_" + j);


                    Hashtable ProfHash = new Hashtable();
                    ProfHash.Add("@tag", "UPS");
                    ProfHash.Add("@TaxPolicyId", Convert.ToInt32(InsertTaxPolicy.Tables[0].Rows[0]["PolicyID"].ToString()));
                    ProfHash.Add("@ProfSlabName", lblSlabName.Text);
                    ProfHash.Add("@ProfSalaryFrom", Convert.ToInt64(txt_FromRange.Text));
                    ProfHash.Add("@ProfSalaryTo", Convert.ToInt64(txt_ToRange.Text));
                    ProfHash.Add("@ProfTaxPercentage", Convert.ToString(txt_TdsPercentage.Text));
                    ProfHash.Add("@ProfISFlag", flag);


                    objPayrollEventData.InsertTaxSlabValues(ProfHash);

                }
            }


            base.MessageWithRedirect(rm.GetString("Alert_ModifyTaxPolicysavedsuccessfully", ci), "TA_UI_Master_TaxPolicy.aspx");

        }
        else
        {
            strScript = "";
            strScript = strScript + "<script language='javascript'>";
            strScript = strScript + "alert('Policy name already exist')";
            strScript = strScript + "</script>";
            Page.RegisterStartupScript("DelAlert1", strScript);
            return;

        }


    }

    protected void btn_cancel_Click(object sender, EventArgs e)
    {

        base.Response.Redirect("TA_UI_Master_TaxPolicy.aspx");
    }
    protected void btn_AddSlab_Click(object sender, EventArgs e)
    {

        int rowId;
        rowId = Convert.ToInt32(Session["SlabCount"]);
        rowId = rowId + 1;


        TableRow tr = new TableRow();
        tr.ID = "tr_" + rowId;
        tr.CssClass = "row form-group col-md-12";

        TableCell tc_Slab = new TableCell();
        tc_Slab.CssClass = "col-md-2";



        tc_Slab.HorizontalAlign = HorizontalAlign.Left;
        tc_Slab.Width = Unit.Percentage(1);
        Label lbl_Slab = new Label();
        lbl_Slab.ID = "lbl_TdsSlab" + rowId;
        lbl_Slab.Text = "TDS Slab" + rowId;

        tc_Slab.Controls.Add(lbl_Slab);
        tr.Cells.Add(tc_Slab);


        TableCell tc_RangeFrom = new TableCell();
        tc_RangeFrom.CssClass = "col-md-2";
        tc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
        tc_RangeFrom.Width = Unit.Percentage(1);
        TextBox tb_SlabFrom = new TextBox();
        tb_SlabFrom.ID = "txt_TdsRangeFrom_" + rowId;
        tb_SlabFrom.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
        tb_SlabFrom.Attributes.Add("onkeyup", "PreventFirstZero(event)");
        tb_SlabFrom.Attributes.Add("onpaste", "return false;");
        tb_SlabFrom.Attributes.Add("ondrop", "return false;");
        tb_SlabFrom.Attributes.Add("runnat", "Server");
        tb_SlabFrom.Attributes.Add("Placeholder", " ₹ INR");
        tb_SlabFrom.MaxLength = 12;
        tb_SlabFrom.CssClass = "form-control ";
        tc_RangeFrom.Controls.Add(tb_SlabFrom);
        tr.Cells.Add(tc_RangeFrom);


        TableCell tc_RangeTO = new TableCell();
        tc_RangeTO.CssClass = "col-md-2";
        tc_RangeTO.HorizontalAlign = HorizontalAlign.Center;
        tc_RangeTO.Width = Unit.Percentage(1);
        TextBox tb_SlabTO = new TextBox();
        tb_SlabTO.ID = "txt_TdsRangeTo_" + rowId;
        tb_SlabTO.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
        tb_SlabTO.Attributes.Add("onpaste", "return false;");
        tb_SlabTO.Attributes.Add("ondrop", "return false;");
        tb_SlabTO.Attributes.Add("runnat", "Server");
        tb_SlabTO.Attributes.Add("Placeholder", " ₹ INR");
        tb_SlabTO.MaxLength = 12;
        tb_SlabTO.CssClass = "form-control";
        tc_RangeTO.Controls.Add(tb_SlabTO);
        tr.Cells.Add(tc_RangeTO);

        TableCell tc_TdsPercent = new TableCell();
        tc_TdsPercent.CssClass = "col-md-2";
        tc_TdsPercent.HorizontalAlign = HorizontalAlign.Center;
        tc_TdsPercent.Width = Unit.Percentage(1);
        TextBox tb_SlabPercent = new TextBox();
        tb_SlabPercent.ID = "txt_TdsRangePercent_" + rowId;
        tb_SlabPercent.Attributes.Add("onkeypress", "return number_dot(event,this);");
        tb_SlabPercent.Attributes.Add("onpaste", "return false;");
        tb_SlabPercent.Attributes.Add("ondrop", "return false;");
        tb_SlabPercent.Attributes.Add("Placeholder", "%");
        tb_SlabPercent.MaxLength = 5;
        tb_SlabPercent.CssClass = "form-control ";
        tc_TdsPercent.Controls.Add(tb_SlabPercent);
        tr.Cells.Add(tc_TdsPercent);

        TableCell tc_Plus = new TableCell();
        tc_Plus.CssClass = "Col-md-1";
        tc_Plus.HorizontalAlign = HorizontalAlign.Center;
        tc_Plus.Width = Unit.Percentage(0);
        Label lbl_plus = new Label();
        lbl_plus.ID = "lbl_plus" + rowId;
        lbl_plus.CssClass = "col-md-12 control-label con-top";
        lbl_plus.Text = "+";

        tc_Plus.Controls.Add(lbl_plus);

        tr.Cells.Add(tc_Plus);

        TableCell tc_CessPercent = new TableCell();
        tc_CessPercent.HorizontalAlign = HorizontalAlign.Center;
        tc_CessPercent.Width = Unit.Percentage(1);
        tc_CessPercent.CssClass = "col-md-2";
        TextBox tb_SlabAdditional = new TextBox();
        tb_SlabAdditional.ID = "txt_TdsCess_" + rowId;
        tb_SlabAdditional.Attributes.Add("onkeypress", "return number_dot(event,this);");
        tb_SlabAdditional.Attributes.Add("onpaste", "return false;");
        tb_SlabAdditional.Attributes.Add("ondrop", "return false;");
        //tb_SlabAdditional.Attributes.Add("onblur", "validatepercent(this)");
        tb_SlabAdditional.Attributes.Add("Placeholder", " %");
        tb_SlabAdditional.MaxLength = 5;
        tb_SlabAdditional.CssClass = "form-control";
        tc_CessPercent.Controls.Add(tb_SlabAdditional);
        tr.Cells.Add(tc_CessPercent);

        TableCell tc_deletebtn = new TableCell();
        tc_deletebtn.ID = "tc_delete_btn_" + rowId;
        tc_deletebtn.HorizontalAlign = HorizontalAlign.Center;
        tc_deletebtn.Width = Unit.Percentage(0.86);
        //tc_deletebtn.Style.Add("Position", "relative");
        //tc_deletebtn.Style.Add("left", "-10px");
        LinkButton btnDelete = new LinkButton();
        btnDelete.ID = "tds_SlabDelete_" + rowId;
        btnDelete.ToolTip = "TDSSlab Delete";
        btnDelete.CssClass = "btn del-btn fa-trash-o";
        btnDelete.CommandArgument = rowId.ToString();
        btnDelete.Click += new EventHandler(btnDelete_Click);
        tc_deletebtn.Controls.Add(btnDelete);
        tr.Cells.Add(tc_deletebtn);


        LinkButton btnPrviousdelete = (LinkButton)tbl_TdsSlab.Rows[rowId - 1].FindControl("tds_SlabDelete_" + (rowId - 1));
        btnPrviousdelete.Visible = false;

        TableCell prevCell = (TableCell)tbl_TdsSlab.Rows[rowId - 1].FindControl("tc_delete_btn_" + (rowId - 1));
        prevCell.Width = Unit.Percentage(1);




        tbl_TdsSlab.Rows.Add(tr);

        hdnTaxPolicyCount.Value = Convert.ToString(rowId);

        Session["SlabCount"] = rowId;
    }

    private void btnDelete_Click(object sender, EventArgs e)
    {
        LinkButton delbtn = (LinkButton)sender;
        int thisRow = Convert.ToInt32(delbtn.CommandArgument);
        TableRow tr = new TableRow();
        tr.ID = "tr_" + thisRow;
        Label slabName = (Label)tbl_TdsSlab.Rows[thisRow].FindControl("lbl_TdsSlab"+thisRow);
        String tdsSlabName = slabName.Text;
        Hashtable deleteSlab = new Hashtable();
        deleteSlab.Add("@tag", "TDD");
        deleteSlab.Add("@TDSSlabName", tdsSlabName);
        deleteSlab.Add("@TaxPolicyId", intPolicyID);
        objPayrollEventData.InsertTaxSlabValues(deleteSlab);
        tbl_TdsSlab.Rows.Remove(tbl_TdsSlab.Rows[thisRow]);

        hdnTaxPolicyCount.Value = Convert.ToString(tbl_TdsSlab.Rows.Count - 1);
        Session["SlabCount"] = tbl_TdsSlab.Rows.Count - 1;

        if (thisRow - 1 != 3)
        {
            TableCell tc_cell = (TableCell)tbl_TdsSlab.Rows[thisRow - 1].FindControl("tc_delete_btn_" + (thisRow - 1));
            tc_cell.Width = Unit.Percentage(0.55);
            LinkButton btndelete = (LinkButton)tbl_TdsSlab.Rows[thisRow - 1].FindControl("tds_SlabDelete_" + (thisRow - 1));
            btndelete.CssClass = "btn del-btn fa-trash-o";
            btndelete.Visible = true;
            tc_cell.Controls.Add(btndelete);
            tc_cell.Style.Add("Position", "relative");
            tc_cell.Style.Add("left", " 0px");
        }

        //tbl_TdsSlab.Rows[tbl_TdsSlab.Rows.Count - 1].Visible = false;


    }
    private void DynamicProfessionalSlabCreate(object v)
    {
        //tbl_TdsSlab = new Table();
        tbl_ProfessSlab.ID = "tbl_ProfSlab";
        tbl_ProfessSlab.CssClass = "Col-md-12";

        TableHeaderRow hr = new TableHeaderRow();
        hr.CssClass = "row form-group col-md-12";

        TableHeaderCell hc_slabName = new TableHeaderCell();
        hc_slabName.CssClass = "col-md-2 lvepo-tblHeader";
        hc_slabName.VerticalAlign = VerticalAlign.Top;
        hc_slabName.Width = Unit.Percentage(0.4);
        hr.Cells.Add(hc_slabName);

        TableHeaderCell hc_RangeFrom = new TableHeaderCell();
        hc_RangeFrom.CssClass = "col-md-2 lvepo-tblHeader";
        hc_RangeFrom.VerticalAlign = VerticalAlign.Top;
        hc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
        hc_RangeFrom.Width = Unit.Percentage(1);
          hc_RangeFrom.Style.Add("Position", "relative");
        hc_RangeFrom.Style.Add("left", "50px");
        hc_RangeFrom.Text = "Range From";
        hr.Cells.Add(hc_RangeFrom);

        TableHeaderCell hc_RangeTo = new TableHeaderCell();
        hc_RangeTo.CssClass = "col-md-2 lvepo-tblHeader";
        hc_RangeTo.VerticalAlign = VerticalAlign.Top;
        hc_RangeTo.HorizontalAlign = HorizontalAlign.Center;
        hc_RangeTo.Style.Add("Position", "relative");
        hc_RangeTo.Style.Add("left", "50px");
        hc_RangeTo.Width = Unit.Percentage(1);
        hc_RangeTo.Text = "Range To";
        hr.Cells.Add(hc_RangeTo);

        TableHeaderCell hc_TdsPercent = new TableHeaderCell();
        hc_TdsPercent.CssClass = "col-md-2 lvepo-tblHeader";
        hc_TdsPercent.VerticalAlign = VerticalAlign.Top;
        hc_TdsPercent.HorizontalAlign = HorizontalAlign.Center;
        hc_TdsPercent.Style.Add("Position", "relative");
        hc_TdsPercent.Style.Add("left", "40px");
        hc_TdsPercent.Width = Unit.Percentage(1);
        hc_TdsPercent.Text = "Professional Tax";
        hr.Cells.Add(hc_TdsPercent);

        TableHeaderCell hc_ProfDelete = new TableHeaderCell();
        hc_ProfDelete.CssClass = "col-md-2 lvepo-tblHeader";
        hc_ProfDelete.VerticalAlign = VerticalAlign.Top;
        hc_ProfDelete.HorizontalAlign = HorizontalAlign.Left;
        hc_ProfDelete.Style.Add("Position", "relative");
        hc_ProfDelete.Style.Add("right", "40px");
        hc_ProfDelete.Width = Unit.Percentage(0.8);

        hr.Cells.Add(hc_ProfDelete);

        tbl_ProfessSlab.Rows.Add(hr);


        int id = Convert.ToInt32(v);

        for (int i = 1; i <= id; i++)
        {
            TableRow tr = new TableRow();
            tr.ID = "tr_Prof_" + i;
            tr.CssClass = "row form-group col-md-12";

            TableCell tc_Slab = new TableCell();
            tc_Slab.CssClass = "col-md-2";

            tc_Slab.HorizontalAlign = HorizontalAlign.Left;
            tc_Slab.Width = Unit.Percentage(0.4);
            Label lbl_Slab = new Label();
            lbl_Slab.ID = "lbl_ProfSlab" + i;
            lbl_Slab.Text = "Professional Slab" + i;

            tc_Slab.Controls.Add(lbl_Slab);
            tr.Cells.Add(tc_Slab);

            TableCell tc_RangeFrom = new TableCell();
            tc_RangeFrom.CssClass = "col-md-2 ";
            tc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
            tc_RangeFrom.Width = Unit.Percentage(1);
            TextBox tb_SlabFrom = new TextBox();
            tb_SlabFrom.ID = "txt_ProfRangeFrom_" + i;
            tb_SlabFrom.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
            tb_SlabFrom.Attributes.Add("onpaste", "return false;");
            tb_SlabFrom.Attributes.Add("ondrop", "return false;");
            tb_SlabFrom.Attributes.Add("runnat", "Server");
            tb_SlabFrom.Attributes.Add("Placeholder", " ₹ INR");
            tb_SlabFrom.MaxLength = 12;
            tb_SlabFrom.CssClass = "form-control ";
            tc_RangeFrom.Controls.Add(tb_SlabFrom);
            tr.Cells.Add(tc_RangeFrom);


            TableCell tc_RangeTO = new TableCell();
            tc_RangeTO.CssClass = "col-md-2";
            tc_RangeTO.HorizontalAlign = HorizontalAlign.Center;
            tc_RangeTO.Width = Unit.Percentage(1);
            TextBox tb_SlabTO = new TextBox();
            tb_SlabTO.ID = "txt_ProfRangeTo_" + i;
            tb_SlabTO.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
            tb_SlabTO.Attributes.Add("onpaste", "return false;");
            tb_SlabTO.Attributes.Add("ondrop", "return false;");
            tb_SlabTO.Attributes.Add("runnat", "Server");
            tb_SlabTO.Attributes.Add("Placeholder", " ₹ INR");
            tb_SlabTO.MaxLength = 12;
            tb_SlabTO.CssClass = "form-control";

            tc_RangeTO.Controls.Add(tb_SlabTO);
            tr.Cells.Add(tc_RangeTO);

            TableCell tc_ProfPercent = new TableCell();
            tc_ProfPercent.ID = "tc_ProfTaxPercentage_"+i;
            tc_ProfPercent.CssClass = "col-md-2";
            tc_ProfPercent.HorizontalAlign = HorizontalAlign.Center;
            tc_ProfPercent.Width = Unit.Percentage(1);
            TextBox tb_SlabPercent = new TextBox();
            tb_SlabPercent.ID = "txt_ProfRangePercent_" + i;
            tb_SlabPercent.Attributes.Add("onkeypress", "return number_dot(event,this);");
            tb_SlabPercent.Attributes.Add("onpaste", "return false;");
            tb_SlabPercent.Attributes.Add("ondrop", "return false;");
            tb_SlabPercent.Attributes.Add("Placeholder", " %");
            tb_SlabPercent.MaxLength = 5;
            tb_SlabPercent.CssClass = "form-control ";
            tc_ProfPercent.Visible = true;
            tc_ProfPercent.Controls.Add(tb_SlabPercent);
            tr.Cells.Add(tc_ProfPercent);

            TableCell tc_ProfAmount = new TableCell();
            tc_ProfAmount.ID = "tc_ProfAmount_" + i;
            tc_ProfAmount.CssClass = "col-md-2";
            tc_ProfAmount.HorizontalAlign = HorizontalAlign.Center;
            tc_ProfAmount.Width = Unit.Percentage(1);
            TextBox tb_SlabAmonunt = new TextBox();
            tb_SlabAmonunt.ID = "txt_ProfRangeAmount_" + i;
            tb_SlabAmonunt.Attributes.Add("onkeypress", "return number_dot(event,this);");
            tb_SlabAmonunt.Attributes.Add("onpaste", "return false;");
            tb_SlabAmonunt.Attributes.Add("ondrop", "return false;");
            tb_SlabAmonunt.Attributes.Add("Placeholder", "₹ INR");
            tb_SlabAmonunt.MaxLength = 5;
            tb_SlabAmonunt.CssClass = "form-control ";
            tb_SlabAmonunt.Visible = true;
            tc_ProfAmount.Controls.Add(tb_SlabAmonunt);
            tc_ProfAmount.Visible = true;
            tr.Cells.Add(tc_ProfAmount);

            if (rbtn_Amount.Checked)
            {
                tc_ProfAmount.Visible = true;
                tc_ProfPercent.Visible = false;
            }
            else
            {
                tc_ProfPercent.Visible = true;
                tc_ProfAmount.Visible = false;

            }
            tr.Cells.Add(tc_ProfPercent);

            TableCell tc_deletebtn = new TableCell();
            tc_deletebtn.ID = "tc_Prodelete_btn_" + i;
            tc_deletebtn.HorizontalAlign = HorizontalAlign.Center;
            tc_deletebtn.Width = Unit.Percentage(0.55);
            LinkButton btnDelete = new LinkButton();
            btnDelete.ID = "Prof_SlabDelete_" + i;
            //btnDelete.Text = "Delete";
            btnDelete.ToolTip = "Profesional Slab Delete";
            //btnDelete.CommandName = "Delete";
            btnDelete.CssClass = "btn del-btn fa-trash-o";
            btnDelete.CommandArgument = i.ToString();
            btnDelete.Click += new EventHandler(btnDeleteProf_Click);
            tc_deletebtn.Controls.Add(btnDelete);
            tr.Cells.Add(tc_deletebtn);


            int count = Convert.ToInt32(Session["ProfSlabCount"]);

            if (i == count && i != 3)
            {
               
                btnDelete.Visible = true;
               
               
            }
            else
            {
                btnDelete.Visible = false;
                tc_deletebtn.Width = Unit.Percentage(0.8);
            }

            tbl_ProfessSlab.Rows.Add(tr);

            hdnProfPolicyCount.Value = Convert.ToString(i);


        }
    }

    protected void btn_ProfessAddSlab_Click(object sender, EventArgs e)
    {

        int rowId;
        rowId = Convert.ToInt32(Session["ProfSlabCount"]);
        rowId = rowId + 1;


        TableRow tr = new TableRow();
        tr.ID = "tr_Prof_" + rowId;
        tr.CssClass = "row form-group col-md-12";

        TableCell tc_Slab = new TableCell();
        tc_Slab.CssClass = "col-md-2";
        tc_Slab.HorizontalAlign = HorizontalAlign.Left;
        tc_Slab.Width = Unit.Percentage(0.4);

        Label lbl_Slab = new Label();
        lbl_Slab.ID = "lbl_ProfSlab" + rowId;
        lbl_Slab.Text = "Professional Slab" + rowId;

        tc_Slab.Controls.Add(lbl_Slab);
        tr.Cells.Add(tc_Slab);


        TableCell tc_RangeFrom = new TableCell();
        tc_RangeFrom.CssClass = "col-md-2";
        tc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
        tc_RangeFrom.Width = Unit.Percentage(1);
        TextBox tb_SlabFrom = new TextBox();
        tb_SlabFrom.ID = "txt_ProfRangeFrom_" + rowId;
        tb_SlabFrom.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
        tb_SlabFrom.Attributes.Add("onkeyup", "PreventFirstZero(event)");
        tb_SlabFrom.Attributes.Add("onpaste", "return false;");
        tb_SlabFrom.Attributes.Add("ondrop", "return false;");
        tb_SlabFrom.Attributes.Add("runnat", "Server");
        tb_SlabFrom.Attributes.Add("Placeholder", " ₹ INR");
        tb_SlabFrom.MaxLength = 12;
        tb_SlabFrom.CssClass = "form-control ";
        tc_RangeFrom.Controls.Add(tb_SlabFrom);
        tr.Cells.Add(tc_RangeFrom);


        TableCell tc_RangeTO = new TableCell();
        tc_RangeTO.CssClass = "col-md-2";
        tc_RangeTO.HorizontalAlign = HorizontalAlign.Center;
        tc_RangeTO.Width = Unit.Percentage(1);
        TextBox tb_SlabTO = new TextBox();
        tb_SlabTO.ID = "txt_ProfRangeTo_" + rowId;
        tb_SlabTO.Attributes.Add("onkeypress", "return onlyNumbersValue(event,this);");
        tb_SlabTO.Attributes.Add("onpaste", "return false;");
        tb_SlabTO.Attributes.Add("ondrop", "return false;");
        tb_SlabTO.Attributes.Add("runnat", "Server");
        tb_SlabTO.Attributes.Add("Placeholder", " ₹ INR");
        tb_SlabTO.MaxLength = 12;
        tb_SlabTO.CssClass = "form-control";
        tc_RangeTO.Controls.Add(tb_SlabTO);
        tr.Cells.Add(tc_RangeTO);

        TableCell tc_ProfPercent = new TableCell();
        tc_ProfPercent.ID= "tc_ProfTaxPercentage_"+rowId;
        tc_ProfPercent.CssClass = "col-md-2";
        tc_ProfPercent.HorizontalAlign = HorizontalAlign.Center;
        tc_ProfPercent.Width = Unit.Percentage(1);
        TextBox tb_SlabPercent = new TextBox();
        tb_SlabPercent.ID = "txt_ProfRangePercent_" + rowId;
        tb_SlabPercent.Attributes.Add("onkeypress", "return number_dot(event,this);");
        tb_SlabPercent.Attributes.Add("onpaste", "return false;");
        tb_SlabPercent.Attributes.Add("ondrop", "return false;");
        tb_SlabPercent.Attributes.Add("Placeholder", "%");
        tb_SlabPercent.MaxLength = 5;
        tb_SlabPercent.CssClass = "form-control ";
        tb_SlabPercent.Visible = true;
        tc_ProfPercent.Controls.Add(tb_SlabPercent);
        tc_ProfPercent.Visible = true;
        tr.Cells.Add(tc_ProfPercent);
  

        TableCell tc_ProfAmount = new TableCell();
        tc_ProfAmount.ID = "tc_ProfAmount_" + rowId;
        tc_ProfAmount.CssClass = "col-md-2";
        tc_ProfAmount.HorizontalAlign = HorizontalAlign.Center;
        tc_ProfAmount.Width = Unit.Percentage(1);
        TextBox tb_SlabAmonunt = new TextBox();
        tb_SlabAmonunt.ID = "txt_ProfRangeAmount_" + rowId;
        tb_SlabAmonunt.Attributes.Add("onkeypress", "return number_dot(event,this);");
        tb_SlabAmonunt.Attributes.Add("onpaste", "return false;");
        tb_SlabAmonunt.Attributes.Add("ondrop", "return false;");
        tb_SlabAmonunt.Attributes.Add("Placeholder", "₹ INR");
        tb_SlabAmonunt.MaxLength = 5;
        tb_SlabAmonunt.CssClass = "form-control ";
        tb_SlabAmonunt.Visible = true;
        tc_ProfAmount.Controls.Add(tb_SlabAmonunt);
        tc_ProfAmount.Visible = true;
        tr.Cells.Add(tc_ProfAmount);

        if (rbtn_Amount.Checked)
        {
            tc_ProfAmount.Visible = true;
            tc_ProfPercent.Visible = false;
        }
        else
        {
            tc_ProfPercent.Visible = true;
            tc_ProfAmount.Visible = false;

        }

        TableCell tc_deletebtn = new TableCell();
        tc_deletebtn.ID = "tc_Prodelete_btn_" + rowId;
        tc_deletebtn.HorizontalAlign = HorizontalAlign.Center;
        tc_deletebtn.Width = Unit.Percentage(0.57);

        LinkButton btnDelete = new LinkButton();
        btnDelete.ID = "Prof_SlabDelete_" + rowId;
        btnDelete.CssClass = "btn del-btn fa-trash-o";
        btnDelete.CommandArgument = rowId.ToString();
        btnDelete.Click += new EventHandler(btnDeleteProf_Click);
        tc_deletebtn.Controls.Add(btnDelete);
        tr.Cells.Add(tc_deletebtn);

        LinkButton btnPrviousdelete = (LinkButton)tbl_ProfessSlab.Rows[rowId - 1].FindControl("Prof_SlabDelete_" + (rowId - 1));
        btnPrviousdelete.Visible = false;
        TableCell prevCell=(TableCell)tbl_ProfessSlab.Rows[rowId - 1].FindControl("tc_Prodelete_btn_" + (rowId - 1));
        prevCell.Width = Unit.Percentage(0.8);


        tbl_ProfessSlab.Rows.Add(tr);
        hdnProfPolicyCount.Value = Convert.ToString(rowId);
        Session["ProfSlabCount"] = rowId;

       
       
    }



    private void btnDeleteProf_Click(object sender, EventArgs e)
    {
        LinkButton delbtn = (LinkButton)sender;
        int thisRow = Convert.ToInt32(delbtn.CommandArgument);
        TableRow tr = new TableRow();

        tr.ID = "tr_Prof_" + thisRow;
        // Delete Slab Value 
        Label slabName = (Label)tbl_ProfessSlab.Rows[thisRow].FindControl("lbl_ProfSlab" + thisRow);
        String profSlabName = slabName.Text;
        Hashtable deleteSlab = new Hashtable();
        deleteSlab.Add("@tag", "PSD");
        deleteSlab.Add("@ProfSlabName", profSlabName);
        deleteSlab.Add("@TaxPolicyId", intPolicyID);
        objPayrollEventData.InsertTaxSlabValues(deleteSlab);

        tbl_ProfessSlab.Rows.Remove(tbl_ProfessSlab.Rows[thisRow]);

        // hdnTaxPolicyCount.Value = Convert.ToString(tbl_ProfessSlab.Rows.Count - 1);

        Session["ProfSlabCount"] = tbl_ProfessSlab.Rows.Count - 1;

        if (thisRow - 1 != 3)
        {
            TableCell tc_cell = (TableCell)tbl_ProfessSlab.Rows[thisRow - 1].FindControl("tc_Prodelete_btn_" + (thisRow - 1));
            tc_cell.Width = Unit.Percentage(0.57);
            LinkButton btndelete = (LinkButton)tbl_ProfessSlab.Rows[thisRow - 1].FindControl("Prof_SlabDelete_" + (thisRow - 1));
            btndelete.Visible = true;
            tc_cell.Controls.Add(btndelete);
        }
    }


    private void ProfessionalTaxTableCreate()
    {
        tbl_ProfessSlab.ID = "tbl_ProfSlab";
        tbl_ProfessSlab.CssClass = "Col-md-12";

        TableHeaderRow hr = new TableHeaderRow();
        hr.CssClass = "row form-group col-md-12";

        TableHeaderCell hc_slabName = new TableHeaderCell();
        hc_slabName.CssClass = "col-md-2 lvepo-tblHeader";
        hc_slabName.VerticalAlign = VerticalAlign.Top;
        hc_slabName.Width = Unit.Percentage(0.4);
        hr.Cells.Add(hc_slabName);

        TableHeaderCell hc_RangeFrom = new TableHeaderCell();
        hc_RangeFrom.CssClass = "col-md-2 lvepo-tblHeader";
        hc_RangeFrom.VerticalAlign = VerticalAlign.Top;
        hc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
        hc_RangeFrom.Width = Unit.Percentage(1);
        hc_RangeFrom.Style.Add("Position", "relative");
        hc_RangeFrom.Style.Add("left", "50px");
        hc_RangeFrom.Text = "Range From";
        hr.Cells.Add(hc_RangeFrom);

        TableHeaderCell hc_RangeTo = new TableHeaderCell();
        hc_RangeTo.CssClass = "col-md-2 lvepo-tblHeader";
        hc_RangeTo.VerticalAlign = VerticalAlign.Top;
        hc_RangeTo.HorizontalAlign = HorizontalAlign.Center;
        hc_RangeTo.Style.Add("Position", "relative");
        hc_RangeTo.Style.Add("left", "50px");
        hc_RangeTo.Width = Unit.Percentage(1);
        hc_RangeTo.Text = "Range To";
        hr.Cells.Add(hc_RangeTo);

        TableHeaderCell hc_TdsPercent = new TableHeaderCell();
        hc_TdsPercent.CssClass = "col-md-2 lvepo-tblHeader";
        hc_TdsPercent.VerticalAlign = VerticalAlign.Top;
        hc_TdsPercent.HorizontalAlign = HorizontalAlign.Center;
        hc_TdsPercent.Style.Add("Position", "relative");
        hc_TdsPercent.Style.Add("left", "40px");
        hc_TdsPercent.Width = Unit.Percentage(1);
        hc_TdsPercent.Text = "Professional Tax";
        hr.Cells.Add(hc_TdsPercent);

        TableHeaderCell hc_ProfDelete = new TableHeaderCell();
        hc_ProfDelete.CssClass = "col-md-2 lvepo-tblHeader";
        hc_ProfDelete.VerticalAlign = VerticalAlign.Top;
        hc_ProfDelete.HorizontalAlign = HorizontalAlign.Left;
        //hc_ProfDelete.Style.Add("Position", "relative");
        //hc_ProfDelete.Style.Add("left", "55px");
        hc_ProfDelete.Width = Unit.Percentage(0.8);

        hr.Cells.Add(hc_ProfDelete);

        tbl_ProfessSlab.Rows.Add(hr);

    }
    #region Table Header
    private void TableCreate()
    {
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        // LoadStrings Function fills the Label from the Resource File
        LoadStrings(ci);
        tbl_TdsSlab.ID = "tbl_Slab";
        tbl_TdsSlab.CssClass = "Col-md-12 ";

        TableHeaderRow hr = new TableHeaderRow();
        hr.CssClass = "row form-group col-md-12";

        TableHeaderCell hc_slabName = new TableHeaderCell();
        hc_slabName.CssClass = "col-md-2 lvepo-tblHeader";
        hc_slabName.VerticalAlign = VerticalAlign.Top;
        hc_slabName.HorizontalAlign = HorizontalAlign.Left;
        hc_slabName.Text = "Tax slab No";
        hc_slabName.Style.Add("opacity", "0");
        hc_slabName.Width = Unit.Percentage(1);
        Label lbl_hcSlab = new Label();

        hr.Cells.Add(hc_slabName);

        TableHeaderCell hc_RangeFrom = new TableHeaderCell();
        hc_RangeFrom.CssClass = "col-md-2 lvepo-tblHeader";
        hc_RangeFrom.HorizontalAlign = HorizontalAlign.Center;
        hc_RangeFrom.Width = Unit.Percentage(1);
        hc_RangeFrom.Style.Add("Position", "relative");
        hc_RangeFrom.Style.Add("left", "30px");
        hc_RangeFrom.Text = "Range From";
        hr.Cells.Add(hc_RangeFrom);

        TableHeaderCell hc_RangeTo = new TableHeaderCell();
        hc_RangeTo.CssClass = "col-md-2 lvepo-tblHeader";
        hc_RangeTo.VerticalAlign = VerticalAlign.Middle;
        hc_RangeTo.HorizontalAlign = HorizontalAlign.Center;
        hc_RangeTo.Style.Add("Position", "relative");
        hc_RangeTo.Style.Add("left", "40px");
        hc_RangeTo.Width = Unit.Percentage(1);
        hc_RangeTo.Text = "Range To";
        hr.Cells.Add(hc_RangeTo);

        TableHeaderCell hc_TdsPercent = new TableHeaderCell();
        hc_TdsPercent.CssClass = "col-md-2 lvepo-tblHeader";
        hc_TdsPercent.VerticalAlign = VerticalAlign.Middle;
        hc_TdsPercent.HorizontalAlign = HorizontalAlign.Center;
        hc_TdsPercent.Style.Add("Position", "relative");
        hc_TdsPercent.Style.Add("left", "50px");
        hc_TdsPercent.Width = Unit.Percentage(1);
        hc_TdsPercent.Text = "TDS %";
        hr.Cells.Add(hc_TdsPercent);

        TableHeaderCell hc_Plus = new TableHeaderCell();
        hc_Plus.CssClass = "col-md-1 lvepo-tblHeader";
        hc_Plus.VerticalAlign = VerticalAlign.Middle;
        hc_Plus.HorizontalAlign = HorizontalAlign.Center;
        hc_Plus.Width = Unit.Percentage(0);
        hc_Plus.Text = "Symbol";
        hc_Plus.Style.Add("opacity", "0");
        hr.Cells.Add(hc_Plus);

        TableHeaderCell hc_Cess = new TableHeaderCell();
        hc_Cess.CssClass = "col-md-2 lvepo-tblHeader";
        hc_Cess.VerticalAlign = VerticalAlign.Middle;
        hc_Cess.HorizontalAlign = HorizontalAlign.Center;
        hc_Cess.Width = Unit.Percentage(1);
        hc_Cess.Style.Add("Position", "relative");
        hc_Cess.Style.Add("left", "40px");
        hc_Cess.Text = "Additional Cess";
        hr.Cells.Add(hc_Cess);

        TableHeaderCell hc_Delete = new TableHeaderCell();
        hc_Delete.CssClass = "col-md-1 lvepo-tblHeader";
        hc_Delete.VerticalAlign = VerticalAlign.Middle;
        hc_Delete.Width = Unit.Percentage(1);
        hc_Delete.HorizontalAlign = HorizontalAlign.Center;
        hc_Delete.Text = "Delete";
        hc_Delete.Style.Add("opacity", "0");
        hr.Cells.Add(hc_Delete);
        tbl_TdsSlab.Rows.Add(hr);
    }
    #endregion


    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(317, Convert.ToInt32(Session["userGroup_Id"]), "addPrv");

        if (ds_Checkuser.Tables[0].Rows.Count == 0)
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
    }

    protected void ddlEmpCatagory_DataBound(object sender, EventArgs e)
    {
        DropDownList ddl = sender as DropDownList;
        DropdownTooltip(ddl);
    }
    protected void ddlEmpType_DataBound(object sender, EventArgs e)
    {
        DropDownList ddl = sender as DropDownList;
        DropdownTooltip(ddl);
    }

    private void DropdownTooltip(DropDownList ddl)
    {
        if (ddl != null)
        {
            foreach (ListItem li in ddl.Items)
            {
                li.Attributes["title"] = li.Text;
            }
        }
    }
    private void BindingEmployeeCategoryandType()
    {
        // employee category binding
        DataSet dsCategory = new DataSet();
        dsCategory = objEmployeeEventData.SelectCategoryDetailsEmployee("");
        if (dsCategory != null)
        {
            if (dsCategory.Tables[0].Rows.Count > 0)
            {
                ddlEmpCatagory.DataSource = dsCategory;
                ddlEmpCatagory.DataTextField = "CategoryName";
                ddlEmpCatagory.DataValueField = "CategoryId";
                ddlEmpCatagory.DataBind();
            }
            dsCategory.Dispose();
            foreach (ListItem item in ddlEmpCatagory.Items)
            {
                item.Attributes.Add("title", item.Text);
            }
        }
        // employee type binding
        DataSet dsType = new DataSet();
        dsType = objEmployeeEventData.SelectTypeDetailsEmployee("");
        if (dsType != null)
        {
            if (dsType.Tables[0].Rows.Count > 0)
            {
                ddlEmpType.DataSource = dsType;
                ddlEmpType.DataTextField = "TypeName";
                ddlEmpType.DataValueField = "TypeId";
                ddlEmpType.DataBind();
            }
            dsType.Dispose();
            foreach (ListItem item in ddlEmpType.Items)
            {
                item.Attributes.Add("title", item.Text);
            }
        }

    }
    private void CompanyBinding()
    {
        DataSet dsCompany = new DataSet();
        dsCompany = objShift.SelectCompany(gstrUserGroupName, Convert.ToString(Session["LevelRights"]), 0);
        if (dsCompany != null)
        {
            if (dsCompany.Tables[0].Rows.Count > 0)
            {
                ddlCompany.DataSource = dsCompany;
                ddlCompany.DataTextField = "CompanyName";
                ddlCompany.DataValueField = "CompanyId";
                ddlCompany.DataBind();
            }
        }
        foreach (ListItem item in ddlCompany.Items)
        {
            item.Attributes.Add("title", item.Text);
        }
    }

    protected void rbtn_Amount_CheckedChanged(object sender, EventArgs e)
    {
        int rowCount = Convert.ToInt32(Session["ProfSlabCount"]);

        for (int i = 1; i <= rowCount; i++)
        {
            TableCell tc_cell_Prof = (TableCell)tbl_ProfessSlab.Rows[i].FindControl("tc_ProfTaxPercentage_" + i);
            tc_cell_Prof.Visible = false;
            TableCell tc_cell_Amount = (TableCell)tbl_ProfessSlab.Rows[i].FindControl("tc_ProfAmount_" + i);
            tc_cell_Amount.Width = Unit.Percentage(1);
            tc_cell_Amount.Visible = true;


        }
        Session["ProfSlabCount"] = tbl_ProfessSlab.Rows.Count - 1;

        int thisRow = Convert.ToInt32(Session["ProfSlabCount"]);


        if (thisRow != 3)
        {
            TableCell tc_cell = (TableCell)tbl_ProfessSlab.Rows[thisRow ].FindControl("tc_Prodelete_btn_" + (thisRow));
            tc_cell.Width = Unit.Percentage(0.7);
            LinkButton btndelete = (LinkButton)tbl_ProfessSlab.Rows[thisRow].FindControl("Prof_SlabDelete_" + (thisRow));
            btndelete.Visible = true;
            tc_cell.Controls.Add(btndelete);
        }

    }

    protected void rbtn_Percentage_CheckedChanged(object sender, EventArgs e)
    {
        int rowCount = Convert.ToInt32(Session["ProfSlabCount"]);


        for (int i = 1; i <= rowCount; i++)
        {
            TableCell tc_cellAmount = (TableCell)tbl_ProfessSlab.Rows[i].FindControl("tc_ProfAmount_" + i);
            tc_cellAmount.Visible = false;

            TableCell tc_cell_Prof = (TableCell)tbl_ProfessSlab.Rows[i].FindControl("tc_ProfTaxPercentage_" + i);
            tc_cell_Prof.Width = Unit.Percentage(1);
            tc_cell_Prof.Visible = true;

        }

        Session["ProfSlabCount"] = tbl_ProfessSlab.Rows.Count - 1;

        int thisRow = Convert.ToInt32(Session["ProfSlabCount"]);

        if (thisRow != 3)
        {
            TableCell tc_cell = (TableCell)tbl_ProfessSlab.Rows[thisRow].FindControl("tc_Prodelete_btn_" + (thisRow));
            tc_cell.Width = Unit.Percentage(0.7);
            LinkButton btndelete = (LinkButton)tbl_ProfessSlab.Rows[thisRow].FindControl("Prof_SlabDelete_" + (thisRow));
            btndelete.Visible = true;
            tc_cell.Controls.Add(btndelete);
        }
    }



}