Esempio n. 1
0
        //新增
        protected override void AddDomainObject(object domainObject)
        {
            if (_InventoryFacade == null)
            {
                _InventoryFacade = new InventoryFacade(base.DataProvider);
            }

            //扣减库存
            string mCode = ((SpecInOut)domainObject).MCode;

            try
            {
                this.DataProvider.BeginTransaction();
                int             qty = ((SpecInOut)domainObject).Qty;//需要扣减的库存
                SpecStorageInfo s   = (SpecStorageInfo)_InventoryFacade.GetSpecStorageInfo(drpStorageOutEdit.SelectedValue, mCode, drpLoationOutEdit.SelectedValue);
                if (qty > s.StorageQty)
                {
                    WebInfoPublish.Publish(this, "输入数量大于库存数量", this.languageComponent1);//add by sam
                    return;
                }
                if (qty == s.StorageQty)
                {
                    _InventoryFacade.DeleteSpecStorageInfo(s);
                }
                else
                {
                    s.StorageQty = s.StorageQty - qty;
                    this._InventoryFacade.UpdateSpecStorageInfo(s);
                }
                this._InventoryFacade.AddSpecInOut((SpecInOut)domainObject);
                this.DataProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                throw ex;
            }
        }
Esempio n. 2
0
        //新增
        protected override void AddDomainObject(object domainObject)
        {
            if (_InventoryFacade == null)
            {
                _InventoryFacade = new InventoryFacade(base.DataProvider);
            }

            ItemFacade itemFacade = new ItemFacade(this.DataProvider);
            string     dQMCode    = FormatHelper.CleanString(this.txtMaterialNO.Text);

            Domain.MOModel.Material material    = (Domain.MOModel.Material)itemFacade.GetMaterialByDQMCode(dQMCode);
            Domain.MOModel.Material newMaterial = null;
            DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);

            try
            {
                this.DataProvider.BeginTransaction();
                //如果该物料编码不存在物料主表,新增一笔数据
                if (material == null)
                {
                    newMaterial              = new Domain.MOModel.Material();
                    newMaterial.MCode        = FormatHelper.CleanString(this.txtMaterialNO.Text, 40);
                    newMaterial.DqmCode      = FormatHelper.CleanString(this.txtMaterialNO.Text, 40);
                    newMaterial.MspecialDesc = FormatHelper.CleanString(this.txtSpecialDescEdit.Text, 200);
                    newMaterial.Muom         = FormatHelper.CleanString(this.txtUnitEdit.Text, 40);
                    newMaterial.MType        = "itemtype_finishedproduct";
                    newMaterial.Sourceflag   = "MES";
                    newMaterial.CUser        = this.GetUserCode();
                    newMaterial.CDate        = dbDateTime.DBDate;
                    newMaterial.CTime        = dbDateTime.DBTime;
                    newMaterial.MaintainUser = this.GetUserCode();
                }

                if (newMaterial != null)
                {
                    itemFacade.AddMaterial(newMaterial);
                }
                //同时更新库存
                SpecStorageInfo specStorageInfo = (SpecStorageInfo)_InventoryFacade.GetSpecStorageInfo(((SpecInOut)domainObject).StorageCode,
                                                                                                       ((SpecInOut)domainObject).MCode,
                                                                                                       ((SpecInOut)domainObject).LocationCode);
                if (specStorageInfo != null)
                {
                    specStorageInfo.StorageQty = specStorageInfo.StorageQty + Convert.ToInt32(this.txtQTY.Text.Trim());
                    this._InventoryFacade.UpdateSpecStorageInfo(specStorageInfo);
                }
                else
                {
                    specStorageInfo              = this._InventoryFacade.CreateNewSpecStorageInfo();
                    specStorageInfo.MCode        = ((SpecInOut)domainObject).MCode;
                    specStorageInfo.DQMCode      = ((SpecInOut)domainObject).DQMCode;
                    specStorageInfo.Muom         = ((SpecInOut)domainObject).Muom;
                    specStorageInfo.StorageCode  = ((SpecInOut)domainObject).StorageCode;
                    specStorageInfo.LocationCode = ((SpecInOut)domainObject).LocationCode;
                    specStorageInfo.StorageQty   = ((SpecInOut)domainObject).Qty;
                    specStorageInfo.CUser        = this.GetUserCode();
                    specStorageInfo.CDate        = dbDateTime.DBDate;
                    specStorageInfo.CTime        = dbDateTime.DBTime;
                    specStorageInfo.MaintainUser = this.GetUserCode();

                    this._InventoryFacade.AddSpecStorageInfo(specStorageInfo);
                }

                this._InventoryFacade.AddSpecInOut((SpecInOut)domainObject);
                this.DataProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                WebInfoPublish.Publish(this, "新增失败:" + ex.Message, this.languageComponent1);
                this.DataProvider.RollbackTransaction();
            }
        }