Exemple #1
0
        private void ucButton2_Click(object sender, EventArgs e)
        {
            Messages messages = new Messages();

            if (rCardEditor.Text.Trim() == String.Empty)
            {
                messages.Add(new UserControl.Message(MessageType.Error, "$CSError_RCard_CanNot_Empty"));
                ApplicationRun.GetInfoForm().Add(messages);
                return;
            }

            DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
            string            sourceRCard       = dataCollectFacade.GetSourceCard(rCardEditor.Text.Trim().ToUpper(), string.Empty);

            string tsStatus;
            //Laws Lu,2005/11/22,新增	添加代理录入人员
            //modified by jessie lee, 2005/11/24
            string userCode = ApplicationService.Current().UserCode;

            if (txtAgentUser.Checked == true && txtAgentUser.Value.Trim().Length == 0)
            {
                messages.Add(new UserControl.Message(MessageType.Error, "$CS_Error_Vicegerent_CanNot_Empty"));
                ApplicationRun.GetInfoForm().Add(messages);
                return;
            }
            else if (txtAgentUser.Checked == true && txtAgentUser.Value != String.Empty)
            {
                if ((new BenQGuru.eMES.Security.SecurityFacade(this.DataProvider)).CheckResourceRight(txtAgentUser.Value.Trim().ToUpper()
                                                                                                      , ApplicationService.Current().ResourceCode))
                {
                    userCode = txtAgentUser.Value;
                }
                else
                {
                    messages.Add(new UserControl.Message(MessageType.Error, "$CS_Error_Vicegerent_Is_Wrong"));
                    ApplicationRun.GetInfoForm().Add(messages);
                    return;
                }
            }

            if (ultraCheckEditor1.Checked == true)
            {
                tsStatus = TSStatus.TSStatus_Reflow;

                //勾选回流,然后不工位栏位未选资料也可允许通过。在业务上回流是一定有确定的工位的。
                //系统要检查此时保存,工位是否为空。
                if (ucLabComboxOPCode.SelectedItemText == string.Empty)
                {
                    messages.Add(new UserControl.Message(MessageType.Error, "$CS_Error_ReflowOPCode_CanNot_Empty"));
                    ApplicationRun.GetInfoForm().Add(messages);
                    ucLabComboxOPCode.Focus();
                    return;
                }
            }
            else if (ultraCheckEditorScrap.Checked == true)
            {
                tsStatus = TSStatus.TSStatus_Scrap;
            }
            else
            {
                tsStatus = TSStatus.TSStatus_Complete;
//				//修改,Karron Qiu 2005-9-23
//				//线上采集的不良品,修复后则“回流”;修不好则“报废”。而不选“回流”或“报废”代表该产品要入了良品库,
//				//线上的不良品修好后是直接回产线回流,不需要入良品库的
//				messages.Add(new UserControl.Message(MessageType.Error,"$CSError_Please_Select_Reflow_OR_Scrap"));//请选择回流或者报废
//				ApplicationRun.GetInfoForm().Add(messages);
//				return;
            }

            ActionFactory     actionFactory    = new ActionFactory(this.DataProvider);
            IAction           actionTSComplete = actionFactory.CreateAction(ActionType.DataCollectAction_TSComplete);
            TSActionEventArgs actionEventArgs  = new TSActionEventArgs(
                ActionType.DataCollectAction_TSComplete,
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(sourceRCard)),
                userCode,
                ApplicationService.Current().ResourceCode,
                tsStatus,
                this.ucLabEditMOCode.Value,
                this.ucLabEditItemCode.Value,
                this.ucLabEditRoute.Value,
                this.ucLabComboxOPCode.SelectedItemText,
                ApplicationService.Current().UserCode,
                FormatHelper.CleanString(this.txtScrapCause.Text, 100));

            //修改 Karron Qiu 2005-9-26
            //在做维修完成处理时,依然按照之前的检查逻辑
            //(不良品是否“已选不良零件”或“已选不良位置”有信息),如果没有,则弹出提示信息,
            //比如:“该不良品无“不良零件”或“不良位置”信息,是否要维修完成”,
            //点击“确认”即维修完成,点击“取消”则维修完成失败

            TSFacade tsFacade = new TSFacade(this.DataProvider);
            object   obj      = tsFacade.GetCardLastTSRecord(actionEventArgs.RunningCard);

            if (obj == null)
            {
                messages.Add(new UserControl.Message(MessageType.Error, "$CSError_Card_Not_In_TS"));
                ApplicationRun.GetInfoForm().Add(messages);
                return;
            }
            else
            {
                Domain.TS.TS ts = (Domain.TS.TS)obj;
                if (tsFacade.CheckErrorCodeCountAndErrorSolutionForTSComplete(actionEventArgs.RunningCard))
                {
                    if (!tsFacade.CheckErrorPartAndErrorLocationForTSComplete(actionEventArgs.RunningCard))
                    {
                        if (System.Windows.Forms.MessageBox.Show(null, MutiLanguages.ParserString("$CS_No_ErrorPartAndLoc_Is_Com"), "", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    messages.Add(new UserControl.Message(MessageType.Error, "$CSError_Card_TSStatus_IsNot_TS $Current_Status $" + ts.TSStatus));
                    ApplicationRun.GetInfoForm().Add(messages);
                    return;
                }
            }
            //karron qiu ,2005/9/16 ,增加try catch,在catch中添加rollback操作
            DataProvider.BeginTransaction();
            try
            {
                messages.AddMessages(actionTSComplete.Execute(actionEventArgs));
                if (!messages.IsSuccess())
                {
                    this.DataProvider.RollbackTransaction();
                    ApplicationRun.GetInfoForm().Add(messages);
                }
                else
                {
                    this.DataProvider.CommitTransaction();
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_TSScrap_SUCCESS"));
                }
            }
            catch
            {
                this.DataProvider.RollbackTransaction();
                throw;
            }
            finally
            {
                (DataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection();
            }
        }