Пример #1
0
        protected void cmdDistribution_ServerClick(object sender, EventArgs e)
        {
            /* 下发的时候需要 */
            if (_facade == null)
            {
                _facade = new BenQGuru.eMES.MOModel.RMAFacade(base.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.Initial)
                        {
                            WebInfoPublish.PublishInfo(this, "$BS_RMABillStatus_CannotOpened $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;
                        }

                        items.Add(rmaBill);
                    }
                }

                if (_TSFacade == null)
                {
                    _TSFacade = new TSFacade(this.DataProvider);
                }
                //放在事务中处理
                this.DataProvider.BeginTransaction();

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

                    object[] objs = _facade.QueryRMADetail(rmabill.RMABillCode);
                    if (objs != null || objs.Length != 0)
                    {
                        foreach (RMADetial detial in objs)
                        {
                            //如果该序列号的处理方式为维修的,需要往TBLTS和TBLTSERRORCODE插入数据
                            if (detial.Handelcode == "ts")
                            {
                                //Insert TS
                                Domain.TS.TS ts = this.GetTS(detial);
                                _TSFacade.AddTS(ts);

                                Domain.TS.TSErrorCode tsErrorCode = this.GetTSErrorCode(detial, ts);
                                _TSFacade.AddTSErrorCode(tsErrorCode);
                            }
                        }
                    }
                }

                this.DataProvider.CommitTransaction();
            }
            //InitViewPanel();

            this.RequestData();
        }
Пример #2
0
        private Messages DropLoadedParts(string rcard)
        {
            Messages msg = new Messages();

            ActionOnLineHelper onLine            = new ActionOnLineHelper(DataProvider);
            MaterialFacade     materialFacade    = new MaterialFacade(this.DataProvider);
            ItemFacade         itemFacade        = new ItemFacade(this.DataProvider);
            DataCollectFacade  dataCollectFacade = new DataCollectFacade(this.DataProvider);
            TSFacade           tsFacade          = new TSFacade(this.DataProvider);

            string sourceRCard = dataCollectFacade.GetSourceCard(rcard.Trim().ToUpper(), string.Empty);

            ProductInfo product = GetProduct(sourceRCard);

            if (product == null || product.LastSimulation == null)
            {
                msg.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                return(msg);
            }

            // Marked By HI1/Venus.Feng on 20081013 for Hisense Version : GOOD can do drop

            /*
             * if (product.LastSimulation.ProductStatus != ProductStatus.NG)
             * {
             *  msg.Add(new UserControl.Message(MessageType.Error, "$DropMaterial_Need_NG"));
             *  return msg;
             * }
             */
            // End Marked

            msg.Add(new UserControl.Message(rcard));

            //获取所有需要拆解或者替换的Parts
            ArrayList partsToUnload = new ArrayList();

            for (int i = 0; i < this.ultraGridLoadedPart.Rows.Count; i++)
            {
                if (ultraGridLoadedPart.Rows[i].Cells[0].Text.ToLower() == "true")
                {
                    InnoObject innoObject = new InnoObject();

                    innoObject.LineIndex  = i;
                    innoObject.MCard      = ultraGridLoadedPart.Rows[i].Cells["PackedNo"].Text;
                    innoObject.MCardType  = ultraGridLoadedPart.Rows[i].Cells["MCardType"].Text;
                    innoObject.ItemIndex  = partsToUnload.Count + 1;
                    innoObject.MItemCode  = ultraGridLoadedPart.Rows[i].Cells["ItemCode"].Text;
                    innoObject.MOCode     = ultraGridLoadedPart.Rows[i].Cells["MOCode"].Text;
                    innoObject.Qty        = 1;
                    innoObject.NewBarcode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(ultraGridLoadedPart.Rows[i].Cells["NewBarcode"].Text.Trim()));

                    partsToUnload.Add(innoObject);
                }
            }

            //对于需要替换的Parts,需要做类似上料中的解析和检查
            for (int i = 0; i < partsToUnload.Count; i++)
            {
                InnoObject innoObject = (InnoObject)partsToUnload[i];

                if (innoObject.NewBarcode.Trim().Length > 0)
                {
                    //抓取物料的设定
                    Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(innoObject.MItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID);
                    if (material == null)
                    {
                        msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_NotFound"));
                        return(msg);
                    }

                    string barcode = innoObject.NewBarcode.Trim();

                    //模拟一个OPBOMDetail
                    OPBOMDetail detailTemp = new OPBOMDetail();
                    detailTemp.OPBOMItemControlType = material.MaterialControlType;
                    detailTemp.OPBOMParseType       = material.MaterialParseType;
                    detailTemp.OPBOMCheckType       = material.MaterialCheckType;
                    detailTemp.CheckStatus          = material.CheckStatus;
                    detailTemp.SerialNoLength       = material.SerialNoLength;
                    detailTemp.NeedVendor           = material.NeedVendor;
                    detailTemp.OPBOMSourceItemCode  = innoObject.MItemCode;
                    detailTemp.OPBOMItemCode        = innoObject.MItemCode;
                    detailTemp.OPBOMItemQty         = 1;


                    MINNO newMINNO = new MINNO();
                    newMINNO.MOCode    = innoObject.MOCode.Trim();
                    newMINNO.MItemCode = material.MaterialCode.Trim();

                    Messages collectMessage = dataCollectFacade.GetMINNOByBarcode(detailTemp, barcode, newMINNO.MOCode, null, false, false, out newMINNO);

                    if (collectMessage.IsSuccess())
                    {
                        innoObject.NewLotNo          = newMINNO.LotNO;
                        innoObject.NewPCBA           = newMINNO.PCBA;
                        innoObject.NewBIOS           = newMINNO.BIOS;
                        innoObject.NewVersion        = newMINNO.Version;
                        innoObject.NewVendorItemCode = newMINNO.VendorItemCode;
                        innoObject.NewVendorCode     = newMINNO.VendorCode;
                        innoObject.NewDateCode       = newMINNO.DateCode;
                    }
                    else
                    {
                        msg.AddMessages(collectMessage);
                        return(msg);
                    }
                }
            }

            try
            {
                this.DataProvider.BeginTransaction();

                //更新试流单
                //下料中处理tbltry,tbltry2rcard
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];

                    TryEventArgs tryEventArgs = new TryEventArgs(
                        ActionType.DataCollectAction_TryNew, ApplicationService.Current().UserCode, product.LastSimulation.OPCode, ApplicationService.Current().ResourceCode,
                        product.LastSimulation.ItemCode, sourceRCard, innoObject.MItemCode, innoObject.MCard, string.Empty, false, false);

                    msg.AddMessages(onLine.ActionWithTransaction(tryEventArgs));
                    if (!msg.IsSuccess())
                    {
                        DataProvider.RollbackTransaction();
                        return(msg);
                    }
                }

                //更新试流单
                //上料中处理tbltry,tbltry2rcard
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];
                    if (innoObject.NewBarcode.Trim().Length > 0)
                    {
                        TryEventArgs tryEventArgs = new TryEventArgs(
                            ActionType.DataCollectAction_TryNew, ApplicationService.Current().UserCode, product.LastSimulation.OPCode, ApplicationService.Current().ResourceCode,
                            product.LastSimulation.ItemCode, sourceRCard, innoObject.MItemCode, innoObject.NewBarcode, string.Empty, true, true);

                        msg.AddMessages(onLine.ActionWithTransaction(tryEventArgs));
                        if (!msg.IsSuccess())
                        {
                            DataProvider.RollbackTransaction();
                            return(msg);
                        }
                    }
                }

                //检查新上料是否在TS中而不可用
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];
                    if (innoObject.NewBarcode.Trim().Length > 0)
                    {
                        if (!tsFacade.RunningCardCanBeClollected(innoObject.NewBarcode.Trim(), CardType.CardType_Part))
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + innoObject.NewBarcode.Trim()));
                            DataProvider.RollbackTransaction();
                            return(msg);
                        }
                    }
                }

                //拆解或者替换处理tblonwipitem,tblsimulationreport
                DropMaterialEventArgs dropMaterialEventArgs = new DropMaterialEventArgs(ActionType.DataCollectAction_DropMaterial, product.LastSimulation.RunningCard,
                                                                                        ApplicationService.Current().UserCode, ApplicationService.Current().ResourceCode,
                                                                                        product);
                dropMaterialEventArgs.OnwipItems = partsToUnload.ToArray();

                msg.AddMessages(onLine.ActionWithTransaction(dropMaterialEventArgs));
                if (!msg.IsSuccess())
                {
                    DataProvider.RollbackTransaction();
                    return(msg);
                }

                //针对拆解下的物料,做TS相关的动作
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];

                    if (_TSList[innoObject.LineIndex] != null)
                    {
                        if (_TSErrorCodeList[innoObject.LineIndex] == null)
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$CS_Please_Select_ErrorCode"));
                            DataProvider.RollbackTransaction();
                            return(msg);
                        }

                        Domain.TS.TS oldTS = (Domain.TS.TS)tsFacade.QueryLastTSByRunningCard(innoObject.MCard);
                        if (oldTS != null)
                        {
                            if (oldTS.TSStatus == TSStatus.TSStatus_New ||
                                oldTS.TSStatus == TSStatus.TSStatus_Confirm ||
                                oldTS.TSStatus == TSStatus.TSStatus_TS)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTS"));
                                DataProvider.RollbackTransaction();
                                return(msg);
                            }
                            else if (oldTS.TSStatus != TSStatus.TSStatus_Reflow &&
                                     oldTS.TSStatus != TSStatus.TSStatus_Split &&
                                     oldTS.TSStatus != TSStatus.TSStatus_Complete &&
                                     oldTS.TSStatus != TSStatus.TSStatus_Scrap)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_WrongTSStatus"));
                                DataProvider.RollbackTransaction();
                                return(msg);
                            }
                        }

                        Domain.TS.TS newTS = (Domain.TS.TS)_TSList[innoObject.LineIndex];
                        tsFacade.AddTS(newTS);
                        foreach (TSErrorCode tsErrorCode in (TSErrorCode[])_TSErrorCodeList[innoObject.LineIndex])
                        {
                            tsErrorCode.RunningCard         = newTS.RunningCard;
                            tsErrorCode.RunningCardSequence = newTS.RunningCardSequence;
                            tsErrorCode.ItemCode            = newTS.ItemCode;
                            tsErrorCode.ModelCode           = newTS.ModelCode;
                            tsErrorCode.MOCode       = newTS.MOCode;
                            tsErrorCode.MOSeq        = newTS.MOSeq;
                            tsErrorCode.MaintainUser = newTS.MaintainUser;
                            tsErrorCode.MaintainDate = newTS.MaintainDate;
                            tsErrorCode.MaintainTime = newTS.MaintainTime;

                            tsFacade.AddTSErrorCode(tsErrorCode);
                        }
                    }
                }

                if (!msg.IsSuccess())
                {
                    DataProvider.RollbackTransaction();
                    return(msg);
                }

                if (msg.IsSuccess())
                {
                    DataProvider.CommitTransaction();
                }
                else
                {
                    DataProvider.RollbackTransaction();
                }
            }
            catch (Exception e)
            {
                this.DataProvider.RollbackTransaction();
                msg.Add(new UserControl.Message(e));
            }

            return(msg);
        }
Пример #3
0
        /// <summary>
        /// ** 功能描述:	确认流程卡序列号的维修
        /// ** 作 者:		crystal chu
        /// ** 日 期:		2005/07/26/
        /// ** 修 改:
        /// ** 日 期:
        /// ** nunit
        /// </summary>
        /// <param name="actionEventArgs"> </param>
        /// <returns></returns>
        public Messages Execute(ActionEventArgs actionEventArgs)
        {
            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);
            try
            {
                ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
                //检查res在不在OPTS中
                messages.AddMessages(dataCollect.CheckResourceInOperationTS(actionEventArgs));

                //Laws Lu,2006/11/13 uniform system collect date
                DBDateTime dbDateTime;
                //Laws Lu,2006/11/13 uniform system collect date
                if (actionEventArgs.ProductInfo != null && actionEventArgs.ProductInfo.WorkDateTime != null)
                {
                    dbDateTime = actionEventArgs.ProductInfo.WorkDateTime;
                }
                else
                {
                    dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);
                    if (actionEventArgs.ProductInfo != null)
                    {
                        actionEventArgs.ProductInfo.WorkDateTime = dbDateTime;
                    }
                }

                DateTime dtNow = FormatHelper.ToDateTime(dbDateTime.DBDate, dbDateTime.DBTime);
                if (messages.IsSuccess())
                {
                    //Laws Lu,2005/09/16,修改	整理逻辑
                    TSFacade tsFacade = new TSFacade(this.DataProvider);
                    //					if( !tsFacade.IsCardInTS(actionEventArgs.RunningCard))
                    //					{
                    //						messages.Add(new Message(MessageType.Error,"$CSError_Card_Not_In_TS"));
                    //					}
                    //Laws Lu,2005/10/16,在订单1中的已经拆解的产品序列号,
                    //现在系统中可以实现将该产品序列号重新归属到另外一个订单2,
                    //但是该产品序列号在工单2采集完不良后,
                    //作送修作业时,系统提出报错信息:
                    //该产品状态为“拆解”状态。导致该产品序列号无法进行维修。
                    object obj = tsFacade.GetCardLastTSRecordInNewStatus(actionEventArgs.RunningCard);

                    if (obj == null)
                    {
                        //Laws Lu,2006,07/05 Support RMA Repair
                        //						if(actionEventArgs.IsRMA)
                        //						{
                        MOFacade moFAC  = new MOFacade(DataProvider);
                        object   objRMA = moFAC.GetRepairRMARCARDByRcard(actionEventArgs.RunningCard);
                        if (objRMA != null)
                        {
                            #region 新增维修信息

                            RMARCARD     rma = objRMA as RMARCARD;
                            Domain.TS.TS tS  = tsFacade.CreateNewTS();
                            tS.TSId = FormatHelper.GetUniqueID((rma.REWORKMOCODE == String.Empty?rma.RMABILLNO:rma.REWORKMOCODE)
                                                               , actionEventArgs.RunningCard, ActionOnLineHelper.StartSeq.ToString());

                            tS.CardType      = CardType.CardType_Product;;
                            tS.FormTime      = rma.MTIME;
                            tS.FromDate      = rma.MDATE;
                            tS.FromInputType = TSFacade.TSSource_RMA;
                            tS.FromUser      = rma.MUSER;
                            tS.FromMemo      = rma.EATTRIBUTE1;
                            //Laws Lu,2006/07/05 add support RMA
                            tS.RMABillCode = rma.RMABILLNO;
                            //工作时间和工业布局信息

                            //Laws Lu,2005/11/09,新增	记录ShiftDay
                            BaseSetting.BaseModelFacade dataModel = new BaseSetting.BaseModelFacade(this.DataProvider);
                            Domain.BaseSetting.Resource res       = (Domain.BaseSetting.Resource)dataModel.GetResource(actionEventArgs.ResourceCode);
                            //onwip.SegmentCode				= productInfo.NowSimulationReport.SegmentCode;
                            //2006/11/17,Laws Lu add get DateTime from db Server

                            BaseSetting.ShiftModelFacade  shiftModel = new BaseSetting.ShiftModelFacade(this.DataProvider);
                            Domain.BaseSetting.TimePeriod period     = (Domain.BaseSetting.TimePeriod)shiftModel.GetTimePeriod(res.ShiftTypeCode, Web.Helper.FormatHelper.TOTimeInt(dtNow));
                            if (period == null)
                            {
                                throw new Exception("$OutOfPerid");
                            }

                            if (period.IsOverDate == Web.Helper.FormatHelper.TRUE_STRING)
                            {
                                if (period.TimePeriodBeginTime < period.TimePeriodEndTime)
                                {
                                    tS.FromShiftDay = FormatHelper.TODateInt(dtNow.AddDays(-1));
                                }
                                else if (Web.Helper.FormatHelper.TOTimeInt(dtNow) < period.TimePeriodBeginTime)
                                {
                                    tS.FromShiftDay = FormatHelper.TODateInt(dtNow.AddDays(-1));
                                }
                                else
                                {
                                    tS.FromShiftDay = FormatHelper.TODateInt(dtNow);
                                }
                            }
                            else
                            {
                                tS.FromShiftDay = FormatHelper.TODateInt(dtNow);
                            }

                            tS.FromOPCode           = "TS";
                            tS.FromResourceCode     = actionEventArgs.ResourceCode;
                            tS.FromRouteCode        = String.Empty;
                            tS.FromSegmentCode      = res.SegmentCode;
                            tS.FromShiftCode        = period.ShiftCode;                     /*Laws Lu,2006/03/11 修正班次填写有误*/
                            tS.FromShiftTypeCode    = period.ShiftTypeCode;
                            tS.FromStepSequenceCode = res.StepSequenceCode;
                            tS.FromTimePeriodCode   = period.TimePeriodCode;

                            tS.ItemCode     = rma.ITEMCODE;
                            tS.MaintainDate = FormatHelper.TODateInt(dtNow);
                            tS.MaintainTime = FormatHelper.TOTimeInt(dtNow);
                            tS.MaintainUser = actionEventArgs.MaintainUser;

                            tS.MOCode              = (rma.REWORKMOCODE == String.Empty?rma.RMABILLNO:rma.REWORKMOCODE);
                            tS.ModelCode           = rma.MODELCODE;
                            tS.RunningCard         = actionEventArgs.RunningCard;
                            tS.RunningCardSequence = ActionOnLineHelper.StartSeq;
                            tS.SourceCard          = actionEventArgs.RunningCard;
                            tS.SourceCardSequence  = ActionOnLineHelper.StartSeq;
                            tS.TransactionStatus   = TSFacade.TransactionStatus_None;

                            tS.TranslateCard         = actionEventArgs.RunningCard;
                            tS.TranslateCardSequence = ActionOnLineHelper.StartSeq;
                            //tS.TSStatus = TSStatus.TSStatus_New;

                            tS.Week    = (new ReportHelper(DataProvider)).WeekOfYear(tS.FromShiftDay.ToString());
                            tS.Month   = int.Parse(tS.FromShiftDay.ToString().Substring(4, 2));
                            tS.TSTimes = ActionOnLineHelper.StartNGTimes;

                            tS.ConfirmUser         = actionEventArgs.UserCode;
                            tS.ConfirmDate         = FormatHelper.TODateInt(dtNow);
                            tS.ConfirmTime         = FormatHelper.TOTimeInt(dtNow);
                            tS.ConfirmOPCode       = "TS";
                            tS.ConfirmResourceCode = actionEventArgs.ResourceCode;
                            tS.TSStatus            = TSStatus.TSStatus_Confirm;
                            // Added by Icyer 2007/07/03
                            MO mo = (MO)moFAC.GetMO(tS.MOCode);
                            if (mo != null)
                            {
                                tS.MOSeq = mo.MOSeq;
                            }
                            // Added end

                            tsFacade.AddTS(tS);
                            //Laws Lu,2006/07/07 add ,Success release than delete rma
                            moFAC.DeleteRMARCARD(rma);
                            #endregion
                        }
                        else
                        {
                            messages.Add(new Message(MessageType.Error, "$CSError_Card_Not_In_TS_OR_Status_Error"));
                        }
                        //						}
                        //						else
                        //						{
                        //							messages.Add(new Message(MessageType.Error,"$CSError_Card_Not_In_TS_OR_Status_Error"));
                        //						}
                    }
                    else
                    {
                        BenQGuru.eMES.Domain.TS.TS ts = (BenQGuru.eMES.Domain.TS.TS)obj;

                        if (ts.TSStatus == TSStatus.TSStatus_New)
                        {
                            ts.ConfirmUser         = actionEventArgs.UserCode;
                            ts.ConfirmDate         = FormatHelper.TODateInt(dtNow);
                            ts.ConfirmTime         = FormatHelper.TOTimeInt(dtNow);
                            ts.ConfirmOPCode       = "TS";
                            ts.ConfirmResourceCode = actionEventArgs.ResourceCode;
                            ts.TSStatus            = TSStatus.TSStatus_Confirm;

                            //added by jessie lee, 2005/11/24,
                            ts.MaintainUser = actionEventArgs.MaintainUser;
                            ts.MaintainDate = FormatHelper.TODateInt(dtNow);
                            ts.MaintainTime = FormatHelper.TOTimeInt(dtNow);

                            tsFacade.UpdateTSConfirmStatus(ts);
                        }
                        else
                        {
                            messages.Add(new Message(MessageType.Error, "$CSError_Card_TSStatus_Error $Current_Status $" + ts.TSStatus));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                messages.Add(new Message(e));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }