コード例 #1
0
ファイル: Item_View.cs プロジェクト: kamchung322/Namwah
        private void btnCopyRoute_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            string sourceItemNo = Microsoft.VisualBasic.Interaction.InputBox("请输入要复制的产品编码.  \n注意, 只会复制有差别的Bom及流程资料!!!", "输入来源产品", "", 0, 0);

            if (sourceItemNo == "")
                return;

            UnitOfWork uow = (UnitOfWork)((XPObjectSpace)View.ObjectSpace).Session;

            Item sourceItem = Item.FindItem(uow, sourceItemNo);

            if (sourceItem == null)
            {
                XtraMessageBox.Show(string.Format("找不到此产品{0}资料", sourceItemNo));
                return;
            }

            Item item = (Item)View.CurrentObject;
            Dictionary<string, string> dictItem = new Dictionary<string, string>();

            for (int i = 0; i < item.BomLines.Count; i++)
            {
                if (dictItem.ContainsKey(item.BomLines[i].BomItem.ItemNo) == false)
                    dictItem.Add(item.BomLines[i].BomItem.ItemNo, item.BomLines[i].BomItem.ItemNo);

                //item.BomLines[i].Delete();
                //i--;
            }

            foreach (BomLine bLine in sourceItem.BomLines)
            {
                if (dictItem.ContainsKey(bLine.BomItem.ItemNo) == false)
                {
                    BomLine newBom = new BomLine(item.Session);
                    newBom.BomItem = bLine.BomItem;
                    newBom.ConstantScrap = bLine.ConstantScrap;
                    newBom.Item = item;
                    newBom.LineType = bLine.LineType;
                    newBom.PerSeries = bLine.PerSeries;
                    newBom.Qty = bLine.Qty;
                    newBom.Unit = bLine.Unit;
                    newBom.VariableScrap = bLine.VariableScrap;
                    newBom.Warehouse = bLine.Warehouse;
                    newBom.Save();
                }
            }

            Dictionary<int, int> dictRoute = new Dictionary<int, int>();

            for (int i = 0; i < item.RouteLines.Count; i++)
            {
                if (dictRoute.ContainsKey(item.RouteLines[i].OperNo) == false)
                    dictRoute.Add(item.RouteLines[i].OperNo, item.RouteLines[i].OperNo);
            }

            foreach (RouteLine rLine in sourceItem.RouteLines)
            {
                if (dictRoute.ContainsKey(rLine.OperNo) == false)
                {
                    RouteLine newLine = new RouteLine(item.Session);
                    newLine.Item = item;
                    newLine.OperNo = rLine.OperNo;
                    newLine.NextOperNo = rLine.NextOperNo;
                    newLine.ProcessQty = rLine.ProcessQty;
                    newLine.QtyofWorkCenter = rLine.QtyofWorkCenter;
                    newLine.RunTime = rLine.RunTime;
                    newLine.SetupTime = rLine.SetupTime;
                    newLine.wipItem = rLine.wipItem;
                    newLine.WorkCenter = rLine.WorkCenter;
                    newLine.WorkDesc = rLine.WorkDesc;
                    newLine.WorkOper = rLine.WorkOper;
                    newLine.Save();
                }
            }

            XtraMessageBox.Show("已完成覆制BOM及流程, 请你检查清楚 !!");
        }
コード例 #2
0
        private RouteLine CreateRouteLine(Item item, int OperNo, int NextOperNo, 
                string WorkOperNo, string WorkCenterNo, string SubContractor, string SubConDesc, UnitOfWork uow)
        {
            RouteLine rLine = new RouteLine(uow);

            rLine.Item = item;
            rLine.OperNo = OperNo;
            rLine.ProcessQty = 1;
            rLine.QtyofWorkCenter = 1;
            rLine.RunTime = 0;
            rLine.SetupTime = 0;
            rLine.WorkOper = WorkOper.Find(uow, WorkOperNo);

            if (WorkOperNo == "N" || WorkOperNo == "J" || WorkOperNo == "W")
                WorkCenterNo = "F";

            if (WorkOperNo == "C" || WorkOperNo == "L" || WorkOperNo == "M")
                WorkCenterNo = "P";

            if (WorkCenterNo == "T")
                WorkCenterNo = "Y";

            if (SubContractor != "")
                rLine.WorkCenter = WorkCenter.Find(uow, SubContractor);
            else
                rLine.WorkCenter = WorkCenter.Find(uow, WorkCenterNo);

            if (rLine.WorkCenter.Type == WorkCenter.WorkCenterType.Vendor)
                rLine.WorkDesc = SubConDesc;

            rLine.NextOperNo = NextOperNo;
            rLine.Save();

            return rLine;
        }