질문이 있으십니까?

기본 컨텐츠 및 사용자가 직접 참여하여 만들어진 다양한 내용을 검색합니다.

C# 닷넷 샘플코드

C# 소스상의 메소드는 btnApproval_Click() 입니다.
소스코드상에 C# 파일은 ModuleViewer.cs 입니다.

전자결재 상신 Click

private void btnApproval_Click(object sender, EventArgs e)
        {
            if (base.viewDBSaveMode == enumDef.DBSaveMode.CreateMode)
            {
                uniBase.UMessage.DisplayMessageBox("202533", MessageBoxButtons.OK, ""); //%1 먼저 저장하십시요
                return;
            }

            DialogResult iDialogResult = DialogResult.None;
            iDialogResult = uniBase.UMessage.DisplayMessageBox("DT9999", MessageBoxButtons.YesNo, "결재상신 하시겠습니까? "); //
            //상신 작업을 하시겠습니까?
            if (iDialogResult == DialogResult.No)
            {
                return;
            }

            //결재버튼 클릭시 결재연동 테이블의 결재상태값 확인후 결제중이거나 완료된 정보가 있으면 재상신 불가토록 차단함
            string strSelect1 = string.Format(@"  SELECT ISNULL(GW_STATUS, 'N') AS GW_STATUS  FROM dbo.A_TEMP_GL   WHERE  TEMP_GL_NO ={0} "
          , uniBase.UCommon.FilterVariable(popGlNo.CodeValue.ToString(), "''", enumDef.FilterVarType.BraceWithSingleQuotation, true));
            DataSet dsResults1 = uniBase.UDataAccess.CommonQuerySQL(strSelect1);
            if (dsResults1 == null || dsResults1.Tables.Count == 0 || dsResults1.Tables[0].Rows.Count == 0)
            {
            }
            else
            {
                switch (dsResults1.Tables[0].Rows[0]["GW_STATUS"].ToString())
                {
                    case "Q"://상신중 
                    case "Y"://결재완료
                    case "T": //반려
                        uniBase.UMessage.DisplayMessageBox("DT9999", MessageBoxButtons.OK, "결재상태를 확인하십시오");
                        return;
                        break;
                    default:

                        break;
                }
            }
uniBase.UProcess.DisplayProgressBar();
            try
            {
                string strurl = string.Empty;//호출 URL
                string strAuthKey = string.Empty; //발급받은 인증키,header로 전송
                string strargFormNo = string.Empty; //ERP에서 지정한 고유한 문서번호ID

                SqlDbType xVarCharType = uniBase.UDatabase.XVarCharType;
                uniCommand iuniCommand = uniBase.UDatabase.GetStoredProcCommand("USP_GW_APPR_ERP");
                uniBase.UDatabase.AddInParameter(iuniCommand, "@TEMP_GL_NO", SqlDbType.NVarChar, popGlNo.CodeValue.ToString());
                uniBase.UDatabase.AddInParameter(iuniCommand, "@USR_ID", SqlDbType.NVarChar, CommonVariable.gUsrID);
                uniBase.UDatabase.AddOutParameter(iuniCommand, "@MSG_CD", SqlDbType.NVarChar, 6);
                uniBase.UDatabase.AddOutParameter(iuniCommand, "@MSG_NM", SqlDbType.NVarChar, 200);
                uniBase.UDatabase.AddReturnParameter(iuniCommand, "RETURN_VALUE", SqlDbType.Int, 1);

                uniBase.UDatabase.ExecuteDataSet(iuniCommand);
                int iIntRetCD = (int)uniBase.UDatabase.GetParameterValue(iuniCommand, "RETURN_VALUE");
                if (iIntRetCD == 1)
                {
                    dsResults1 = null;
                    strSelect1 = string.Format(@" SELECT REFERENCE  FROM dbo.B_CONFIGURATION  WHERE MAJOR_CD ='FZZ04'  AND MINOR_CD ='00' AND SEQ_NO = 0

                                            SELECT REFERENCE  FROM dbo.B_CONFIGURATION  WHERE MAJOR_CD ='FZZ04'  AND MINOR_CD ='00' AND SEQ_NO = 1

                                           SELECT REFERENCE  FROM dbo.B_CONFIGURATION  WHERE MAJOR_CD ='FZZ04'  AND MINOR_CD ='FI' AND SEQ_NO = 0 ");
                    dsResults1 = uniBase.UDataAccess.CommonQuerySQL(strSelect1);
                    if (dsResults1 != null && dsResults1.Tables.Count > 0)
                    {
                        strurl = dsResults1.Tables[0].Rows[0][0].ToString();
                        strAuthKey = dsResults1.Tables[1].Rows[0][0].ToString();
                        strargFormNo = dsResults1.Tables[2].Rows[0][0].ToString();
                    }

     
                    WebClient web = new WebClient();
                    NameValueCollection POST = new NameValueCollection();

                    web.Headers.Add("AuthKey", strAuthKey);
                    POST["argErpUserID"] = CommonVariable.gUsrID.ToString();
                    POST["argFormNo"] = strargFormNo;
                    POST["argErpDocKey"] = popGlNo.CodeValue.ToString();
                    POST["argCallbackErpEventUrl"] = "callbackerpeventurl?arg1={1}&arg2={2}&arg3={3}&arg4={4}"; //하드코딩(그룹웨어에서 호출될 이벤트 콜백URL)
                    POST["argDocSubject"] = txtDesc.Text;                                                       //그룹웨어에서 수정가능함
                    POST["argBodyHtml"] = "pgm://";                                                             //pgm:// ==> 그룹웨어에서 HTML을 만든다는 의미 
                    POST["argCallbackErpResultUrl"] = "callbackerpreturnurl?arg1={1}&arg2={2}&arg3={3}&arg4={4}";//하드코딩
   
     
                    var response = web.UploadValues(strurl, "POST", POST);
                    string responsebody = Encoding.UTF8.GetString(response);
                    JsonRetunData JsonRetunData = JsonConvert.DeserializeObject<JsonRetunData>(responsebody);
                    if (JsonRetunData.ErrCode.ToString() != "0")
                    {
                        uniBase.UMessage.DisplayMessageBox("DT9999", MessageBoxButtons.OK, "상신작업에 실패했습니다(" + JsonRetunData.Message.ToString() + ").");
                        uniBase.UProcess.HideProgressBar();
                        return;
                    }
                    string vUrl = System.Web.HttpUtility.UrlDecode(JsonRetunData.zurl);
                    System.Diagnostics.Process.Start(vUrl);

                    this.TakeVirgin();
                    uniBase.UProcess.HideProgressBar();
                    if (OnFncQuery())
                    {
                        OnPostFncQuery();
                    }
                }
else
                {
                    string sMsgCd = uniBase.UDatabase.GetParameterValue(iuniCommand, "@MSG_CD") as string;
                    string sMessage = uniBase.UDatabase.GetParameterValue(iuniCommand, "@MSG_NM") as string;
                    if (sMsgCd != "")
                    {
                        uniBase.UMessage.DisplayMessageBox(sMsgCd, MessageBoxButtons.OK, sMessage);
                    }
                    else
                    {
                        uniBase.UMessage.DisplayMessageBox("W70001", MessageBoxButtons.OK, "상신작업에 실패했습니다.");
                    }
                    uniBase.UProcess.HideProgressBar();
                }
            }
            catch (Exception ex)
            {
                uniBase.UMessage.DisplayMessageBox("dt9999", MessageBoxButtons.OK, ex.Message.ToString());
                return;
            }

        }

문서 View Click

private void btnApproval_View_Click(object sender, EventArgs e)
        {

            string strurl = string.Empty;//호출 URL
            string strAuthKey = string.Empty; //발급받은 인증키,header로 전송
            string argGwDocKey = string.Empty; //gw고유한 문서번호ID

            //결재버튼 클릭시 결재연동 테이블의 결재상태값 확인후 결제중이거나 완료된 정보가 있으면 재상신 불가토록 차단함
            string strSelect1 = string.Format(@"  SELECT ISNULL(GW_STATUS, 'N') AS GW_STATUS , ISNULL(GW_NO, '') AS GW_NO  FROM dbo.A_TEMP_GL   WHERE  TEMP_GL_NO ={0} "
          , uniBase.UCommon.FilterVariable(popGlNo.CodeValue.ToString(), "''", enumDef.FilterVarType.BraceWithSingleQuotation, true));
            DataSet dsResults1 = uniBase.UDataAccess.CommonQuerySQL(strSelect1);
            if (dsResults1 == null || dsResults1.Tables.Count == 0 || dsResults1.Tables[0].Rows.Count == 0)
            {
            }
            else
            {
                if (dsResults1.Tables[0].Rows[0]["GW_NO"].ToString() == "")
                {
                    uniBase.UMessage.DisplayMessageBox("DT9999", MessageBoxButtons.OK, "결재상태를 확인하십시오");
                    return;
                }
                argGwDocKey = dsResults1.Tables[0].Rows[0]["GW_NO"].ToString();
            }

            uniBase.UProcess.DisplayProgressBar();

            dsResults1 = null;
            strSelect1 = string.Format(@" SELECT REFERENCE  FROM dbo.B_CONFIGURATION  WHERE MAJOR_CD ='FZZ04'  AND MINOR_CD ='01' AND SEQ_NO = 0

                                            SELECT REFERENCE  FROM dbo.B_CONFIGURATION  WHERE MAJOR_CD ='FZZ04'  AND MINOR_CD ='01' AND SEQ_NO = 1");
            dsResults1 = uniBase.UDataAccess.CommonQuerySQL(strSelect1);
            if (dsResults1 != null && dsResults1.Tables.Count > 0)
            {
                strurl = dsResults1.Tables[0].Rows[0][0].ToString();
                strAuthKey = dsResults1.Tables[1].Rows[0][0].ToString();
            }

            try
            {
                WebClient web = new WebClient();
                NameValueCollection POST = new NameValueCollection();
                web.Headers.Add("AuthKey", strAuthKey);
                POST["argErpDocKey"] = popGlNo.CodeValue.ToString();
                POST["argGwDocKey"] = argGwDocKey;      //gw문서번호
                POST["argViewGubun"] = "screen";                                                             //

                var response = web.UploadValues(strurl, "POST", POST);
                string responsebody = Encoding.UTF8.GetString(response);
                JsonRetunData JsonRetunData = JsonConvert.DeserializeObject<JsonRetunData>(responsebody);
                if (JsonRetunData.ErrCode.ToString() != "0")
                {
                    uniBase.UMessage.DisplayMessageBox("DT9999", MessageBoxButtons.OK, "결재문서보기에 실패했습니다(" + JsonRetunData.Message.ToString() + ").");
                    uniBase.UProcess.HideProgressBar();
                    return;
                }
                string vUrl = System.Web.HttpUtility.UrlDecode(JsonRetunData.zurl);
                System.Diagnostics.Process.Start(vUrl);

                this.TakeVirgin();
                uniBase.UProcess.HideProgressBar();
            }
            catch (Exception ex)
            {
                uniBase.UMessage.DisplayMessageBox("dt9999", MessageBoxButtons.OK, ex.Message.ToString());
                return;
            }
            finally
            {
                uniBase.UProcess.HideProgressBar();
            }
        }
    }

댓글을 작성하세요

문서 이력

  • 2024-02-28 날짜로 신달수 님으로 부터 컨텐츠명이 변경 되었습니다.