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 LotOPerate(string lotStatus, bool isForce) { Messages msg = new Messages(); bool isFrozen = false; string oqcLotNo = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.ucLabelEditLotNo.Value)); ActionFactory actionFactory = new ActionFactory(this.DataProvider); OQCFacade oqcFacade = new OQCFacade(this.DataProvider); //获取OQCLot以及逻辑检查 object obj = null; msg.AddMessages(GetOQCLotToOperate(oqcFacade, oqcLotNo, out obj)); if (!msg.IsSuccess()) { ApplicationRun.GetInfoForm().Add(msg); this.ucLabelEditLotNo.TextFocus(false, true); return; } //其他检查 if (lotStatus == OQCLotStatus.OQCLotStatus_Reject) { if (this.ucLabelEditStatusMemo.Value.Trim().Length == 0) { msg.Add(new UserControl.Message(MessageType.Error, "$CS_PleaseInputMemo")); ApplicationRun.GetInfoForm().Add(msg); this.ucLabelEditStatusMemo.TextFocus(false, true); return; } } string msgInfo = String.Empty; if (lotStatus == OQCLotStatus.OQCLotStatus_Pass) { if (isForce) { msgInfo = UserControl.MutiLanguages.ParserMessage("$CS_CONFIRM_ForcePassLot"); } else { msgInfo = UserControl.MutiLanguages.ParserMessage("$CS_CONFIRM_LOT_PASS"); } } else { if (isForce) { msgInfo = UserControl.MutiLanguages.ParserMessage("$CS_CONFIRM_ForceRejectLot"); } else { msgInfo = UserControl.MutiLanguages.ParserMessage("$CS_CONFIRM_LOT_RJECT"); } } frmDialog dialog = new frmDialog(); dialog.Text = this.Text; dialog.DialogMessage = msgInfo; if (DialogResult.OK != dialog.ShowDialog(this)) { return; } //add by roger xue 2008/10/27 OQCLot objFrozen = obj as OQCLot; if (objFrozen.FrozenStatus == FrozenStatus.STATUS_FRONZEN) { isFrozen = true; FFrozenReason frozenReason = new FFrozenReason(); string reason = this.ucLabelEditStatusMemo.Value.Trim(); if (reason.Length == 0) { if (lotStatus == OQCLotStatus.OQCLotStatus_Reject) { reason = "批判退"; } else { reason = "批判过"; } } frozenReason.Reason = reason; frozenReason.Event += new ParentChildRelateEventHandler <ParentChildRelateEventArgs <string> >(Form_Event); if (DialogResult.Cancel == frozenReason.ShowDialog(this)) { return; } } //end add // 输入用户名、密码确认 add by alex.hu 2010/11/19 if (isForce) { string strMsg = UserControl.MutiLanguages.ParserString("$SMT_UnLoadAll_Confirm_UserCode"); FDialogInput finput = new FDialogInput(strMsg); DialogResult dialogResult = finput.ShowDialog(); if (dialogResult != DialogResult.OK) { return; } string strUserCode = finput.InputText.Trim().ToUpper(); strMsg = UserControl.MutiLanguages.ParserString("$Please_Input_Password"); finput = new FDialogInput(strMsg); finput.InputPasswordChar = '*'; dialogResult = finput.ShowDialog(); if (dialogResult != DialogResult.OK) { return; } string strPassword = finput.InputText.Trim().ToUpper(); finput.Close(); BenQGuru.eMES.Security.SecurityFacade security = new BenQGuru.eMES.Security.SecurityFacade(this.DataProvider); try { object objSec = security.PasswordCheck(strUserCode, strPassword); if (lotStatus == OQCLotStatus.OQCLotStatus_Pass && !security.IsBelongToAdminGroup(strUserCode) && !security.CheckAccessRight(strUserCode, "OQCFORCEPASS")) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_No_Access_Right")); return; } if (lotStatus == OQCLotStatus.OQCLotStatus_Reject && !security.IsBelongToAdminGroup(strUserCode) && !security.CheckAccessRight(strUserCode, "OQCFORCEREJECT")) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_No_Access_Right")); return; } } catch (Exception ex) { Messages msgErr = new Messages(); msgErr.Add(new UserControl.Message(ex)); ApplicationRun.GetInfoForm().Add(msgErr); Application.DoEvents(); return; } } //end add //把lotcapacity更新成lotsise一样大小,防止此时有产品在产生工序进入批而产生批判定时整个批无法全部完工的并发问题 by hiro Decimal reallyLotCapacity = ((OQCLot)obj).LotCapacity; this.DataProvider.BeginTransaction(); try { //lock该lot,防止同时对该lot操作产生死锁 oqcFacade.LockOQCLotByLotNO(oqcLotNo); //end oqcFacade.UpdateOQCLotCapacity(((OQCLot)obj).LOTNO, ((OQCLot)obj).LotSize); this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); ApplicationRun.GetInfoForm().Add(msg); } if (!msg.IsSuccess()) { return; } //end add //缓解性能问题 ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false; ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection(); DataProvider.BeginTransaction(); try { //lock该lot,防止同时对该lot操作产生死锁 oqcFacade.LockOQCLotByLotNO(oqcLotNo); // msg.AddMessages(GetOQCLotToOperate(oqcFacade, oqcLotNo, out obj)); if (!msg.IsSuccess()) { return; } #region 业务逻辑 ActionOnLineHelper actinOnlineHelper = new ActionOnLineHelper(this.DataProvider); object[] objs = (new ActionOQCHelper(this.DataProvider)).QueryCardOfLot(FormatHelper.PKCapitalFormat(oqcLotNo), OQCFacade.Lot_Sequence_Default); if (objs == null) { msg.Add(new UserControl.Message(MessageType.Error, "$CS_LOT_NOT_EXIST")); return; } // Added By Hi1/Venus.Feng on 20081111 for Hisense : 根据产生批的资源获取该资源对应的大线的最后一个工序的资源(取一个) //string rightResource = (new BaseModelFacade(this.DataProvider)).GetRightResourceForOQCOperate(objFrozen.ResourceCode, // (objs[0] as Simulation).ItemCode, (objs[0] as Simulation).RouteCode); //if (string.IsNullOrEmpty(rightResource)) //{ // msg.Add(new UserControl.Message(MessageType.Error, "$Error_NoBigLineFQCResource")); // return; //} string rightResource = ApplicationService.Current().ResourceCode; // End Added //对批通过的处理 if (lotStatus == OQCLotStatus.OQCLotStatus_Pass) { IAction actionPass = actionFactory.CreateAction(ActionType.DataCollectAction_OQCPass); OQCPASSEventArgs actionEventArgs = new OQCPASSEventArgs(ActionType.DataCollectAction_OQCPass, ((Domain.DataCollect.Simulation)objs[0]).RunningCard, ApplicationService.Current(). UserCode, rightResource, oqcLotNo, null); actionEventArgs.Lot = obj; actionEventArgs.CardOfLot = objs; actionEventArgs.IsForcePass = isForce; actionEventArgs.Memo = FormatHelper.CleanString(this.ucLabelEditStatusMemo.Value.Trim(), 100); //frozen operate actionEventArgs.IsUnFrozen = isFrozen; actionEventArgs.UnFrozenReason = this.frozenReason; msg.AddMessages(actionPass.Execute(actionEventArgs)); if (msg.IsSuccess()) { msg.Add(new UserControl.Message(MessageType.Success, "$CS_OQCPASSSUCCESS")); } } //对批判退的处理 if (lotStatus == OQCLotStatus.OQCLotStatus_Reject) { IAction actionReject = actionFactory.CreateAction(ActionType.DataCollectAction_OQCReject); OQCRejectEventArgs actionEventArgs = new OQCRejectEventArgs(ActionType.DataCollectAction_OQCReject, ((Domain.DataCollect.Simulation)objs[0]).RunningCard, ApplicationService.Current(). UserCode, ApplicationService.Current().ResourceCode, oqcLotNo, null); actionEventArgs.Lot = obj; actionEventArgs.CardOfLot = objs; actionEventArgs.IsForceReject = isForce; actionEventArgs.IsAutoGenerateReworkSheet = this.chkBoxAutoGenerate.Checked; actionEventArgs.IsCreateNewLot = this.checkBoxAutoLot.Checked; actionEventArgs.Memo = FormatHelper.CleanString(this.ucLabelEditStatusMemo.Value.Trim(), 100); //frozen operate actionEventArgs.IsUnFrozen = isFrozen; actionEventArgs.UnFrozenReason = frozenReason; actionEventArgs.rightResource = rightResource; msg.AddMessages(actionReject.Execute(actionEventArgs)); if (msg.IsSuccess()) { msg.Add(new UserControl.Message(MessageType.Success, "$CS_OQCREJECTSUCCESS")); } } #endregion } catch (Exception ex) { this.DataProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); } finally { ApplicationRun.GetInfoForm().Add(msg); if (!msg.IsSuccess()) { this.DataProvider.RollbackTransaction(); this.DataProvider.BeginTransaction(); } obj = oqcFacade.GetOQCLot(((OQCLot)obj).LOTNO, ((OQCLot)obj).LotSequence); if (obj != null) { oqcFacade.UpdateOQCLotCapacity(((OQCLot)obj).LOTNO, reallyLotCapacity); } this.DataProvider.CommitTransaction(); this.ucLabelEditLotNo.TextFocus(false, true); //缓解性能问题 ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection(); ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false; } }