读书人

方法中 再用此方法,该怎么解决

发布时间: 2012-04-11 17:42:33 作者: rapoo

方法中 再用此方法

C# code
        [AjaxMethod]        public string GetGetCustInfo(string custCode)        {            DataTable dt = CustomerBLL.CreateInstance().CustomerList(" WHERE CustomerID='" + custCode + "' ", 1, 100);            string strTopFatherCode = "", strTopFatherName = "", strLevelCode = "", strTopFatherID="";            if (dt.Rows.Count > 0)            {                if (string.IsNullOrEmpty(dt.Rows[0]["TopFatherID"].ToString()))                {                    strTopFatherCode = dt.Rows[0]["CustomerCode"].ToString();                    strTopFatherName = dt.Rows[0]["CustomerName"].ToString();                    strTopFatherID = dt.Rows[0]["CustomerID"].ToString();                    strLevelCode = (Convert.ToInt16(dt.Rows[0]["LevelCode"]) + 1).ToString();                }                else                {                    // 如果 TopFatherID 不为空  再走一次这个方法  该如何写                                    }                                return strTopFatherCode + "|" + strTopFatherName + "|" + strLevelCode + "|" + dt.Rows[0]["CustomerCode"].ToString() + "|" + strTopFatherID;            }            else            {                return "";            }        }


[解决办法]
你啥问题???
[解决办法]
就是个递归啊,以TopFatherID 为条件退出即可,不过TopFatherID最好作为全局或者参数,不要是局部变量
[解决办法]
探讨
就是个递归啊,以TopFatherID 为条件退出即可,不过TopFatherID最好作为全局或者参数,不要是局部变量

[解决办法]
[AjaxMethod]
public string state="0";
public string GetGetCustInfo(string custCode)
{
DataTable dt = CustomerBLL.CreateInstance().CustomerList(" WHERE CustomerID='" + custCode + "' ", 1, 100);

string strTopFatherCode = "", strTopFatherName = "", strLevelCode = "", strTopFatherID="";
if (dt.Rows.Count > 0)
{
if (string.IsNullOrEmpty(dt.Rows[0]["TopFatherID"].ToString()))
{
strTopFatherCode = dt.Rows[0]["CustomerCode"].ToString();
strTopFatherName = dt.Rows[0]["CustomerName"].ToString();
strTopFatherID = dt.Rows[0]["CustomerID"].ToString();
strLevelCode = (Convert.ToInt16(dt.Rows[0]["LevelCode"]) + 1).ToString();
}
else
{
if(state=="0"){GetGetCustInfo(custCode);state="1"};
else return "";
}


return strTopFatherCode + "|" + strTopFatherName + "|" + strLevelCode + "|" + dt.Rows[0]["CustomerCode"].ToString() + "|" + strTopFatherID;
}
else
{
return "";
}
}

读书人网 >C#

热点推荐