Esempio n. 1
0
        protected override void DeleteDomainObjects(ArrayList domainObjects)
        {
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new WarehouseFacade(base.DataProvider);
            }
            if (_InventoryFacade == null)
            {
                _InventoryFacade = new InventoryFacade(this.DataProvider);
            }
            CARTONINVDETAILSN[] cartoninvdetailsnList = ((CARTONINVDETAILSN[])domainObjects.ToArray(typeof(CARTONINVDETAILSN)));
            try
            {
                this.DataProvider.BeginTransaction();
                foreach (CARTONINVDETAILSN cartoninvdetailsn in cartoninvdetailsnList)
                {
                    //1、删除完SN后,同时删除掉对应的TBLCARTONINVDETAILMATERIAL,TBLCARTONINVDETAIL信息。
                    //2、拣货任务令头状态为pick,且发货箱单头状态为Release时才可以删除。
                    #region delete
                    _WarehouseFacade.DELETECARTONINVDETAILSN(cartoninvdetailsn);
                    Pick       pickHead   = _InventoryFacade.GetPick(cartoninvdetailsn.PICKNO) as Pick;
                    PickDetail pickDetail = _InventoryFacade.GetPickDetail(cartoninvdetailsn.PICKNO, cartoninvdetailsn.PICKLINE) as PickDetail;
                    //Pickdetailmaterial pickdetailmaterial = _WarehouseFacade.GetPickdetailmaterial(cartonInvDetailMaterial.PICKNO, cartonInvDetailMaterial.CARTONNO) as Pickdetailmaterial;
                    if (pickDetail == null || pickHead == null)
                    {
                        this.DataProvider.RollbackTransaction();
                        return;
                    }
                    object[] objPickdetailmaterials = this._WarehouseFacade.QueryPICKDetailMaterialBydqMCode(cartoninvdetailsn.PICKNO, pickDetail.DQMCode);
                    if (objPickdetailmaterials == null)
                    {
                        this.DataProvider.RollbackTransaction();
                        return;
                    }
                    CARTONINVOICES cartoninvoices = _WarehouseFacade.GetCartoninvoices(cartoninvdetailsn.CARINVNO)
                                                    as CARTONINVOICES;
                    if (cartoninvoices == null)
                    {
                        this.DataProvider.RollbackTransaction();
                        return;
                    }
                    //if (!(cartoninvoices.STATUS == PickDetail_STATUS.Status_Release))
                    //{
                    //    this.DataProvider.RollbackTransaction();
                    //    WebInfoPublish.Publish(this, "发货箱单头状态为Release时才可以删除", this.languageComponent1);
                    //    return;
                    //}
                    if (!(pickHead.Status == PickHeadStatus.PickHeadStatus_Pick || pickHead.Status == PickHeadStatus.PickHeadStatus_WaitPick))
                    {
                        this.DataProvider.RollbackTransaction();
                        WebInfoPublish.Publish(this, "拣货任务令头状态为pick或者待拣料时才可以删除", this.languageComponent1);
                        return;
                    }
                    object[] cartoninvdetailSnList = _WarehouseFacade.GetCartoninvdetailsnByCartonno(cartoninvdetailsn.CARINVNO,
                                                                                                     cartoninvdetailsn.CARTONNO);
                    if (cartoninvdetailSnList == null)
                    {
                        CartonInvDetailMaterial cartonInvDetailMaterial = _WarehouseFacade.QueryCartonInvDetailMaterial(cartoninvdetailsn.CARINVNO,
                                                                                                                        cartoninvdetailsn.CARTONNO, pickDetail.DQMCode) as CartonInvDetailMaterial;
                        _WarehouseFacade.DeleteCartonInvDetailMaterial(cartonInvDetailMaterial);
                        _WarehouseFacade.DeleteCartoninvdetailByCartonNo(cartoninvdetailsn.CARINVNO, cartoninvdetailsn.CARTONNO);
                    }
                    else
                    {
                        CartonInvDetailMaterial cartonInvDetailMaterial = _WarehouseFacade.QueryCartonInvDetailMaterial(cartoninvdetailsn.CARINVNO,
                                                                                                                        cartoninvdetailsn.CARTONNO, pickDetail.DQMCode) as CartonInvDetailMaterial;
                        if (cartonInvDetailMaterial != null)
                        {
                            cartonInvDetailMaterial.QTY -= 1;
                            _WarehouseFacade.UpdateCartonInvDetailMaterial(cartonInvDetailMaterial);
                        }
                    }

                    pickDetail.PQTY -= 1;
                    _InventoryFacade.UpdatePickDetail(pickDetail);

                    #region Pickdetailmaterial
                    foreach (Pickdetailmaterial _pickdetailmaterial in objPickdetailmaterials)
                    {
                        decimal num = _pickdetailmaterial.PQty;
                        if (num > 0)
                        {
                            _pickdetailmaterial.PQty -= 1;
                            this._WarehouseFacade.UpdatePickdetailmaterial(_pickdetailmaterial);
                            break;
                        }
                    }
                    #endregion
                    //pickdetailmaterial.PQty-= 1;
                    //_WarehouseFacade.UpdatePickdetailmaterial(pickdetailmaterial);

                    #endregion
                }
                this.DataProvider.CommitTransaction();
                WebInfoPublish.Publish(this, "删除成功", this.languageComponent1);
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                WebInfoPublish.PublishInfo(this, ex.Message, this.languageComponent1);
            }
        }