Ejemplo 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);
            }
            Pickdetailmaterial[] pickdetailmaterialList = ((Pickdetailmaterial[])domainObjects.ToArray(typeof(Pickdetailmaterial)));
            try
            {
                this.DataProvider.BeginTransaction();

                Pick pick = _InventoryFacade.GetPick(txtPickNoQuery.Text) as Pick;
                if (pick == null)
                {
                    WebInfoPublish.Publish(this, pick.PickNo + "拣货任务令不存在!", this.languageComponent1);
                    return;
                }

                foreach (Pickdetailmaterial pickdetailm in pickdetailmaterialList)
                {
                    int packageCount = _WarehouseFacade.GetPackageMaterialCartonnos(pick.PickNo);
                    if (packageCount > 0)
                    {
                        WebInfoPublish.Publish(this, pick.PickNo + "包装信息存在, 请先删除包装信息!", this.languageComponent1);
                        return;
                    }
                }



                foreach (Pickdetailmaterial pickdetailm in pickdetailmaterialList)
                {
                    #region delete
                    #region delete 检查
                    //1、只有行明细是拣料中和拣料完成状态,且拣货任务令头状态是拣料状态或制作箱单状态时才可以删除。
                    PickDetail pickDetail = _InventoryFacade.GetPickDetail(pickdetailm.Pickno, pickdetailm.Pickline) as PickDetail;
                    Pick       pickHead   = _InventoryFacade.GetPick(pickdetailm.Pickno) as Pick;
                    if (pickDetail == null || pickHead == null)
                    {
                        this.DataProvider.RollbackTransaction();
                        return;
                    }
                    if (!(pickDetail.Status == PickDetail_STATUS.Status_Pick ||
                          pickDetail.Status == PickDetail_STATUS.Status_WaitPick ||
                          pickDetail.Status == PickDetail_STATUS.Status_ClosePick || pickDetail.Status == PickDetail_STATUS.Status_Cancel))
                    {
                        this.DataProvider.RollbackTransaction();
                        WebInfoPublish.Publish(this, "行明细是拣料中和拣料完成,取消状态,才可以删除", this.languageComponent1);
                        return;
                    }
                    if (!(pickHead.Status == PickHeadStatus.PickHeadStatus_Pick ||
                          pickHead.Status == PickHeadStatus.PickHeadStatus_MakePackingList ||
                          pickHead.Status == PickHeadStatus.PickHeadStatus_WaitPick || pickHead.Status == PickHeadStatus.PickHeadStatus_Cancel))
                    {
                        this.DataProvider.RollbackTransaction();
                        WebInfoPublish.Publish(this, "拣货任务令头状态是拣料状态或制作箱单,取消状态时,才可以删除", this.languageComponent1);
                        return;
                    }



                    //  2、删除已拣行明细后,该行状态变更为待拣料。
                    _WarehouseFacade.DeletePickdetailmaterial(pickdetailm);
                    //delete pickdetailmsn
                    _WarehouseFacade.DeletePickDetailMaterialSNByCartonNo(pickdetailm.Pickno, pickdetailm.Cartonno);



                    //3、所有已拣行明细删除后,拣货任务令状态变更为待拣料。
                    #endregion

                    StorageDetail storageDetail = _WarehouseFacade.GetStorageDetail(pickdetailm.Cartonno) as StorageDetail;
                    if (storageDetail != null)
                    {
                        storageDetail.FreezeQty    -= Convert.ToInt32(pickdetailm.Qty);
                        storageDetail.AvailableQty += Convert.ToInt32(pickdetailm.Qty);
                        _WarehouseFacade.UpdateStorageDetail(storageDetail);
                        _WarehouseFacade.UpdateStorageDetailSnbyCartonNo(pickdetailm.Cartonno, "N");
                    }

                    if (pickDetail.Status != "Cancel")
                    {
                        pickDetail.Status = PickDetail_STATUS.Status_Pick;
                    }

                    pickDetail.SQTY -= pickdetailm.Qty;
                    int count = _WarehouseFacade.GetPickdetailmaterialCount(pickdetailm.Pickno);
                    if (count == 0)
                    {
                        //pickHead.Status = PickHeadStatus.PickHeadStatus_WaitPick;
                        _WarehouseFacade.UpdatePick(pickHead);
                        //pickDetail.Status = PickDetail_STATUS.Status_WaitPick;
                    }
                    _WarehouseFacade.UpdatePickdetail(pickDetail);

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