Ejemplo n.º 1
0
        protected void CmdConfirmOweQtyObjects(object[] pickList)
        {
            // 点击该按钮,初始TBLPICKDETAIL. OweQTY为空or零,
            //点击该按钮后保存TBLPICKDETAIL. OweQTY= TBLPICKDETAIL. SQTY
            //注:只有状态为:Owe:欠料的物料行可以执行此按钮,确认后该行更新状态为ClosePick:拣料完成
            if (facade == null)
            {
                facade = new InventoryFacade(base.DataProvider);
            }
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new WarehouseFacade(base.DataProvider);
            }
            DBDateTime dbTime = FormatHelper.GetNowDBDateTime(this.DataProvider);

            try
            {
                this.DataProvider.BeginTransaction();
                foreach (PickDetail pickdetail in pickList)
                {
                    if (pickdetail.Status == PickDetail_STATUS.Status_Owe)
                    {
                        if (pickdetail.OweQTY == 0 || string.IsNullOrEmpty(pickdetail.OweQTY.ToString()))
                        {
                            PickDetail oldpickdetail = (PickDetail)facade.GetPickDetail(pickdetail.PickNo, pickdetail.PickLine);
                            oldpickdetail.OweQTY = oldpickdetail.SQTY;
                            oldpickdetail.Status = PickDetail_STATUS.Status_ClosePick;
                            facade.UpdatePickDetail(oldpickdetail);
                        }
                        else
                        {
                            WebInfoPublish.Publish(this, "已申请欠料发货!", this.languageComponent1);
                            return;
                        }
                    }
                    else
                    {
                        WebInfoPublish.Publish(this, "只有状态为欠料的物料行可以执行此按钮", this.languageComponent1);
                        return;
                    }
                }

                #region 在invinouttrans表中增加一条数据 箱单完成日期
                WarehouseFacade wfacade = new WarehouseFacade(base.DataProvider);
                DBDateTime      dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider);
                foreach (PickDetail pickDetail in pickList)
                {
                    Pick          pick  = facade.GetPick(pickDetail.PickNo) as Pick;
                    InvInOutTrans trans = wfacade.CreateNewInvInOutTrans();
                    trans.CartonNO        = string.Empty;
                    trans.DqMCode         = pickDetail.DQMCode;
                    trans.FacCode         = string.Empty;
                    trans.FromFacCode     = string.Empty;
                    trans.FromStorageCode = string.Empty;
                    trans.InvNO           = pick.InvNo;//.InvNo;
                    trans.InvType         = pick.PickType;
                    trans.LotNo           = string.Empty;
                    trans.MaintainDate    = dbTime1.DBDate;
                    trans.MaintainTime    = dbTime1.DBTime;
                    trans.MaintainUser    = this.GetUserCode();
                    trans.MCode           = pickDetail.MCode;
                    trans.ProductionDate  = 0;
                    trans.Qty             = pickDetail.QTY;
                    trans.Serial          = 0;
                    trans.StorageAgeDate  = 0;
                    trans.StorageCode     = string.Empty;
                    trans.SupplierLotNo   = string.Empty;
                    trans.TransNO         = pickDetail.PickNo;
                    trans.TransType       = "OUT";
                    trans.Unit            = string.Empty;
                    trans.ProcessType     = "ClosePick";
                    wfacade.AddInvInOutTrans(trans);
                }

                #endregion

                string pickno       = FormatHelper.CleanString(this.txtPickNoQuery.Text);
                bool   isUpdatePick = facade.QueryPickDetailCount(pickno, PickDetail_STATUS.Status_ClosePick) == 0;
                if (isUpdatePick)
                {
                    facade.UpdatePickStatusByPickno(pickno, PickHeadStatus.PickHeadStatus_MakePackingList);
                }
                #region  创建发货箱单

                string carInvNo = string.Empty;
                object obj      = _WarehouseFacade.GetCartonInvoices(pickno);
                if (obj == null)
                {
                    CARTONINVOICES CartonH = _WarehouseFacade.CreateNewCartoninvoices();
                    object         objLot  = _WarehouseFacade.GetNewLotNO("K", dbTime.DBDate.ToString().Substring(2, 6).ToString());
                    Serialbook     serbook = _WarehouseFacade.CreateNewSerialbook();
                    if (objLot == null)
                    {
                        #region
                        CartonH.CARINVNO = "K" + dbTime.DBDate.ToString().Substring(2, 6).ToString() + "001";
                        CartonH.PICKNO   = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtPickNoQuery.Text));
                        CartonH.STATUS   = CartonInvoices_STATUS.Status_Release;
                        CartonH.CDATE    = dbTime.DBDate;
                        CartonH.CTIME    = dbTime.DBTime;
                        CartonH.CUSER    = this.GetUserCode();
                        CartonH.MDATE    = dbTime.DBDate;
                        CartonH.MTIME    = dbTime.DBTime;
                        CartonH.MUSER    = this.GetUserCode();
                        _WarehouseFacade.AddCartoninvoices(CartonH);

                        serbook.SNprefix  = "K" + dbTime.DBDate.ToString().Substring(2, 6).ToString();
                        serbook.MAXSerial = "2";
                        serbook.MUser     = this.GetUserCode();
                        serbook.MDate     = dbTime.DBDate;
                        serbook.MTime     = dbTime.DBTime;

                        _WarehouseFacade.AddSerialbook(serbook);
                        #endregion
                    }
                    else
                    {
                        #region
                        string MAXNO = (objLot as Serialbook).MAXSerial;
                        string SNNO  = (objLot as Serialbook).SNprefix;
                        CartonH.CARINVNO = SNNO + Convert.ToString(MAXNO).PadLeft(3, '0');
                        CartonH.PICKNO   = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtPickNoQuery.Text));
                        CartonH.STATUS   = CartonInvoices_STATUS.Status_Release;
                        CartonH.CDATE    = dbTime.DBDate;
                        CartonH.CTIME    = dbTime.DBTime;
                        CartonH.CUSER    = this.GetUserCode();
                        CartonH.MDATE    = dbTime.DBDate;
                        CartonH.MTIME    = dbTime.DBTime;
                        CartonH.MUSER    = this.GetUserCode();
                        _WarehouseFacade.AddCartoninvoices(CartonH);

                        //更新tblserialbook
                        serbook.SNprefix  = SNNO;
                        serbook.MAXSerial = Convert.ToString((int.Parse(MAXNO) + 1));
                        serbook.MUser     = this.GetUserCode();
                        serbook.MDate     = dbTime.DBDate;
                        serbook.MTime     = dbTime.DBTime;
                        _WarehouseFacade.UpdateSerialbook(serbook);
                        #endregion
                    }
                }
                # endregion
                this.DataProvider.CommitTransaction();
                WebInfoPublish.Publish(this, "确认欠料发货数量成功", this.languageComponent1);
            }