Ejemplo n.º 1
0
        private BomLine CreateBomLine(Item item, Item bomItem, UnitOfWork uow, int Qty)
        {
            BomLine bLine = new BomLine(uow);
            bLine.Item = item;
            bLine.BomItem = bomItem;
            bLine.ConstantScrap = 0;
            bLine.LineType = bomItem.Source;
            bLine.PerSeries = 1;
            bLine.Qty = Qty;
            bLine.Unit = bomItem.Unit;
            bLine.VariableScrap = 0;
            bLine.Warehouse = bomItem.Warehouse;
            bLine.Save();

            return bLine;
        }
Ejemplo n.º 2
0
        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及流程, 请你检查清楚 !!");
        }
Ejemplo n.º 3
0
        public void ImportPartBom()
        {
            string partPath = "http://nwszmail/public/namwah/Parts2/Parts/";
            string strSQL = "";

            ADODB.Connection cnn = new ADODB.Connection();
            ADODB.Recordset rst = new ADODB.Recordset();
            //Item item;

            session.BeginTransaction();
            XPCollection<BomLine> bLines = new XPCollection<BomLine>(session);
            session.Delete(bLines);
            session.Save(bLines);
            session.CommitTransaction();
            Part part;
            Dictionary<string, Part> dictPart = new Dictionary<string, Part>();

            CacheItem();

            ConnectDB(cnn, partPath);

            strSQL = "SELECT \"nw:partno\", \"nw:material\", \"nw:part:tmxrefno\", \"nw:rout1:resoption\", \"nw:rout1:resourceno\",  \"nw:rout1:type\", ";
            strSQL = strSQL + " \"nw:bom:list:partno\", \"nw:bom:list:qty\" ";
            strSQL = strSQL + " FROM \"" + partPath ;
            strSQL = strSQL + "\" WHERE (\"DAV:ishidden\" = false)";

            rst.Open(strSQL, cnn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockBatchOptimistic, 1);

            while (!rst.EOF)
            {
                part = new Part();
                part.partNo = rst.Fields["nw:partno"].Value.ToString();
                part.bomNo = rst.Fields["nw:bom:list:partno"].Value.ToString();
                part.bomQty = rst.Fields["nw:bom:list:qty"].Value.ToString();
                part.resOption = bool.Parse(rst.Fields["nw:rout1:resoption"].Value.ToString());
                part.resourceNo = rst.Fields["nw:rout1:resourceno"].Value.ToString();
                part.routType = rst.Fields["nw:rout1:type"].Value.ToString();

                if (dictPart.ContainsKey(part.partNo) == false)
                    dictPart.Add(part.partNo, part);

                rst.MoveNext();
            }

            session.BeginTransaction();

            foreach (Item item in dictItem.Values )
            {
                //int rout = 0;
                if (dictPart.ContainsKey(item.ItemNo))
                {
                    part = dictPart[item.ItemNo];

                    //                    if (item.ItemNo.EndsWith("P01"))
                    //                      System.Diagnostics.Debug.WriteLine(item.ItemNo);

                    bool resOption;
                    do
                    {
                        resOption = part.resOption;
                        if (part.resOption && part.bomNo == "")
                        {
                            // Insert Route;

                            if (dictPart.ContainsKey(part.resourceNo))
                                part = dictPart[part.resourceNo];
                            else
                                break;
                        }
                        else
                        {
                            // Insert BOM;
                            resOption = false;

                            if (part.resourceNo == "bom" && part.bomNo != "")
                            {
                                string[] bPartNo = Regex.Split(part.bomNo, ",");
                                string[] bQty = Regex.Split(part.bomQty, ",");
                                int i = 0;
                                foreach (string bNo in bPartNo)
                                {
                                    if (dictItem.ContainsKey(bNo))
                                    {
                                        BomLine bomLine = new BomLine(session);
                                        bomLine.BomItem = dictItem[bNo];
                                        bomLine.Item = item; //dictItem[item.ItemNo];
                                        bomLine.PerSeries = 1;
                                        int b;
                                        if (int.TryParse(bQty[i], out b))
                                            bomLine.Qty = int.Parse(bQty[i]);
                                        else
                                            bomLine.Qty = 1;

                                        bomLine.Save();
                                    }
                                    else
                                    {
                                        System.Diagnostics.Debug.Write(bNo);
                                    }
                                    i++;
                                }
                                item.Save();
                            }
                            else
                                if (part.resourceNo != "" && part.resourceNo != "bom" && dictItem.ContainsKey(part.resourceNo))
                                {
                                    BomLine bomLine = new BomLine(session);
                                    bomLine.BomItem = dictItem[part.resourceNo];
                                    bomLine.Item = item; //dictItem[part.partNo];
                                    bomLine.PerSeries = 1;
                                    bomLine.Qty = 1;
                                    bomLine.Save();
                                    item.Save();
                                }
                        }
                    }
                    while (resOption);
                }
            }

            session.CommitTransaction();
        }