Esempio n. 1
0
        public string Add(string userCode, string newIqcNo, string fromCarton)
        {
            #region check
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new WarehouseFacade(DataProvider);
            }
            InventoryFacade facade     = new InventoryFacade(this.DataProvider);
            ItemFacade      itemFacade = new ItemFacade(DataProvider);
            DBDateTime      dbTime     = FormatHelper.GetNowDBDateTime(DataProvider);
            string          msg        = "";

            StorageDetail storageCarton = (StorageDetail)facade.GetStorageDetail(fromCarton);
            if (storageCarton == null)
            {  //A 根据原箱号和数量操作。根据原箱号(cartonno)到TBLStorageDetail中查找数据。没有报错。
                msg = "转储单中没有对应的SAP物料号";
                return(msg);
            }
            string dqmCode = storageCarton.DQMCode;
            if (string.IsNullOrEmpty(dqmCode))
            {
                msg = "鼎桥物料编码不能为空";
                return(msg);
            }
            BenQGuru.eMES.Domain.MOModel.Material material = (BenQGuru.eMES.Domain.MOModel.Material)itemFacade.GetMaterialByDQMCode(dqmCode);
            if (material == null)
            {
                msg = "鼎桥物料编码不存在";
                return(msg);
            }
            if (string.IsNullOrEmpty(newIqcNo))
            {
                msg = "移转单号不能为空";
                return(msg);
            }

            #endregion
            #region try
            try
            {
                this.DataProvider.BeginTransaction();
                Storloctrans oldStorloctrans = (Storloctrans)_WarehouseFacade.GetStorloctrans(newIqcNo);
                if (oldStorloctrans == null)
                {
                    #region 货位移动单信息TBLStorLocTrans表增加一笔数据
                    Storloctrans storloctrans = new Storloctrans();
                    storloctrans.Transno      = newIqcNo;
                    storloctrans.TransType    = TransType.TransType_Move;//类型(Transfer:转储;Move:货位移动)
                    storloctrans.Status       = Pick_STATUS.Status_Release;
                    storloctrans.Invno        = " ";
                    storloctrans.StorageCode  = "";
                    storloctrans.CDate        = dbTime.DBDate;
                    storloctrans.CTime        = dbTime.DBTime;
                    storloctrans.CUser        = userCode;// this.GetUserCode();
                    storloctrans.MaintainDate = dbTime.DBDate;
                    storloctrans.MaintainTime = dbTime.DBTime;
                    storloctrans.MaintainUser = userCode;// this.GetUserCode();
                    _WarehouseFacade.AddStorloctrans(storloctrans);
                    #endregion
                }
                StorloctransDetail oldstorloctransDetail = (StorloctransDetail)_WarehouseFacade.GetStorloctransdetail(newIqcNo, material.MCode);
                if (oldstorloctransDetail == null)
                {
                    //检查移转单下表TBLStorLocTransDetail是否存在,如果存在提示已经包含物料信息。
                    //    this.DataProvider.RollbackTransaction();
                    //   msg= "移转单号已经包含物料信息" ;
                    //   return msg;
                    //}
                    //else
                    //{
                    #region 货位移动单信息StorloctransDetail表增加一笔数据
                    StorloctransDetail storloctransDetail = new StorloctransDetail();
                    storloctransDetail.Transno      = newIqcNo;
                    storloctransDetail.Status       = Pick_STATUS.Status_Release;
                    storloctransDetail.DqmCode      = dqmCode;
                    storloctransDetail.MCode        = material.MCode;
                    storloctransDetail.MDesc        = material.MenlongDesc;
                    storloctransDetail.CustmCode    = ""; //
                    storloctransDetail.Unit         = ""; //
                    storloctransDetail.Qty          = 0;
                    storloctransDetail.CDate        = dbTime.DBDate;
                    storloctransDetail.CTime        = dbTime.DBTime;
                    storloctransDetail.CUser        = userCode;// this.GetUserCode();
                    storloctransDetail.MaintainDate = dbTime.DBDate;
                    storloctransDetail.MaintainTime = dbTime.DBTime;
                    storloctransDetail.MaintainUser = userCode;// this.GetUserCode();
                    _WarehouseFacade.AddStorloctransdetail(storloctransDetail);
                    #endregion
                }



                //货位移动单据号
                //string date = dbTime.DBDate.ToString().Substring(2, 6);
                //string documentno = CreateAutoDocmentsNo();
                //SaveDocmentsNo(documentno, userCode);


                this.DataProvider.CommitTransaction();
                msg = "新增成功";
                return(msg);
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                msg = ex.Message;
                return(msg);
                //WebInfoPublish.PublishInfo(this, ex.Message, this.languageComponent1);
            }
            #endregion
        }