Ejemplo n.º 1
0
        public WIPItemNeed(Session session, WIPItemNeed wipItemNeed, RouteLine rLine, ref WIPItemNeed childItemNeed)
            : base(session)
        {
            ParentItemNeed = wipItemNeed;
            WIPTable = wipItemNeed.WIPTable;
            SalesOrderLine = wipItemNeed.SalesOrderLine;
            //Item = rLine.wipItem;
            Item = wipItemNeed.Item;
            ItemSource = wipItemNeed.ItemSource;
            Level = wipItemNeed.Level;
            SubLevel = wipItemNeed.SubLevel + 1;
            IsEnableCalcQty = true;

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

            //  TODO: calc the needDate & needQty
            NeedDate = wipItemNeed.NeedDate.AddDays(-1);
            NeedQty = wipItemNeed.LackQty;
            calcSubItemNeedQty();
            RouteLine = CWIPRouteLine(rLine);
            SetSortKey();
            CheckOrderTypeScrap();

            RouteLine PreviousRLine = rLine.GetPreviousRoute();

            if (PreviousRLine != null)
            {
                WIPItemNeed childWipItemNeed = new WIPItemNeed(Session, this, PreviousRLine, ref childItemNeed);
                childWipItemNeed.Save();
            }
            else
            {
                IsCheckWH = true;
                childItemNeed = this;
            }
        }
Ejemplo n.º 2
0
        private WIPRouteLine CWIPRouteLine(RouteLine rLine)
        {
            WIPRouteLine wipRouteLine = rLine.Session.FindObject<WIPRouteLine>(CriteriaOperator.Parse(string.Format("Item.Oid = '{0}' AND OperNo = {1}",
                rLine.Item.Oid, rLine.OperNo)));

            if (wipRouteLine == null)
            {
                wipRouteLine = new WIPRouteLine(rLine.Session);
                wipRouteLine.Item = rLine.Item;
                wipRouteLine.OperNo = rLine.OperNo;
                wipRouteLine.NextOperNo = rLine.NextOperNo;
                wipRouteLine.ProcessQty = rLine.ProcessQty;
                wipRouteLine.QtyofWorkCenter = rLine.QtyofWorkCenter;
                wipRouteLine.RunTime = rLine.RunTime;
                wipRouteLine.SetupTime = rLine.SetupTime;
                wipRouteLine.wipItem = rLine.wipItem;
                wipRouteLine.WorkCenter = rLine.WorkCenter;
                wipRouteLine.WorkDesc = rLine.WorkDesc;
                wipRouteLine.WorkOper = rLine.WorkOper;
                wipRouteLine.Save();
            }
            else
            {
                wipRouteLine.NextOperNo = rLine.NextOperNo;
                wipRouteLine.ProcessQty = rLine.ProcessQty;
                wipRouteLine.QtyofWorkCenter = rLine.QtyofWorkCenter;
                wipRouteLine.RunTime = rLine.RunTime;
                wipRouteLine.SetupTime = rLine.SetupTime;
                wipRouteLine.wipItem = rLine.wipItem;
                wipRouteLine.WorkCenter = rLine.WorkCenter;
                wipRouteLine.WorkDesc = rLine.WorkDesc;
                wipRouteLine.WorkOper = rLine.WorkOper;
                wipRouteLine.Save();
            }

            return wipRouteLine;
        }
Ejemplo n.º 3
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.º 4
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;
        }
Ejemplo n.º 5
0
        private void btnItemRoute_Click(object sender, EventArgs e)
        {
            if (InitExcel("Item-Route") == false)
                return;

            UnitOfWork uow = new UnitOfWork();
            RouteLine routeLine;
            int row = 3;
            uow.BeginTransaction();

            while (ExcelHelper.GetCellStringValue(xlSht, row, 1) != "")
            {
                Item item = Item.FindItem(uow, ExcelHelper.GetCellStringValue(xlSht, row, 1));
                routeLine = uow.FindObject<RouteLine>(CriteriaOperator.Parse(string.Format("Item.ItemNo = '{0}' AND OperNo = {1}",
                    ExcelHelper.GetCellStringValue(xlSht, row, 1), ExcelHelper.GetCellStringValue(xlSht, row, 2))));

                if (routeLine != null && ItemExist.SelectedIndex == 0 || routeLine == null)
                {
                    if (routeLine == null)  // 0  = overwrite
                        routeLine = new RouteLine(uow);

                    routeLine.Item = item;
                    routeLine.OperNo = ExcelHelper.GetCellIntValue(xlSht, row, 2);

                    if (ExcelHelper.GetCellStringValue(xlSht, row, 3) != "")
                        routeLine.NextOperNo = ExcelHelper.GetCellIntValue(xlSht, row, 3);

                    routeLine.WorkCenter = uow.FindObject<WorkCenter>(new BinaryOperator("WorkCenterNo", ExcelHelper.GetCellStringValue(xlSht, row, 4)));
                    routeLine.WorkOper = uow.FindObject<WorkOper>(new BinaryOperator("Name", ExcelHelper.GetCellStringValue(xlSht, row, 5)));
                    routeLine.WorkDesc = ExcelHelper.GetCellStringValue(xlSht, row, 6);

                    if (ExcelHelper.GetCellStringValue(xlSht, row, 7) != "")
                        routeLine.wipItem = Item.FindItem(uow, ExcelHelper.GetCellStringValue(xlSht, row, 7));

                    routeLine.Save();
                    item.Source = Item.ItemSource.Make;
                    item.Save();
                }
                row++;
            }
            uow.CommitTransaction();
            ReleaseExcel();
        }
Ejemplo n.º 6
0
        public bool UpdatePromisedDate(Item item , RouteLine rLine, string PromisedDateList)
        {
            try
            {
                float tShipQty = ShipQty ;
                SalesOrderPromisedDates.Sorting.Add(new SortProperty("PromisedDate", SortingDirection.Ascending));

                for (int i = 0; i < SalesOrderPromisedDates.Count; i++)
                {
                    SalesOrderPromisedDate promisedDate = SalesOrderPromisedDates[i];

                    if (promisedDate.Item == item && promisedDate.RouteLine == rLine)
                    {
                        if (tShipQty > promisedDate.Qty)
                        {
                            tShipQty = tShipQty - promisedDate.Qty;
                        }
                        else
                            if (tShipQty == 0)
                            {
                                promisedDate.Delete();
                            }
                            else
                            {
                                promisedDate.Qty = tShipQty;
                                promisedDate.Save();
                                tShipQty = 0;
                            }
                    }
                }

                if (tShipQty > 0)
                {
                    SalesOrderPromisedDate promisedDate = new SalesOrderPromisedDate(Session);
                    promisedDate.SalesOrderLine = this;
                    promisedDate.Item = item;
                    promisedDate.RouteLine = rLine;
                    promisedDate.PromisedDate = NeedDate;
                    promisedDate.Qty = tShipQty;
                    promisedDate.Save();
                }

                float tBalQty = BalQty ;

                PromisedDateList = PromisedDateList.Trim();

                if (tBalQty > 0)
                {
                    DateTime dt;

                    if (DateTime.TryParseExact(PromisedDateList, "yyyy-M-d", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt))
                    {
                        // PromisedDateList is Date
                        SalesOrderPromisedDate promisedDate = new SalesOrderPromisedDate(Session);
                        promisedDate.SalesOrderLine = this;
                        promisedDate.Item = item;
                        promisedDate.RouteLine = rLine;
                        promisedDate.PromisedDate = dt;
                        promisedDate.Qty = tBalQty;
                        promisedDate.Save();
                    }
                    else
                    {
                        SortedDictionary<DateTime, float> dictList = new SortedDictionary<DateTime, float>(new IDateTimeDecreaseComparer());

                        UDFunction.ConvertStringToPromisedDate(PromisedDateList, dictList);

                        // 2011-3-30 (1000), 2011-4-1 (100)

                        foreach (KeyValuePair<DateTime, float> kvp in dictList)
                        {
                            DateTime pDate = (DateTime)kvp.Key;
                            float pQty = (float)kvp.Value;

                            if (pQty > 0 && tBalQty > 0)
                            {
                                SalesOrderPromisedDate promisedDate = new SalesOrderPromisedDate(Session);
                                promisedDate.SalesOrderLine = this;
                                promisedDate.Item = item;
                                promisedDate.RouteLine = rLine;
                                promisedDate.PromisedDate = pDate;

                                if (tBalQty > pQty)
                                {
                                    promisedDate.Qty = pQty;
                                    promisedDate.Save();
                                    tBalQty = tBalQty - pQty;
                                }
                                else
                                {
                                    promisedDate.Qty = tBalQty;
                                    promisedDate.Save();
                                    tBalQty = 0;
                                }
                            }
                        }
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                //throw new Exception(string.Format("采购单号{0}不能发单, 因为入仓数大于采购单欠数", PurchOrderLine.PurchOrderNo));
                throw new Exception(string.Format("销售单号{0}不能更新覆期, 原因 : {1}", OrderLineIndex, ex.Message));

                return false;
            }
        }
Ejemplo n.º 7
0
        private void CWIPRouteLine(RouteLine rLine)
        {
            WIPRouteLine wipRouteLine = rLine.Session.FindObject<WIPRouteLine>(CriteriaOperator.Parse(string.Format("Item.Oid = '{0}' AND OperNo = {1}",
                rLine.Item.Oid, rLine.OperNo)));

            string key = rLine.Item.ItemNo + "_" + rLine.OperNo;

            if (wipRouteLine == null)
            {
                if (dictWIPRouteLine.ContainsKey(key))
                    wipRouteLine = dictWIPRouteLine[key];
                else
                    wipRouteLine = new WIPRouteLine(rLine.Session);
            }

            wipRouteLine.Item = rLine.Item;
            wipRouteLine.OperNo = rLine.OperNo;
            wipRouteLine.NextOperNo = rLine.NextOperNo;
            wipRouteLine.ProcessQty = rLine.ProcessQty;
            wipRouteLine.QtyofWorkCenter = rLine.QtyofWorkCenter;
            wipRouteLine.RunTime = rLine.RunTime;
            wipRouteLine.SetupTime = rLine.SetupTime;
            wipRouteLine.wipItem = rLine.wipItem;
            wipRouteLine.WorkCenter = rLine.WorkCenter;
            wipRouteLine.WorkDesc = rLine.WorkDesc;
            wipRouteLine.WorkOper = rLine.WorkOper;
            wipRouteLine.Save();

            if (dictWIPRouteLine.ContainsKey(key) == false)
                dictWIPRouteLine.Add(key, wipRouteLine);
        }