Beispiel #1
0
        private void ucLabelEditRcard_TxtboxKeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                if (string.IsNullOrEmpty(this.ucLabelEditDown.Value.Trim()))
                {
                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditDown.Value + ";" + this.ucLabelEditDown.Value,
                                                       new UserControl.Message(MessageType.Error, "$CS_PleaseInputDownReason"), false);
                    this.ucLabelEditDown.TextFocus(false, true);
                    return;
                }

                if (string.IsNullOrEmpty(this.ucLabelEditRcard.Value.Trim()))
                {
                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditRcard.Value + ";" + this.ucLabelEditRcard.Value,
                                                       new UserControl.Message(MessageType.Error, "$CS_PleaseInputID"), false);
                    this.ucLabelEditRcard.TextFocus(false, true);
                    return;
                }

                //检查事件号是否超出最大范围
                if (!this.CheckDownCodeLimits())
                {
                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, "" + ": " + this.ucLabelEditDownCode.Value,
                                                       new UserControl.Message(MessageType.Error, "$CS_DownCode_Out_Of_Limit"), true);
                    return;
                }


                if (_dataCollectFacade == null)
                {
                    _dataCollectFacade = new DataCollectFacade(this.DataProvider);
                }

                //清除序列号中的特殊字符
                string RunningCard = FormatHelper.CleanString(this.ucLabelEditRcard.Value.Trim().ToUpper());

                //根据当前序列号获取产品最原始的序列号
                DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
                string            sourceRCard       = dataCollectFacade.GetSourceCard(RunningCard, string.Empty);

                //判断序列号在生产信息中是否存在,同时获取rcard
                object objectRcard = _dataCollectFacade.GetRcardFromSimulationReport(sourceRCard);
                if (objectRcard == null)
                {
                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditRcard.Value + ";" + this.ucLabelEditRcard.Value,
                                                       new UserControl.Message(MessageType.Error, "$CS_RcardInput_Wrong $NoProductInfo"), false);
                    this.ucLabelEditRcard.TextFocus(false, true);
                    return;
                }

                //判断序列号在生产信息中是否存在,同时获取simulation
                object objectSimulationReport = _dataCollectFacade.GetLastSimulationReport(((SimulationReport)objectRcard).RunningCard.Trim().ToUpper());
                if (objectSimulationReport == null)
                {
                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditRcard.Value + ";" + this.ucLabelEditRcard.Value,
                                                       new UserControl.Message(MessageType.Error, "$CS_RcardInput_Wrong $NoProductInfo"), false);
                    this.ucLabelEditRcard.TextFocus(false, true);
                    return;
                }

                //判断序列号在此事件号中是否重负
                object objectDown = _dataCollectFacade.GetDown(FormatHelper.CleanString(this.ucLabelEditDownCode.Value.ToUpper()), ((SimulationReport)objectRcard).RunningCard.Trim().ToUpper());
                if (objectDown != null)
                {
                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditRcard.Value + ";" + this.ucLabelEditRcard.Value,
                                                       new UserControl.Message(MessageType.Error, "$Error_CS_ID_Already_Exist_INHERE"), false);
                    this.ucLabelEditRcard.TextFocus(false, true);
                    return;
                }

                //判断序列号在其他事件号中是否存在
                object[] objectDownList = _dataCollectFacade.QueryDownByRcard(((SimulationReport)objectRcard).RunningCard.Trim().ToUpper());
                if (objectDownList != null)
                {
                    for (int i = 0; i < objectDownList.Length; i++)
                    {
                        if (((Down)objectDownList[i]).DownCode != this.ucLabelEditDownCode.Value && ((Down)objectDownList[i]).DownStatus == DownStatus.DownStatus_Down)
                        {
                            ApplicationRun.GetInfoForm().AddEx(this._FunctionName, RunningCard + ";" + RunningCard,
                                                               new UserControl.Message(MessageType.Error, "$Error_CS_ID_Already_Exist_INOther :" + ((Down)objectDownList[0]).DownCode), false);
                            this.ucLabelEditRcard.TextFocus(false, true);
                            return;
                        }
                    }
                }

                //下地号与下地原因没有关系,新建下地号
                object[] objectDowns = _dataCollectFacade.QueryDown(FormatHelper.CleanString(this.ucLabelEditDownCode.Value.ToUpper()), FormatHelper.CleanString(this.ucLabelEditDown.Value.Trim().ToUpper()));
                if (objectDowns == null)
                {
                    this.ToCreateDownCode();
                }

                //检查事件号是否超出最大范围
                if (!this.CheckDownCodeLimits())
                {
                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, "" + ": " + this.ucLabelEditDownCode.Value,
                                                       new UserControl.Message(MessageType.Error, "$CS_DownCode_Out_Of_Limit"), true);
                    return;
                }

                BaseSetting.BaseModelFacade baseModelFacade = new BaseModelFacade(this.DataProvider);
                object     objectRes     = baseModelFacade.GetResource(ApplicationService.Current().ResourceCode.ToUpper());
                string     SSCode        = ((Domain.BaseSetting.Resource)objectRes).StepSequenceCode;
                DBDateTime NowDBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);

                this.DataProvider.BeginTransaction();
                try
                {
                    Down NewDown = _dataCollectFacade.CreateNewDown();

                    NewDown.DownCode      = FormatHelper.CleanString(this.ucLabelEditDownCode.Value.Trim());
                    NewDown.RCard         = ((SimulationReport)objectRcard).RunningCard.Trim().ToUpper();
                    NewDown.MOCode        = ((SimulationReport)objectSimulationReport).MOCode;
                    NewDown.ModelCode     = ((SimulationReport)objectSimulationReport).ModelCode;
                    NewDown.ItemCode      = ((SimulationReport)objectSimulationReport).ItemCode;
                    NewDown.SSCode        = SSCode.Trim().ToUpper();
                    NewDown.ResCode       = ApplicationService.Current().ResourceCode;
                    NewDown.DownStatus    = DownStatus.DownStatus_Down;
                    NewDown.DownReason    = FormatHelper.CleanString(this.ucLabelEditDown.Value.Trim());
                    NewDown.DownDate      = NowDBDateTime.DBDate;
                    NewDown.DownShiftDate = NowDBDateTime.DBDate;
                    NewDown.DownTime      = NowDBDateTime.DBTime;
                    NewDown.DownBy        = ApplicationService.Current().UserCode;
                    NewDown.UPReason      = string.Empty;
                    NewDown.ORGID         = GlobalVariables.CurrentOrganizations.First().OrganizationID;
                    NewDown.UPBY          = string.Empty;
                    NewDown.MaintainUser  = ApplicationService.Current().UserCode;
                    NewDown.MaintainDate  = NowDBDateTime.DBDate;
                    NewDown.MaintainTime  = NowDBDateTime.DBTime;
                    NewDown.EAttribute1   = string.Empty;

                    _dataCollectFacade.AddDown(NewDown);
                }
                catch (Exception ex)
                {
                    this.DataProvider.RollbackTransaction();
                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditRcard.Value + ";" + this.ucLabelEditRcard.Value,
                                                       new UserControl.Message(ex), false);
                }
                finally
                {
                    this.DataProvider.CommitTransaction();
                    this.ucLblEditNumber.Value = Convert.ToString(System.Int32.Parse(this.ucLblEditNumber.Value.Trim()) + 1);
                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditRcard.Value + ";" + this.ucLabelEditRcard.Value,
                                                       new UserControl.Message(MessageType.Success, "$CS_DownIsSuccess $CS_Param_RunSeq:" + ((SimulationReport)objectRcard).RunningCard.Trim().ToUpper()), false);
                }
                //同步Grid
                this.QueryORUpdateGrid();
                this.ucLabelEditRcard.TextFocus(false, true);
            }
        }