using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
public partial class UserControls_TA_uc_LevelsModify : System.Web.UI.UserControl
{
    cls_Common objCommon = new cls_Common();
    ResourceManager rm;
    CultureInfo ci;
    protected void Page_Load(object sender, EventArgs e)
    {
        //get the culture info to set the language               
        string strSourceLanguage;
        strSourceLanguage = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(strSourceLanguage, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        if (!IsPostBack)
        {
            //Session["parentLevelId"] = null;
        }
        getLev();
    }
    private void getLev()
    {
        cls_master_levels totLev = new cls_master_levels();
        int tot;
        int maxId;
        tot = totLev.getNoLevel();
        maxId = totLev.getMaxLevel();
        string IDs = "";
        string orgIds = "";
        string IDsName = "";
        string IDsName1 = "";
        int intialVal = 0;
        DataSet ds_ParentLevels = new DataSet();
        DataSet ds_maxLevel = new DataSet();
        int LevelID = Convert.ToInt16(Session["orgLevelid"]);
        ///Added by Manjula.P on 08-Jan-2014 for getting designation assign
        int DesignationId = 0;
        int ReportingTo = 0;
        int Authority = 0;
        //int LevelID = Convert.ToInt16(Session["parentLevelId_modify"]);
        //objCommon.GetParentLevels_FromLevelID(LevelID);
        //objCommon.GetParentLevels_FromLevelID(maxId);
        objCommon.GetParentLevels_FromLevelID(LevelID);
        ds_ParentLevels = objCommon.GetParentLevels();
        int count = 0;
        foreach (DataRow dr in ds_ParentLevels.Tables[0].Rows)
        {
            if (IDs == "")
            {
                IDs = dr[0].ToString();
                IDsName = "'" + dr[1].ToString().Replace("'", "\\'") + "'";
                IDsName1 = dr[1].ToString().Replace("'", "\\'") + "'";
                //this.lblTitle.Text = IDsName1;
                intialVal = Convert.ToInt16(IDs);
            }
            else
            {
                IDs = IDs + "," + dr[0].ToString();
                //IDsName = IDsName + "," + "'" + dr[1].ToString() + "'";
                IDsName = IDsName + "," + "'" + dr[1].ToString().Replace("'", "\\'") + "'";
            }
        }
        //getting parent of the selected organizationlevel
        //int orgID = Convert.ToInt16(Session["parentLevelId"]);
        int orgID = Convert.ToInt16(Session["parentLevelId_modify"]);
        //int orgID = 34;        
        org_levelsEventData getOrg = new org_levelsEventData();
        getOrg.GetOrgParentLevels_FromID(orgID);
        DataSet ds_getOrg = new DataSet();
        ds_getOrg = getOrg.GetOrgParentLevels();
        foreach (DataRow dr1 in ds_getOrg.Tables[0].Rows)
        {
            count = count + 1;
            if (orgIds == "")
            {
                orgIds = dr1[0].ToString();
            }
            else
            {
                orgIds = orgIds + "," + dr1[0].ToString();
            }
            //end
        }
        if (orgIds == "0")
        {
            count = 0;
        }
        if (IDs != "0" && IDs != "")
        {
            this.Page.RegisterStartupScript("AjaxCall", "<script>var orgArray=new Array( " + orgIds + ",0);var OrgDesignationId=" + DesignationId + ";  var ReportingTo=" + ReportingTo + "; var AthorityTo=" + Authority + ";var totLevels =" + count + ";var levelArray=new Array(" + IDs + "); var levelNameArray = new Array(" + IDsName + "); chckLevel1_getOrg(0,0,'" + rm.GetString("Select", ci) + "');</script>");
        }
    }
}
