示例#1
0
        public WIPItemNeed(Session session, WIPItemNeed wipItemNeed, BomLine bLine)
            : base(session)
        {
            ParentItemNeed = wipItemNeed;
            WIPTable = wipItemNeed.WIPTable;
            SalesOrderLine = wipItemNeed.SalesOrderLine;
            Item = bLine.BomItem;
            ItemSource = bLine.LineType;
            Level = wipItemNeed.Level + 1;

            if (SalesOrderLine.SaleOrderLine.OrderType.WareHouse != null)
                WareHouse = SalesOrderLine.SaleOrderLine.OrderType.WareHouse;
            else
                WareHouse = bLine.Warehouse;

            VariableScrap = bLine.VariableScrap;
            ConstantScrap = bLine.ConstantScrap;
            Qty = bLine.Qty;
            PerSeries = bLine.PerSeries;
            NeedQty = wipItemNeed.LackQty;
            NeedDate = wipItemNeed.NeedDate.AddDays(-1);
            CheckOrderTypeScrap();
            calcSubItemNeedQty();

            SetSortKey();

            WIPItemNeed childItemNeed = this;

            if (ItemSource == Item.ItemSource.Make)
            {
                RouteLine rLine = Item.GetLastRouteLine();

                if (rLine != null)
                {
                    RouteLine = CWIPRouteLine(rLine);

                    RouteLine PreviousRLine = rLine.GetPreviousRoute();

                    if (PreviousRLine != null)
                    {
                        WIPItemNeed childWipItemNeed = new WIPItemNeed(Session, this, PreviousRLine, ref childItemNeed);
                        childWipItemNeed.Save();
                    }
                    else
                    {
                        IsCheckWH = true;
                    }
                }

                InitBomItemNeed(childItemNeed);
            }
            else
            {
                IsCheckWH = true;
            }
        }
示例#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及流程, 请你检查清楚 !!");
        }
示例#3
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;
        }
示例#4
0
        private void btnItemBom_Click(object sender, EventArgs e)
        {
            if (InitExcel("Item-BOM") == false)
                return;

            UnitOfWork uow = new UnitOfWork();
            BomLine bomLine;

            int row = 3;
            uow.BeginTransaction();

            while (ExcelHelper.GetCellStringValue(xlSht, row, 1) != "")
            {
                bomLine = uow.FindObject<BomLine>(CriteriaOperator.Parse(string.Format("Item.ItemNo = '{0}' AND BomItem.ItemNo = '{1}'",
                        ExcelHelper.GetCellStringValue(xlSht, row, 1), ExcelHelper.GetCellStringValue(xlSht, row, 2))));

                if (bomLine != null && ItemExist.SelectedIndex == 0 || bomLine == null)
                {
                    if (bomLine == null)
                        bomLine = new BomLine(uow);

                    bomLine.Item = Item.FindItem(uow, ExcelHelper.GetCellStringValue(xlSht, row, 1));
                    bomLine.BomItem = Item.FindItem(uow, ExcelHelper.GetCellStringValue(xlSht, row, 2));

                    if (ExcelHelper.GetCellStringValue(xlSht, row, 3) == "Buy")
                        bomLine.LineType = Item.ItemSource.Buy;
                    else
                        bomLine.LineType = Item.ItemSource.Make;

                    bomLine.Qty = ExcelHelper.GetCellIntValue(xlSht, row, 4);
                    bomLine.PerSeries = ExcelHelper.GetCellIntValue(xlSht, row, 5);
                    bomLine.Unit = uow.FindObject<Unit>(new BinaryOperator("UnitName", ExcelHelper.GetCellStringValue(xlSht, row, 6)));
                    bomLine.ConstantScrap = ExcelHelper.GetCellIntValue(xlSht, row, 7);
                    bomLine.VariableScrap = ExcelHelper.GetCellIntValue(xlSht, row, 8);
                    bomLine.Warehouse = uow.FindObject<WareHouse>(new BinaryOperator("WarehouseName", ExcelHelper.GetCellStringValue(xlSht, row, 9)));
                    bomLine.Save();
                }
                row++;
            }
            uow.CommitTransaction();
            ReleaseExcel();
        }
示例#5
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();
        }
示例#6
0
        private void ListBomLineToSheet(BomLine BLine, Worksheet ShtBomDetail)
        {
            string Key = string.Format("{0}_{1}", BLine.Item.ItemNo, BLine.BomItem.ItemNo);

            if (DictListedBomItem.ContainsKey(Key))
                return;

            DictListedBomItem.Add(Key, Key);
            RowNo++;
            ShtBomDetail.Cells[RowNo, COL_ITEMNO].Value = BLine.Item.ItemNo ;
            ShtBomDetail.Cells[RowNo, COL_ITEMNAME].Value = BLine.Item.ItemName;
            ShtBomDetail.Cells[RowNo, COL_ITEMTYPE].Value = BLine.Item.ItemType.ItemTypeName;
            ShtBomDetail.Cells[RowNo, COL_BOMNO].Value = BLine.BomItem.ItemNo;
            ShtBomDetail.Cells[RowNo, COL_BOMNAME].Value = BLine.BomItem.ItemName;
            ShtBomDetail.Cells[RowNo, COL_BOMTYPE].Value = BLine.BomItem.ItemType.ItemTypeName;
            ShtBomDetail.Cells[RowNo, COL_LINETYPE].Value = BLine.LineType.ToString();
            ShtBomDetail.Cells[RowNo, COL_PERSERIES].Value = BLine.PerSeries;
            ShtBomDetail.Cells[RowNo, COL_QTY].Value = BLine.Qty;
            ShtBomDetail.Cells[RowNo, COL_ALLITEMNO].Value = BLine.BomItem.AllItemNo;

            if (BLine.LineType == Item.ItemSource.Buy)
            {
                if (BLine.BomItem.MainVendor != null)
                    ShtBomDetail.Cells[RowNo, COL_SUPPLIER].Value = BLine.BomItem.MainVendor.No;

                ShtBomDetail.Cells[RowNo, COL_PURCHCOST].Value = Math.Round(BLine.BomItem.PurchCost, 3);
                ShtBomDetail.Cells[RowNo, COL_FINALCOST].Value =
                    Math.Round((BLine.BomItem.PurchCost ) * BLine.Qty / BLine.PerSeries, 3);
            }
            else
            {
                ShtBomDetail.Cells[RowNo, COL_BOMCOST].Value = Math.Round(BLine.BomItem.BomCost, 3);
                ShtBomDetail.Cells[RowNo, COL_FINALCOST].Value =
                    Math.Round((BLine.BomItem.BomCost) * BLine.Qty / BLine.PerSeries, 3);

                foreach (BomLine Line in BLine.BomItem.BomLines)
                {
                    ListBomLineToSheet(Line, ShtBomDetail);
                }
            }
        }