﻿function $(id)
{
    return document.getElementById(id);
}
function showddlPlace(tParentCode,tSelfDll,tddl,tGet)
{
    if(tParentCode != "" && tParentCode != null && tddl != "" && tddl != null)
    {
        var tNowDll = $(tddl);
        var tPlaces = bounbary_Product_ProductList.GetNextPlace(tParentCode).value;
        if(tPlaces != "" && tPlaces != null && typeof(tPlaces) == "object")
        {
            tNowDll.length = 0;
            tNowDll.options.add(new Option("-请选择-",""));
            for(var i = 0;i < tPlaces.Rows.length;i++)
            {
                var txt = tPlaces.Rows[i].codeName;
                var val = tPlaces.Rows[i].code;
                tNowDll.options.add(new Option(txt,val));
            }
        }
    }
    if(tParentCode != null)
    {
        if($(tSelfDll).options[$(tSelfDll).selectedIndex].text == "-请选择-")
        {
            $(tGet).value = "";
        }
        else
        {
            $(tGet).value = $(tSelfDll).options[$(tSelfDll).selectedIndex].text;        
        }
    }
    
    var tP = null;
    var tC = null;
    if($("ddlP").options[$("ddlP").selectedIndex].text == '-请选择-')
    {
        tP = "";
    }
    else
    {
        tP = $("ddlP").options[$("ddlP").selectedIndex].text;
    }
    if($("ddlC").options[$("ddlC").selectedIndex].text == '-请选择-')
    {
        tC = "";
    }
    else
    {
        tC = $("ddlC").options[$("ddlC").selectedIndex].text;
    }
    GetNowAgora(tP,tC);
    $("hidfldArid").value = "";
} 

function GetNowAgora(tP,tC)
{
    var ddlAgora = document.getElementById("ddlAllAgora");
    var AllAgora = bounbary_Product_ProductList.bindNowAgora(tP,tC).value;
    if(AllAgora != null && typeof(AllAgora) == "object")
    {
        ddlAgora.length = 0;
		ddlAgora.options.add(new Option("-请选择-",""));
        for(var i=0; i< AllAgora.Rows.length; i++)
	    {
		    var txt = AllAgora.Rows[i].arName; //这个地方需要注意区分大小写
		    var vol = AllAgora.Rows[i].arid; //跟dataset表的列名称要一致
		    ddlAgora.options.add(new Option(txt,vol));
	    }
    }
}

function ShowPlaces(tP,tC,tGetP,tGetC)
{
    if(document.getElementById("hidfldArid").value != "" && document.getElementById("hidfldArid").value != null)
    {
        var tPlace = bounbary_Product_ProductList.bindNowPlace(document.getElementById("hidfldArid").value).value;
        if(tPlace != null && typeof(tPlace) == "object" && tPlace.Rows.length >0)
        {
            $(tGetP).value = tPlace.Rows[0].arProvince;
            $(tGetC).value = tPlace.Rows[0].arCity;
        }
    }
    if($(tGetP).value != "")
    {
        var tTableP = bounbary_Product_ProductList.GetNowPlaces($(tGetP).value).value;
        if(tTableP != "" && tTableP != null && typeof(tTableP) == "object" && tTableP.Rows.length > 0)
        {
            $(tP).value = tTableP.Rows[0].code;
            var tTableC = bounbary_Product_ProductList.GetNextPlace(tTableP.Rows[0].code).value;
            if(tTableC != "" && tTableC != null && typeof(tTableC) == "object" && tTableC.Rows.length > 0)
            {
                $(tC).length = 0;
                $(tC).options.add(new Option("-请选择-",""));
                for(var i = 0;i < tTableC.Rows.length;i++)
                {
                    
                    var txt = tTableC.Rows[i].codeName;
                    var val = tTableC.Rows[i].code;
                    $(tC).options.add(new Option(txt,val));
                }
                if($(tGetC).value != "")
                {
                    var tCid = bounbary_Product_ProductList.GetNowPlaces2($(tGetC).value,tTableP.Rows[0].code).value;
                    if(tCid != "" && tCid != null && typeof(tCid) == "object" && tCid.Rows.length > 0)
                    {
                        $(tC).value = tCid.Rows[0].code;
                    }
                }
            }
        }
        
        var tNowP = null;
        var tNowC = null;
        if($("ddlP").options[$("ddlP").selectedIndex].text == '-请选择-')
        {
            tNowP = "";
        }
        else
        {
            tNowP = $("ddlP").options[$("ddlP").selectedIndex].text;
        }
        if($("ddlC").options[$("ddlC").selectedIndex].text == '-请选择-')
        {
            tNowC = "";
        }
        else
        {
            tNowC = $("ddlC").options[$("ddlC").selectedIndex].text;
        }
        GetNowAgora(tNowP,tNowC);
        if($("hidfldArid").value != "" && $("hidfldArid").value != null)
        {
            $("ddlAllAgora").value = $("hidfldArid").value;
        }
    }
} 

function GetNowArid()
{
    document.getElementById("hidfldArid").value = document.getElementById("ddlAllAgora").value
}
 
