Ejemplo n.º 1
0
    private void SPMAfterSend_DBIO(SPMTaskVariables SPMTaskVars, EFFormFields FormFields, ref IInterfaceHandleResult HandleResult, SPMRoutingVariable RoutingVariable, SPMVariables Variables)
    {
        try
        {
            string stepName = (string)SPMTaskVars.ReadDatum("STEPNAME");
            int    caseID   = int.Parse((string)(SPMTaskVars.ReadDatum("CASEID")));


            switch (RoutingVariable.Key)
            {
            //if Reject,Post Back To SAP
            case SPMRoutingVariableKey.spm_Return:
                try
                {
                    PostBackToSAP(SPMTaskVars, FormFields, Variables, "R");
                    oStandard.UpdateFormStatus(caseID, "Reject");
                }
                catch (Exception ex)
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = ex.Message;
                }
                break;

            case SPMRoutingVariableKey.spm_Jump:
                string curDOA  = FormFields["txtDOA".ToUpper()].Replace("&lt1;", "<").Replace("&gt1;", ">");
                string curStep = SPMAppLine.GetCurrentStep(curDOA);
                //最後一關結束 將結果拋到DB中 並更新STATUS欄位為 Approve
                if (curStep == "*")
                {
                    try
                    {
                        //  IF APPROVE ,POST BACK TO SAP and Update Form Status Approve
                        PostBackToSAP(SPMTaskVars, FormFields, Variables, "A");
                        oStandard.UpdateFormStatus(caseID, "Approve");
                    }
                    catch (Exception ex)
                    {
                        HandleResult.IsSuccess     = false;
                        HandleResult.CustomMessage = ex.Message;
                    }
                }
                break;
            }
        }
        catch (Exception e)
        {
            HandleResult.IsSuccess     = false;
            HandleResult.CustomMessage = e.Message;
        }
    }
Ejemplo n.º 2
0
    // Validate contols before submit
    public override bool EFFormFieldsValidation(SPMSubmitMethod SubmitMethod, SPMProcessMethod ProcessMethod, SPMTaskVariables SPMTaskVars, ref IInterfaceHandleResult HandleResult, object oContainer, IUIShadow UIShadow)
    {
        GDSExceptionHandlingUIShadow lUIControls = (GDSExceptionHandlingUIShadow)UIShadow;
        GDS_Helper    oStandard = new GDS_Helper();
        StringBuilder ErrMsg    = new StringBuilder();


        string stepName = (string)(SPMTaskVars.ReadDatum("STEPNAME"));
        string curDOA   = lUIControls.txtDOA.Text;
        string plant    = lUIControls.txtWERKS.Text;
        string apType   = lUIControls.txtAPTYP.Text;

        DOA    spmDOA     = new DOA();
        string sApplicant = lUIControls.txtApplication.Text.Trim();
        //獲取 表頭及表身DATA
        string    formDetail = lUIControls.txtDetail.Text.Trim().Replace("&lt1;", "<").Replace("&gt1;", ">");
        string    formHead   = lUIControls.txtHead.Text.Trim().Replace("&lt1;", "<").Replace("&gt1;", ">");
        DataTable dtHead     = LiteOn.GDS.Utility.Tools.BuildHeadTable();

        System.IO.StringReader reader = new System.IO.StringReader(formHead);
        dtHead.ReadXml(reader);
        System.IO.StringReader reader2 = new System.IO.StringReader(formDetail);
        DataTable dtDetail             = LiteOn.GDS.Utility.Tools.BuildDetailTable();

        dtDetail.ReadXml(reader2);
        if (SubmitMethod == SPMSubmitMethod.CreateNewCase)
        {
            #region 欄位的非空驗證

            #endregion

            #region Check單據是否已經過帳
            string I1DocNo = oUIControls.txtRDocNo.Text;
            string IADocNo = oUIControls.txtIADocNo.Text;
            string I6DocNo = oUIControls.txtI6DocNo.Text;
            string WERKS   = oUIControls.txtWERKS.Text;
            //Check此I1單(領料單)和關聯的IA,I6單(退料單)是否都已經過賬 (Call SAP BAPI Z_BAPI_GDS_SEND MBLNR不為空則表示已經過賬)
            if (!oStandard.CheckFormNoIsPass(I1DocNo, IADocNo, I6DocNo, WERKS))
            {
                HandleResult.IsSuccess     = false;
                HandleResult.CustomMessage = "I1(領料單)或者IA,I6(退料單)存在未過賬的單子!";
            }
            #endregion
        }
        else
        {
            //only  approve action check controls
            if (SubmitMethod == SPMSubmitMethod.HandleCase_Approve)
            {
                int    caseId    = int.Parse((string)(SPMTaskVars.ReadDatum("CASEID")));
                string curStepId = SPMAppLine.GetCurrentStep(curDOA);
                //調用FUNCTION作FormFieldsValidation
                string errMsg = DOA.FieldsValidationByStepId(plant, apType, curStepId, caseId);
                if (errMsg.Length > 0)
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = errMsg;
                }
                else
                {
                    try
                    {
                        //CALL FUNCTION獲取下關簽核人
                        DOAHandler = spmDOA.GetStepHandler(sApplicant, curDOA, dtHead, dtDetail, false);
                        oStandard.UpdateSettingxml(oUIControls.txtDocNo.Text, DOAHandler._sDOA.ToString());
                    }
                    catch (Exception ex)
                    {
                        HandleResult.IsSuccess     = false;
                        HandleResult.CustomMessage = ex.Message;
                    }
                }

                if (ErrMsg.ToString().Length > 0)
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = ErrMsg.ToString();
                }

                //簽核人防呆檢查
                if (DOAHandler._sEndFlag == "N" && DOAHandler._sHandler.Length == 0)
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = "Can't find next step handler, pls contact sys administrator";
                }
                string sCurLogonID  = (string)(SPMTaskVars.ReadDatum("SYS_LOGONID"));
                string sCurRoleCode = SPMAppLine.GetCurrentApprover(curDOA).Replace("{", "").Replace("}", "");

                //簽核人重復簽核防呆
                if (DOAHandler._sEndFlag == "N" && DOAHandler._sRoleCode == sCurRoleCode && DOAHandler._sHandler.ToUpper() == sCurLogonID.ToUpper())
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = "Server or network is busy now, pls try again";
                }
            }
        }
        return(base.EFFormFieldsValidation(SubmitMethod, ProcessMethod, SPMTaskVars, ref HandleResult, oContainer, UIShadow));
    }