Ejemplo n.º 1
0
 public virtual void UpdateMiscOrder(MiscOrder entity)
 {
     entityDao.UpdateMiscOrder(entity);
 }
Ejemplo n.º 2
0
        public MiscOrder SaveMiscOrder(MiscOrder miscOrder, User user)
        {
            MiscOrder dbMiscOrder = null;

            if (miscOrder != null && miscOrder.OrderNo != null)
            {
                dbMiscOrder = miscOrderDao.LoadMiscOrder(miscOrder.OrderNo);
            }

            if (dbMiscOrder != null)
            {
                IList <MiscOrderDetail> dbMiscOrderDets = dbMiscOrder.MiscOrderDetails;
                foreach (MiscOrderDetail miscOrderDet in dbMiscOrderDets)
                {
                    miscOrderDetailMgr.DeleteMiscOrderDetail(miscOrderDet);
                }

                MiscOrder pageMiscOrder = miscOrder;
                IList <MiscOrderDetail> pageMiscOrderDets = pageMiscOrder.MiscOrderDetails;
                foreach (MiscOrderDetail miscOrderDet in pageMiscOrderDets)
                {
                    miscOrderDet.MiscOrder = pageMiscOrder;
                    miscOrderDetailMgr.CreateMiscOrderDetail(miscOrderDet);
                }
                dbMiscOrder.Remark        = pageMiscOrder.Remark;
                dbMiscOrder.Reason        = pageMiscOrder.Reason;
                dbMiscOrder.EffectiveDate = pageMiscOrder.EffectiveDate;
                dbMiscOrder.Location      = pageMiscOrder.Location;
                dbMiscOrder.CreateDate    = DateTime.Now;
                miscOrderDao.UpdateMiscOrder(dbMiscOrder);
            }
            else
            {
                dbMiscOrder            = miscOrder;
                dbMiscOrder.CreateUser = user;
                dbMiscOrder.CreateDate = DateTime.Now;
                dbMiscOrder.OrderNo    = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_MISCO);
                miscOrderDao.CreateMiscOrder(dbMiscOrder);

                IList <MiscOrderDetail> pageMiscOrderDets = dbMiscOrder.MiscOrderDetails;
                foreach (MiscOrderDetail miscOrderDet in pageMiscOrderDets)
                {
                    miscOrderDet.MiscOrder = dbMiscOrder;
                    miscOrderDetailMgr.CreateMiscOrderDetail(miscOrderDet);

                    //出入库
                    if (dbMiscOrder.Type == BusinessConstants.CODE_MASTER_MISC_ORDER_TYPE_VALUE_GI)
                    {
                        //出库
                        this.locationMgr.InventoryOut(miscOrderDet, user);
                    }
                    else if (dbMiscOrder.Type == BusinessConstants.CODE_MASTER_MISC_ORDER_TYPE_VALUE_GR)
                    {
                        //入库
                        this.locationMgr.InventoryIn(miscOrderDet, user);
                    }
                    else if (dbMiscOrder.Type == BusinessConstants.CODE_MASTER_MISC_ORDER_TYPE_VALUE_ADJ)
                    {
                        //用入库操作就可以做调整
                        this.locationMgr.InventoryIn(miscOrderDet, user);
                        //if (miscOrderDet.Qty > 0)
                        //{
                        //    //入库
                        //    this.locationMgr.InventoryIn(miscOrderDet, user);
                        //}
                        //else if (miscOrderDet.Qty < 0)
                        //{
                        //    //出库
                        //    miscOrderDet.Qty = miscOrderDet.Qty * -1;  //调整为正数
                        //    this.locationMgr.InventoryOut(miscOrderDet, user);
                        //}
                    }
                    else
                    {
                        throw new TechnicalException("MiscOrder Type:" + dbMiscOrder.Type + " is not valided");
                    }
                }
            }
            return(ReLoadMiscOrder(dbMiscOrder.OrderNo));
        }