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


public partial class Masters_TA_UI_Master_ConveyanceAllowanceView :Base.BasePage
{
    ResourceManager rm;
    CultureInfo ci;
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    DataSet dsPFESIPOlicy;
    Int64 getPFESIID, EmpID;
    String gstrUserGroupName = String.Empty;
    PayrollConfigurationEventData objLoanEntry = new PayrollConfigurationEventData();
    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;

        EmpID = Int32.Parse(Session["EmpAutoID"].ToString());
        //btn_Modify.Focus();
        loadcss();
        LoadStrings(ci);
        getPFESIID = Convert.ToInt64(Request.QueryString["C_Id"]);
        gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
        if (!Page.IsPostBack)
        {
            UserRights();
            LoadStrings(ci);
            GetLoanEntryDetails();
        }



        int intIndividualUser = objCheckUser.CheckIndividualUser(Convert.ToString(Session["UserGroupName"]));
    }
    private void GetLoanEntryDetails()
    {
        dsPFESIPOlicy = new DataSet();
        //DataTable dtPFESEntry = new DataTable();
        Hashtable htable = new Hashtable();
        htable.Add("@Type", "P");
        htable.Add("@Policy_Id", getPFESIID);
        htable.Add("@UserGroupName", gstrUserGroupName);

        dsPFESIPOlicy = objLoanEntry.SelectConveyancePolicyDetails(htable);
        //dtLoanEntry = dsPFESIPOlicy.Tables[0];

        //gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
        //intPolicyID = Convert.ToInt32(Request.QueryString["Policy_Id"]);
        //DataSet ds_LeaveType = new DataSet();
        //DataSet ds_LeavePolicy = new DataSet();
        //ds_LeavePolicy = objLeave.SelectLeavePolicyByID(intPolicyID, gstrUserGroupName);
        //DataSet ds_leavePolicyDetails = new DataSet();
        //ds_leavePolicyDetails = objLeave.SelectLeavePolicyDetails(intPolicyID);

        if (dsPFESIPOlicy != null && dsPFESIPOlicy.Tables[0].Rows.Count > 0)
        {
            #region "Filling Leave Policy"
            if (Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["CompanyName"]) != null)
            {
                lblSelectedCompany.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["CompanyName"]);
            }
            // filling Leave policy 
            lblPolicyName.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["ConPolicyName"]);
            if (Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["EmployeeCategorys"]) != "")
            {
                lblEmployeeCategory.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["EmployeeCategorys"]);
            }
            else
            {
                lblEmployeeCategory.Text = "All";
            }
            if (Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["EmployeeTypes"]) != "")
            {
                lblEmployeeType.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["EmployeeTypes"]);
            }
            else
            {
                lblEmployeeType.Text = "All";
            }
            if (Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["Gender"]) != " " && Convert.ToInt32(dsPFESIPOlicy.Tables[0].Rows[0]["Gender"]) == 1)
            {
                lbl_Gender.Text = "Male";
            }
            else if (Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["Gender"]) != " " && Convert.ToInt32(dsPFESIPOlicy.Tables[0].Rows[0]["Gender"]) == 2)
            {
                lbl_Gender.Text = "Female";
            }
            else
            {
                lbl_Gender.Text = "Both";
            }

            if (Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["LimitAmount"]) != " ")
            {
                txt_MaximumAmount.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["LimitAmount"]);
            }
            else
            {
                txt_MaximumAmount.Text = " ";
            }
            String conveanceType = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["Con_type"]);
            if (conveanceType=="Percentage")
            {
                txt_ConveyanceAllowance.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["conPercentage"]);
                //txt_ConveyanceType.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["Con_type"]);
            }
            else 
            {
                
                txt_ConveyanceAllowance.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["conAmount"]);
                //txt_ConveyanceType.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["Con_type"]);
            }
            //if (Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["ESI_Employee"]) != " ")
            //{
            //    txt_ESIEmployee.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["ESI_Employee"]);
            //}
            //else
            //{
            //    txt_ESIEmployee.Text = " ";
            //}
            //if (Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["ESI_Employer"]) != " ")
            //{
            //    txt_ESIEmployer.Text = Convert.ToString(dsPFESIPOlicy.Tables[0].Rows[0]["ESI_Employer"]);
            //}
            //else
            //{
            //    txt_ESIEmployer.Text = " ";
            //}
            #endregion
        }
    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(26, 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_Master_LoanAddDetails.aspx");
            }
            if (ds_Checkuser.Tables[0].Rows[0]["modifyPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["modifyPrv"]) == 1)
            {
                // this.btn_Modify.Visible = true;
            }
            else
            {
                //   this.btn_Modify.Visible = false;
            }
            if (ds_Checkuser.Tables[0].Rows[0]["deletePrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["deletePrv"]) == 1)
            {
                //   this.btn_Delete.Visible = true;
            }
            else
            {
                //  this.btn_Delete.Visible = false;
            }
        }
        else
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
    }
    private void LoadStrings(CultureInfo ci)
    {
        lbl_HeaderLeavePolicy.Text = rm.GetString("ConveyanceAllowanceHeader", ci);

        lblCompany.Text = rm.GetString("EntranceMaster_Company", ci);
        lbl_PolicyName.Text = rm.GetString("LeavePermissionPolicy_PolicyName", ci);
        lblGender.Text = rm.GetString("EmployeeMaster_Gender", ci);

        lblEmpCategory.Text = rm.GetString("Master_Category", ci);
        lblEmpType.Text = rm.GetString("Master_Type", ci);
        //chkPF_ESIPolicy.Text = rm.GetString("Conveyance_policy", ci);

        //btn_Add.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Add", ci);
        //chkProfessionalTax.Text = rm.GetString("UserGroup_Professional", ci);
        //btn_Add_Professional.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Add", ci);
        //btn_save.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Save", ci);
        //btn_cancel.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Back", 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
        htmlLeavePolicy.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";
            stylefonts.Href = "../dist/css/fonts.css";
        }
        else
        {
            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";
            stylefonts.Href = "../dist/css/fonts.css";
        }
    }
}