using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
public partial class UserControls_TA_uc_OrgLevel_Filter : 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;
        }
        //"<script>var totLevels =" + tot + ";chckLevel1(0,0); </script>"
        // getTotLevel();
        getLev();
    }
    protected void getTotLevel()
    {
        cls_master_levels totLev = new cls_master_levels();
        int tot;
        tot = totLev.getNoLevel();
        //Response.Write("<script>var totLevels =" + tot + ";chckLevel1(0,0); </script>");
        this.Page.RegisterStartupScript("AjaxCalllMethod123", "<script>var totLevels =" + tot + ";chckLevel1(0,0); </script>");
    }
    private void getLev()
    {
        cls_master_levels totLev = new cls_master_levels();
        int tot;
        int maxId;
        tot = totLev.getNoLevel();
        maxId = totLev.getMaxLevel();
        string IDs = "";
        string IDsName = "";
        string IDsName1 = "";
        int intialVal = 0;
        DataSet ds_ParentLevels = new DataSet();
        DataSet ds_maxLevel = new DataSet();
        int LevelID = Convert.ToInt16(Session["orgLevelid"]);
        //objCommon.GetParentLevels_FromLevelID(LevelID);
        objCommon.GetParentLevels_FromLevelID(maxId);
        ds_ParentLevels = objCommon.GetParentLevels();
        foreach (DataRow dr in ds_ParentLevels.Tables[0].Rows)
        {
            if (IDs == "")
            {
                IDs = dr[0].ToString();
                IDsName = "'" + dr[1].ToString() + "'";
                IDsName1 = dr[1].ToString();
                //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("'", "\\'") + "'";
            }
            //this.set.InnerHtml = "<select name='ddlLevel0' class='dlist' onChange='getChild_getOrg(1,this.value," + intialVal  + ");' ></select>";
            //            this.lblTitle.Text=dr[1].ToString();
        }
        //this.Page.RegisterStartupScript("AjaxCalllMethod", "<script>var totLevels =" + (Convert.ToInt16(ds_ParentLevels.Tables[0].Rows.Count) - 1) + ";chckLevel1_getOrg(0,0);var levelArray=new Array(" + IDs + "); var levelNameArray = new Array(" + IDsName + "); </script>");
        this.Page.RegisterStartupScript("AjaxCalllMethod", "<script>var totLevels =" + (Convert.ToInt16(tot)) + ";var levelArray=new Array(" + IDs + "); var levelNameArray = new Array(" + IDsName + "); chckLevel1_getOrg(0,0,'" + rm.GetString("Select", ci) + "');</script>");
    }
}
