Ejemplo n.º 1
0
    //检查零件是否存在
    private bool CheckItemExists(IList <FlowDetail> flowDetailList)
    {
        int              newRowId    = flowDetailList != null ? flowDetailList.Count - 1 : 0;
        GridViewRow      newRow      = this.GV_List.Rows[newRowId];
        Controls_TextBox tbItemCode  = (Controls_TextBox)newRow.FindControl("tbItemCode");
        Controls_TextBox tbUom       = (Controls_TextBox)newRow.FindControl("tbUom");
        TextBox          tbUnitCount = (TextBox)newRow.FindControl("tbUnitCount");

        if (flowDetailList != null)
        {
            Flow         flow     = flowDetailList[0].Flow;
            IList <Item> itemList = new List <Item>();
            Item         item     = this.TheItemMgr.LoadItem(tbItemCode.Text.Trim());
            item.Uom       = this.TheUomMgr.LoadUom(tbUom.Text.Trim());
            item.UnitCount = decimal.Parse(tbUnitCount.Text.Trim());
            if (item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
            {
                IList <ItemKit> itemKitList = TheItemKitMgr.GetChildItemKit(item);

                if (itemKitList != null && itemKitList.Count > 0)
                {
                    foreach (ItemKit itemKit in itemKitList)
                    {
                        itemList.Add(itemKit.ChildItem);
                    }
                }
                else
                {
                    ShowErrorMessage("ItemKit.Error.NotFoundForParentItem", item.Code);
                    return(true);
                }
            }
            else
            {
                itemList.Add(item);
            }

            for (int i = 0; i < flowDetailList.Count - 1; i++)
            {
                foreach (Item checkItem in itemList)
                {
                    string oLocFrom = flow.LocationFrom == null ? null : flow.LocationFrom.Code;
                    string oLocTo   = flow.LocationTo == null ? null : flow.LocationTo.Code;
                    string dLocFrom = flowDetailList[i].DefaultLocationFrom == null ? null : flowDetailList[i].DefaultLocationFrom.Code;
                    string dLocTo   = flowDetailList[i].DefaultLocationTo == null ? null : flowDetailList[i].DefaultLocationTo.Code;

                    if (flowDetailList[i].Item.Code == checkItem.Code &&
                        flowDetailList[i].Item.Uom.Code == checkItem.Uom.Code &&
                        oLocFrom == dLocFrom && oLocTo == dLocTo &&
                        flowDetailList[i].UnitCount == checkItem.UnitCount)
                    {
                        if (checkItem.Code == item.Code &&
                            item.Uom.Code == checkItem.Uom.Code &&
                            oLocFrom == dLocFrom && oLocTo == dLocTo &&
                            checkItem.UnitCount == item.UnitCount)
                        {
                            ShowErrorMessage("MasterData.Order.OrderDetail.ItemCode.Exists");
                        }
                        else
                        {
                            ShowErrorMessage("MasterData.Order.OrderDetail.ItemCode.Exists2", item.Code);
                        }
                        return(true);
                    }
                }
            }
        }
        return(false);
    }