Exemplo n.º 1
0
        protected void cmdClose_ServerClick(object sender, EventArgs e)
        {
            /* 下发的时候需要 */
            if (_facade == null)
            {
                _facade = new BenQGuru.eMES.MOModel.RMAFacade(base.DataProvider);
            }
            if (_TSFacade == null)
            {
                _TSFacade = new TSFacade(this.DataProvider);
            }
            if (_DataCollectFacade == null)
            {
                _DataCollectFacade = new DataCollectFacade(this.DataProvider);
            }

            ArrayList array = this.gridHelper.GetCheckedRows();

            if (array.Count > 0)
            {
                ArrayList items = new ArrayList(array.Count);

                foreach (GridRecord row in array)
                {
                    RMABill rmaBill = (RMABill)this.GetEditObject(row);
                    if (rmaBill != null)
                    {
                        if (rmaBill.Status != RMABillStatus.Opened)
                        {
                            WebInfoPublish.PublishInfo(this, "$BS_RMABillStatus_CannotClose $RMABillCode:" + rmaBill.RMABillCode, this.languageComponent1);
                            return;
                        }

                        object[] objs = _facade.QueryRMADetail(rmaBill.RMABillCode);
                        if (objs == null || objs.Length == 0)
                        {
                            WebInfoPublish.PublishInfo(this, "$BS_RMABillDetail_NOT_EXIST $RMABillCode:" + rmaBill.RMABillCode, this.languageComponent1);
                            return;
                        }
                        foreach (RMADetial rmaDetial in objs)
                        {
                            if (rmaDetial.Handelcode == "ts")
                            {
                                object objTs = _TSFacade.QueryLastTSByRunningCard(rmaDetial.Rcard);
                                if (objTs != null)
                                {
                                    //处理方式为维修的,则序列号必须为维修完成(tblts.tsstatus_complete)或者报废(tblts.tsstatus_scrap)
                                    if (!((objTs as Domain.TS.TS).TSStatus == TSStatus.TSStatus_Complete || (objTs as Domain.TS.TS).TSStatus == TSStatus.TSStatus_Scrap))
                                    {
                                        WebInfoPublish.PublishInfo(this, "$RCAR_MUST_TSCOMPLETE_TSSCRAP $RCARD:" + rmaDetial.Rcard, this.languageComponent1);
                                        return;
                                    }
                                }
                            }
                            else if (rmaDetial.Handelcode == "rework")
                            {
                                object objsimRepot = _DataCollectFacade.GetLastSimulationReportByRMA(rmaDetial.Rcard, rmaDetial.Rmabillcode);
                                if (objsimRepot != null)
                                {
                                    if ((objsimRepot as Domain.DataCollect.SimulationReport).IsComplete != "1")
                                    {
                                        WebInfoPublish.PublishInfo(this, "$CS_RCARD_IS_NOT_FINISHED $RCARD:" + rmaDetial.Rcard, this.languageComponent1);
                                        return;
                                    }
                                }
                                else
                                {
                                    //还未做返工
                                    WebInfoPublish.PublishInfo(this, "$RCARD_NOT_DO_REWORK $RCARD:" + rmaDetial.Rcard, this.languageComponent1);
                                    return;
                                }
                            }
                        }

                        items.Add(rmaBill);
                    }
                }


                //放在事务中处理
                this.DataProvider.BeginTransaction();

                foreach (RMABill rmabill in items)
                {
                    // Update RMA Status
                    rmabill.Status = RMABillStatus.Closed;
                    _facade.UpdateRMABill(rmabill);
                }

                this.DataProvider.CommitTransaction();

                RequestData();
            }
        }