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


public partial class Masters_TA_UI_Master_TaxPolicyView : Base.BasePage
{
    #region "Variable Declaration"
    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();
    int counter = 0;
    string source_Language;
    string strScript = string.Empty;
  
    int intPolicyID = 0;
    int EmployeeID = 0;
    #endregion
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        //get the culture info to set the language
        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);
        loadcss();
        EmployeeID = Convert.ToInt32(Session["EmpAutoID"]);

        if(!IsPostBack)
        {
            UserRights();
            gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
            intPolicyID = Convert.ToInt32(Request.QueryString["TaxPolicy_Id"]);
            DataSet ds_TdsSlab = new DataSet();
            DataSet ds_TaxPolicy= new DataSet();
            Hashtable htable = new Hashtable();
            htable.Add("@tag", "P");
            htable.Add("@TaxPolicyID", intPolicyID);
            ds_TaxPolicy = objPayrollEventData.InsertTaxPolicy(htable);

            if(ds_TaxPolicy.Tables[0].Rows.Count>0)
            {
                if (Convert.ToString(ds_TaxPolicy.Tables[0].Rows[0]["CompanyName"]) != null)
                {
                    lblSelectedCompany.Text = Convert.ToString(ds_TaxPolicy.Tables[0].Rows[0]["CompanyName"]);
                }
                // filling Leave policy 
                lblPolicyName.Text = Convert.ToString(ds_TaxPolicy.Tables[0].Rows[0]["TaxPolicyName"]);
                if (Convert.ToString(ds_TaxPolicy.Tables[0].Rows[0]["EmployeeCategorys"]) != "")
                {
                    lblEmployeeCategory.Text = Convert.ToString(ds_TaxPolicy.Tables[0].Rows[0]["EmployeeCategorys"]);
                }
                else
                {
                    lblEmployeeCategory.Text = "All";
                }
                if (Convert.ToString(ds_TaxPolicy.Tables[0].Rows[0]["EmployeeTypes"]) != "")
                {
                    lblEmployeeType.Text = Convert.ToString(ds_TaxPolicy.Tables[0].Rows[0]["EmployeeTypes"]);
                }
                else
                {
                    lblEmployeeType.Text = "All";
                }
                if (Convert.ToString(ds_TaxPolicy.Tables[0].Rows[0]["Gender"]) != "")
                {
                    lbl_Gender.Text = Convert.ToString(ds_TaxPolicy.Tables[0].Rows[0]["Gender"]);
                }
                else
                {
                    lbl_Gender.Text = "Both";
                }
                if(ds_TaxPolicy.Tables[1].Rows.Count>0)
                {
                    int i = 1;
                    foreach (DataRow dr in ds_TaxPolicy.Tables[1].Rows)
                    {
                        TableRow tr = new TableRow();
                        tr.CssClass = "lve-text lve-potablebg";
                        TableCell tc_SlabName = new TableCell();
                        tc_SlabName.Text = Convert.ToString(dr["Tds_SlabNo"]);
                        tr.Cells.Add(tc_SlabName);

                        TableCell tc_SlabRangeFrom = new TableCell();
                        tc_SlabRangeFrom.Text = Convert.ToString(dr["Tds_RangeFrom"]);
                        tr.Cells.Add(tc_SlabRangeFrom);


                        TableCell tc_SlabRangeTo = new TableCell();
                        tc_SlabRangeTo.Text = Convert.ToString(dr["Tds_RangeTo"]);
                        tr.Cells.Add(tc_SlabRangeTo);

                        TableCell tc_TdsPercentage = new TableCell();
                        tc_TdsPercentage.Text = Convert.ToString(dr["Tds_Percentage"]);
                        tr.Cells.Add(tc_TdsPercentage);

                        TableCell tc_CessPercentage = new TableCell();
                        tc_CessPercentage.Text = Convert.ToString(dr["Tds_CessPercentage"]);
                        tr.Cells.Add(tc_CessPercentage);
                        tbl_TaxPolicy.Rows.Add(tr);
                        i = i + 1;
                    }
                }
                if(ds_TaxPolicy.Tables[2].Rows.Count > 0)
                {
                    int i = 1;
                    foreach (DataRow dr in ds_TaxPolicy.Tables[2].Rows)
                    {
                        TableRow trProf = new TableRow();
                        trProf.CssClass = "lve-text lve-potablebg";
                        TableCell tc_SlabName = new TableCell();
                        tc_SlabName.Text = Convert.ToString(dr["Prof_SlabName"]);
                        trProf.Cells.Add(tc_SlabName);

                        TableCell tc_SlabRangeFrom = new TableCell();
                        tc_SlabRangeFrom.Text = Convert.ToString(dr["Prof_RangeFrom"]);
                        trProf.Cells.Add(tc_SlabRangeFrom);


                        TableCell tc_SlabRangeTo = new TableCell();
                        tc_SlabRangeTo.Text = Convert.ToString(dr["Prof_RangeTO"]);
                        trProf.Cells.Add(tc_SlabRangeTo);

                        TableCell tc_TdsPercentage = new TableCell();
                        tc_TdsPercentage.Text = Convert.ToString(dr["Prof_Amount"]);
                        trProf.Cells.Add(tc_TdsPercentage);

                        //TableCell tc_CessPercentage = new TableCell();
                        //tc_CessPercentage.Text = Convert.ToString(dr["Tds_CessPercentage"]);
                        //tr.Cells.Add(tc_CessPercentage);

                        tbl_ProfPolicy.Rows.Add(trProf);
                        i = i + 1;
                    }
                }
                
            }
            objCommon.menu("PayrollMaster", "315");
        }


    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(315, Convert.ToInt32(Session["userGroup_Id"]), "");
        if (ds_Checkuser.Tables[0].Rows.Count > 0)
        {
            if (ds_Checkuser.Tables[0].Rows[0]["viewPrv"] == DBNull.Value || Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["viewPrv"]) != 1)
            {
                Response.Redirect("TA_UI_MasterLeavePolicyList.aspx");
            }
        }
        else
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
    }

    private void LoadStrings(CultureInfo ci)
    {
        lbl_ProfRangeFrom.Text = rm.GetString("lbl_RangeFrom", ci);
        lblCompany.Text = rm.GetString("EntranceMaster_Company", ci);
        lbl_ProfRangeTo.Text = rm.GetString("lbl_RangeTo", ci);
        lbl_ProfPercentage.Text = rm.GetString("lbl_ProfPercentage", ci);
       
        lbl_PolicyName.Text = rm.GetString("LeavePermissionPolicy_PolicyName", ci);
        lbl_HeaderLeavePolicy.Text = rm.GetString("Masters_Leave_LeavePermissionPolicy", ci);
        lbl_RecordStatus.Text = rm.GetString("DeleteStatus", ci);
        lblGender.Text = rm.GetString("EmployeeMaster_Gender", ci);
        lblEmpType.Text = rm.GetString("Master_Type", ci);
        lblEmpCategory.Text = rm.GetString("Master_Category", ci);
    
        lblTaxSlabName.Text = rm.GetString("lbl_taxslabname", ci);
        lblRangeFrom.Text = rm.GetString("lbl_RangeFrom", ci);
        lblRangeTo.Text = rm.GetString("lbl_RangeTo", ci);
        lblTdsPercentage.Text = rm.GetString("lbl_TdsPercentage", ci);
        lblCess.Text= rm.GetString("lbl_TdsCess", ci);
        lblProfSlabName.Text = rm.GetString("lbl_taxslabname", ci);


    }
    private void loadcss()
    {
        CultureInfo ci;
        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;
        //if Standard Demo
        htmlTaxPolicy.Attributes.Add("dir", rm.GetString("Direction", ci));
        if (source_Language == "Resources.Resource_AR")
        {
            stylebootstrap.Href = "../bootstrap/css/bootstrap-rtl.min.css";
            stylefontawesome.Href = "../bootstrap/font-awesome/css/font-awesome-rtl.css";
            styleAdminLTE.Href = "../dist/css/AdminLTE.min-rtl.css";
            stylecustom.Href = "../dist/css/custom-rtl.css";
            stylebuild.Href = "../bootstrap/font-awesome/css/build-rtl.css";
            stylefonts.Href = "../dist/css/fonts.css";
        }
        else
        {
            //htmlLeavePolicy.Attributes.Add("dir", "rtl");
            //stylebootstrap.Href = "../bootstrap/css/bootstrap-rtl.min.css";
            //stylefontawesome.Href = "../bootstrap/font-awesome/css/font-awesome-rtl.css";
            //styleAdminLTE.Href = "../dist/css/AdminLTE.min-rtl.css";
            //stylecustom.Href = "../dist/css/custom-rtl.css";
            //stylebuild.Href = "../bootstrap/font-awesome/css/build-rtl.css";
            //stylefonts.Href = "../dist/css/fonts.css";
            stylebootstrap.Href = "../bootstrap/css/bootstrap.min.css";
            stylefontawesome.Href = "../bootstrap/font-awesome/css/font-awesome.css";
            styleAdminLTE.Href = "../dist/css/AdminLTE.min.css";
            stylecustom.Href = "../dist/css/custom.css";
            stylebuild.Href = "../bootstrap/font-awesome/css/build.css";
            stylefonts.Href = "../dist/css/fonts.css";
        }
    }
}