private void ucButtonOK_Click(object sender, EventArgs e) { if (this.ucLabelEditTotal.Value.Trim() == string.Empty || this.ucLabelEditTotal.Value.Trim() == "0") { return; } if (this.ucLabelEditSelected.Value.Trim() == string.Empty || this.ucLabelEditSelected.Value.Trim() == "0") { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Normal, "$Error_NoDataSelected")); this.ucLabelEditRCardEdit.TextFocus(false, true); return; } if (this.ucLabelEditUpReason.Value.Trim().Length == 0) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Normal, "$Error_PleaseInputUPReason")); this.ucLabelEditUpReason.TextFocus(false, true); return; } frmDialog dialog = new frmDialog(); dialog.Owner = this; dialog.Text = this.Text; dialog.DialogMessage = UserControl.MutiLanguages.ParserMessage("$Are_You_Sure_To_Do_UP"); if (DialogResult.OK != dialog.ShowDialog()) { return; } Messages msg = new Messages(); ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false; ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection(); DataProvider.BeginTransaction(); try { string rcard = ""; string downCode = ""; Down down; DataCollectFacade dcf = new DataCollectFacade(this.DataProvider); DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); for (int i = 0; i < this.ultraGridRCardList.Rows.Count; i++) { if (string.Compare(this.ultraGridRCardList.Rows[i].Cells["Checked"].Value.ToString(), "true", true) == 0) { rcard = this.ultraGridRCardList.Rows[i].Cells["RCard"].Value.ToString(); downCode = this.ultraGridRCardList.Rows[i].Cells["DownCode"].Value.ToString(); down = dcf.GetDown(downCode, rcard) as Down; if (down == null) { throw new Exception("$Error_DownNotExist $EventCode=" + downCode + " $CS_Param_ID=" + rcard); } if (down.DownStatus == DownStatus.DownStatus_Up) { throw new Exception("$Error_AlreadyUp $EventCode=" + downCode + " $CS_Param_ID=" + rcard); } down.DownStatus = DownStatus.DownStatus_Up; down.UPReason = FormatHelper.CleanString(this.ucLabelEditUpReason.Value.Trim(), 100); down.UPDATE_ = currentDateTime.DBDate; down.UPTIME = currentDateTime.DBTime; down.UPBY = ApplicationService.Current().UserCode; down.MaintainDate = currentDateTime.DBDate; down.MaintainTime = currentDateTime.DBTime; down.MaintainUser = ApplicationService.Current().UserCode; dcf.UpdateDown(down); } } ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_UPSuccess")); DataProvider.CommitTransaction(); this.ReloadData(); this.checkBoxSelectAll.Checked = false; this.ucLabelEditUpReason.Value = ""; if (this.ultraGridRCardList.Rows.Count > 0) { this.ucLabelEditRCardEdit.TextFocus(true, true); } } catch (Exception ex) { DataProvider.RollbackTransaction(); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, ex.Message)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection(); ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false; } }
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); } }