zoukankan      html  css  js  c++  java
  • 递归的实际应用

    IList<CBF.Model.BOMDisplay> list = new List<CBF.Model.BOMDisplay>();

    protected override bool CallRead()
    {
    CBF.Model.BOM bom = this.Operation.GetBOMById(CHelper.GetQueryString(CString.ID).ToInt());

    if (!bom.Id.IsNull())
    {
    list.Add(this.Operation.BOMToBOMDisplay(bom, list, 0));

    //this.Operation.AddEq("ParentId", bom.Id.ToString());
    IList<CBF.Model.BOM> boms = this.Operation.GetRootBOM(bom.Id.ToString());

    this.Operation.ShowBOM(boms, list, 1);

    treeList.DataSource = list;
    treeList.DataBind();
    //ExtAspNet.TreeNode node = new ExtAspNet.TreeNode();
    //node.Text = bom.ItemNO;
    //tr_BOM.Nodes.Add(node);
    //ShowBOM(bom, node.Nodes);
    }

    ;

    return base.InitPage();
    }

    public void ShowBOM(IList<CBF.Model.BOM> boms, IList<CBF.Model.BOMDisplay> listBoms,int parentId)
    {
    foreach (var b in boms)
    {
    BOMDisplay bOMToBOMDisplay = BOMToBOMDisplay(b, listBoms,parentId);
    listBoms.Add(bOMToBOMDisplay);

    //ICriteria criteria = this._session.CreateCriteria(typeof(CBF.Model.BOM));

    //criteria.Add(Expression.In("ParentId", new List<string>() { b.Id.ToString() }));
    string strSQL = string.Format(@"if exists(select * from mes_bom where parentid ='{0}')
    begin
    select * from mes_bom where parentid ='{1}'
    end
    else if exists(select * from MES_BOM where ItemNO = '{2}' and ParentID = 0)
    begin
    select * from MES_BOM where ParentID in(select ID from MES_BOM where ItemNO = '{3}' and ParentID = 0)
    end
    else
    select * from mes_bom where parentid ='{4}'

    ", b.Id, b.Id, b.ItemNO, b.ItemNO,b.Id);

    IList<CBF.Model.BOM> iboms = _session.CreateSQLQuery(strSQL).AddEntity(typeof(BOM)).List<BOM>();

    if (iboms.Count > 0)
    {
    ShowBOM(iboms, listBoms, bOMToBOMDisplay.IId);
    }

    }
    }

    public BOMDisplay BOMToBOMDisplay(BOM bom, IList<BOMDisplay> boms,int parentId)
    {
    BOMDisplay bomDis = new BOMDisplay();
    bomDis.IId = boms.Count + 1;
    bomDis.Id = bom.Id;
    bomDis.ItemNO = bom.ItemNO;
    bomDis.ItemName = bom.ItemName;
    bomDis.Unit = bom.Unit;
    bomDis.Qty = bom.Qty;
    bomDis.Yield = bom.Yield;
    bomDis.Scrap = bom.Scrap;
    bomDis.ParentId = parentId;

    return bomDis;
    }

  • 相关阅读:
    网络芯片应用:GPS公交车行驶记录仪
    “黑暗潜伏者” -- 手机病毒新型攻击方式
    Android导入工程提示Invalid project description
    设计模式_代理模式
    el简略说明与11个隐含对象
    jsp九大内置对象
    js全局函数
    python基础:multiprocessing的使用
    pgAdmin III 使用图解
    windows下简单安装postgres
  • 原文地址:https://www.cnblogs.com/chengjun/p/5378604.html
Copyright © 2011-2022 走看看