public long getClassIDByPartId(long partId)
{
DBConnect dbCon = new DBConnect(this);
long iClassId, iProductId, iPartId, iParentPartId;
string dsSql = "Select NodeID,ParentNodeID,Class,OrderIndex,PartId from DM_ProductTree order by Class Desc,ParentNodeID,OrderIndex;
DataSet ds = dbCon.getDataSet(dsSql);
return getClassIDByNodeID(ds, 0, partId);
}
private long getClassIDByNodeID(DataSet ds, int fromNo, long varNodeID)
{
return getIDByNodeID(ds, fromNo, varNodeID, 0);
}
private long getProductIDByNodeID(DataSet ds, int fromNo, long varNodeID)
{
return getIDByNodeID(ds, fromNo, varNodeID, 1);
}
private long getIDByNodeID(DataSet ds, int fromNo, long varNodeID, int iFlg)
{
DataRow dr;
for (i = fromNo; i < ds.Tables["tree"].Rows.Count; i++)
{
dr=dst.Tables["tree"].Rows[i];
iNodeId = Convert.ToInt32(dr["NodeID"]);
if (iNodeId == varNodeID){
iClass = Convert.ToInt32(dr["Class"]);
iParentNodeID = Convert.ToInt64(dr["ParentNodeID"]);
if (iClass == iFlg + 1)
{
return iParentNodeID;
}else{
return getClassIDByNodeID(ds, i, iParentNodeID);
}
}
}
}
阅读(2446) | 评论(0) | 转发(0) |