Beispiel #1
0
        /// <summary>
        /// Do the auto receive
        /// </summary>
        /// <param name="IssueNumber">The issue number</param>
        public static void AutoReceive(string IssueNumber)
        {
            var db = DCFactory.GetDataContext<PartDataContext>();
            var rd = new List<ReceiveDetail>();
            var list = db.IShippings.Where(p => p.IssueNumber == IssueNumber).ToList();
            var oh = db.OrderHeaders.Single(p => p.OrderHeaderId == list[0].VDMSOrderId);

            // collect data
            var rh = new ReceiveHeader
            {
                DealerCode = oh.ToDealer,
                HasUndo = false,
                IsAutomatic = true,
                IsLocked = false,
                IssueNumber = IssueNumber,
                OrderHeaderId = oh.OrderHeaderId,
                ReceiveDate = DateTime.Now,
                WarehouseId = oh.ToLocation
            };

            foreach (var item in list)
            {
                if (item.ShippingQuantity != 0)
                {
                    var od = db.OrderDetails.FirstOrDefault(p => p.OrderHeaderId == oh.OrderHeaderId && p.PartCode == item.PartCode);
                    if (od == null) continue;

                    var rcvd = new ReceiveDetail
                    {
                        BrokenQuantity = 0,
                        DealerComment = string.Empty,
                        GoodQuantity = item.ShippingQuantity,
                        LackQuantity = 0,
                        OrderHeaderId = oh.OrderHeaderId,
                        OrderQuantity = od.OrderQuantity,
                        PartCode = item.PartCode,
                        ShippingQuantity = item.ShippingQuantity,
                        WrongQuantity = 0,
                        ReceiveHeader = rh
                    };
                    rd.Add(rcvd);
                }
            }

            db.ReceiveHeaders.InsertOnSubmit(rh);
            db.SubmitChanges();

            // update current inventory, inventory day
            rd.ForEach(p =>
            {
                PartDAO.StockAdjust(p.PartCode, "P", oh.ToDealer, oh.ToLocation, null, DateTime.Now, InventoryAction.NormalImport, p.UnitPrice * p.GoodQuantity, p.GoodQuantity, p.DealerComment, string.Empty, null);
            });
            db.SubmitChanges();

            //// update has in stock flag
            //oh.AlreadyInStock = true;
            //oh.AutoInStockDate = DateTime.Now;
            //oh.Status = OrderStatus.OrderClosedNormal;
            //db.SubmitChanges();
        }
 private void detach_ReceiveHeaders(ReceiveHeader entity)
 {
     this.SendPropertyChanging();
     entity.OrderHeader = null;
 }
 private void attach_ReceiveHeaders(ReceiveHeader entity)
 {
     this.SendPropertyChanging();
     entity.Dealer = this;
 }
 private void attach_ReceiveHeaders(ReceiveHeader entity)
 {
     this.SendPropertyChanging();
     entity.Warehouse = this;
 }
 private void detach_ReceiveHeaders(ReceiveHeader entity)
 {
     this.SendPropertyChanging("ReceiveHeaders");
     entity.Warehouse = null;
 }
 private void attach_ReceiveHeaders(ReceiveHeader entity)
 {
     this.SendPropertyChanging("ReceiveHeaders");
     entity.OrderHeader = this;
 }