public GetPolicyAPLForPayment_Result GetPolicyAPLForPayment(string partnerUsername, string partnerPassword, string policyNumber)
    {
        GetPolicyAPLForPayment_Result obj = new GetPolicyAPLForPayment_Result();
        RefRunningTBBLL runningobj        = new RefRunningTBBLL();

        this.refnum = runningobj.AddRefRunningTBAndReturn();
        WSLogBLL logobj     = new WSLogBLL();
        string   methodName = "GetPolicyAPLForPayment";

        try
        {
            if (partnerUsername == "" || partnerPassword == "" || policyNumber == "")
            {
                this.partnerName = partnerUsername;
                // LogRequest: Insert Log Request
                logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);

                obj.Result = "notcomplete_กรุณาระบุข้อมูลให้ครบถ้วน";
            }
            else if (policyNumber.Trim().Substring(0, 2) == "PA")
            {
                this.partnerName = partnerUsername;
                // LogRequest: Insert Log Request
                logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);

                obj.Result = "notcomplete_กรมธรรม์นี้ไม่มียอดเงินกู้อัตโนมัติ(APL)ให้ชำระ";
            }
            else if (policyNumber.Length != 10 || !MTL.Utils.ThisWeb.CheckIsNumeric(policyNumber))
            {
                this.partnerName = partnerUsername;
                // LogRequest: Insert Log Request
                logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);
                obj.Result = "notcomplete_กรุณาระบุเลขกรมธรรม์ให้ถูกต้อง";
            }
            else
            {
                // พิสูจน์ตัวตนของพันธมิตรก่อนที่จะให้ใช้งานจริง
                NETWS_ForPartnerAuthenticationChecking.CheckPartnerAuthentication_Result pacobj = CheckPartnerAuthenticationReturnDetail(partnerUsername, partnerPassword, this.ipaddress);
                if (pacobj.Result.Trim().ToLower() == "passed")
                {
                    this.partnerName = pacobj.PartnerName;
                    // LogRequest: Insert Log Request
                    logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);

                    // ดึงข้อมูลรายละเอียดของกรมธรรม์กับ ApplinX WS_Admin
                    ApplinXgetPolicyCashValueResult resAdminObj = new ApplinXgetPolicyCashValueResult();
                    MTL.WS_Admin.WS_Admin_SmileServices.WS_Admin_ForSmartCardService adminWSObj = new MTL.WS_Admin.WS_Admin_SmileServices.WS_Admin_ForSmartCardService();
                    resAdminObj.fld_errmsg = adminWSObj.getPolicyCashValue(this.admin_username, this.admin_password, policyNumber, "", out resAdminObj.fld_sessionID, out resAdminObj.fld_client_name, out resAdminObj.fld_plan_name, out resAdminObj.fld_contract_start_date, out resAdminObj.fld_apl, out resAdminObj.fld_apl_interest, out resAdminObj.fld_apl_interest_2, out resAdminObj.fld_cash_value_present, out resAdminObj.fld_date, out resAdminObj.fld_dividend, out resAdminObj.fld_loan_interest, out resAdminObj.fld_loan_interest_2, out resAdminObj.fld_loan_value, out resAdminObj.fld_loan_value_net, out resAdminObj.fld_policy_number, out resAdminObj.fld_premium_outof_payment, out resAdminObj.fld_surrender_value_net, out resAdminObj.fld_year);

                    if (resAdminObj.fld_errmsg.Trim().ToLower() == "หมายเลขกรมธรรม์ถูกต้อง")
                    {
                        if (resAdminObj.fld_apl_interest_2.Trim().ToLower() != ".00")
                        {
                            obj.Result           = "completed";
                            obj.SessionID        = resAdminObj.fld_sessionID.Trim();
                            obj.PolicyNumber     = policyNumber;
                            obj.PlanName         = resAdminObj.fld_plan_name.Trim();
                            obj.APLAmount        = resAdminObj.fld_apl_interest_2.Trim();
                            obj.PaymentTypeToPay = "CCP";   //รับบัตรเดบิตเท่านั้น
                        }
                        else
                        {
                            obj.Result = "notcomplete_กรมธรรม์นี้ไม่มียอดเงินกู้อัตโนมัติ(APL)ให้ชำระ";
                        }
                    }
                    else
                    {
                        obj.Result = "notcomplete_กรุณาระบุเลขกรมธรรม์ให้ถูกต้อง";
                    }
                }
                else
                {
                    this.partnerName = pacobj.PartnerName;
                    // LogRequest: Insert Log Request
                    logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);

                    obj.Result = pacobj.Result.Trim().Replace("notpass_", "notcomplete_");
                }
            }
            // LogResponse: Insert Log Response
            logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", this.webserviceName, methodName, obj.Result + "|" + obj.PolicyNumber + "|" + "|" + obj.PlanName + "|" + obj.APLAmount + "|" + obj.PlanName + "|" + obj.PaymentTypeToPay + "|" + obj.SessionID, this.refnum);

            return(obj);
        }
        catch (Exception ex)
        {
            obj.Result = "notcomplete_" + ex.Message.ToString();

            // LogResponse: Insert Log Response
            logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", this.webserviceName, methodName, obj.Result, this.refnum);

            return(obj);
        }
    }
    public GetPolicyAPLForPayment_Result GetPolicyAPLForPayment(string partnerUsername, string partnerPassword, string policyNumber)
    {
        GetPolicyAPLForPayment_Result obj = new GetPolicyAPLForPayment_Result();
        RefRunningTBBLL runningobj = new RefRunningTBBLL();
        this.refnum = runningobj.AddRefRunningTBAndReturn();
        WSLogBLL logobj = new WSLogBLL();
        string methodName = "GetPolicyAPLForPayment";

        try
        {
            if (partnerUsername == "" || partnerPassword == "" || policyNumber == "")
            {
                this.partnerName = partnerUsername;
                // LogRequest: Insert Log Request
                logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);

                obj.Result = "notcomplete_กรุณาระบุข้อมูลให้ครบถ้วน";
            }
            else if (policyNumber.Trim().Substring(0, 2) == "PA")
            {
                this.partnerName = partnerUsername;
                // LogRequest: Insert Log Request
                logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);

                obj.Result = "notcomplete_กรมธรรม์นี้ไม่มียอดเงินกู้อัตโนมัติ(APL)ให้ชำระ";
            }
            else if (policyNumber.Length != 10 || !MTL.Utils.ThisWeb.CheckIsNumeric(policyNumber))
            {
                this.partnerName = partnerUsername;
                // LogRequest: Insert Log Request
                logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);
                obj.Result = "notcomplete_กรุณาระบุเลขกรมธรรม์ให้ถูกต้อง";
            }
            else
            {
                // พิสูจน์ตัวตนของพันธมิตรก่อนที่จะให้ใช้งานจริง
                NETWS_ForPartnerAuthenticationChecking.CheckPartnerAuthentication_Result pacobj = CheckPartnerAuthenticationReturnDetail(partnerUsername, partnerPassword, this.ipaddress);
                if (pacobj.Result.Trim().ToLower() == "passed")
                {
                    this.partnerName = pacobj.PartnerName;
                    // LogRequest: Insert Log Request
                    logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);

                    // ดึงข้อมูลรายละเอียดของกรมธรรม์กับ ApplinX WS_Admin
                    ApplinXgetPolicyCashValueResult resAdminObj = new ApplinXgetPolicyCashValueResult();
                    MTL.WS_Admin.WS_Admin_SmileServices.WS_Admin_ForSmartCardService adminWSObj = new MTL.WS_Admin.WS_Admin_SmileServices.WS_Admin_ForSmartCardService();
                    resAdminObj.fld_errmsg = adminWSObj.getPolicyCashValue(this.admin_username, this.admin_password, policyNumber, "", out  resAdminObj.fld_sessionID, out resAdminObj.fld_client_name, out resAdminObj.fld_plan_name, out resAdminObj.fld_contract_start_date, out resAdminObj.fld_apl, out resAdminObj.fld_apl_interest, out resAdminObj.fld_apl_interest_2, out resAdminObj.fld_cash_value_present, out resAdminObj.fld_date, out resAdminObj.fld_dividend, out resAdminObj.fld_loan_interest, out resAdminObj.fld_loan_interest_2, out resAdminObj.fld_loan_value, out resAdminObj.fld_loan_value_net, out resAdminObj.fld_policy_number, out resAdminObj.fld_premium_outof_payment, out resAdminObj.fld_surrender_value_net, out resAdminObj.fld_year);

                    if (resAdminObj.fld_errmsg.Trim().ToLower() == "หมายเลขกรมธรรม์ถูกต้อง")
                    {
                        if (resAdminObj.fld_apl_interest_2.Trim().ToLower() != ".00")
                        {
                            obj.Result = "completed";
                            obj.SessionID = resAdminObj.fld_sessionID.Trim();
                            obj.PolicyNumber = policyNumber;
                            obj.PlanName = resAdminObj.fld_plan_name.Trim();
                            obj.APLAmount = resAdminObj.fld_apl_interest_2.Trim();
                            obj.PaymentTypeToPay    ="CCP"; //รับบัตรเดบิตเท่านั้น

                        }
                        else
                        {
                            obj.Result = "notcomplete_กรมธรรม์นี้ไม่มียอดเงินกู้อัตโนมัติ(APL)ให้ชำระ";

                        }
                    }
                    else
                    {
                        obj.Result = "notcomplete_กรุณาระบุเลขกรมธรรม์ให้ถูกต้อง";

                    }

                }
                else
                {
                    this.partnerName = pacobj.PartnerName;
                    // LogRequest: Insert Log Request
                    logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + policyNumber, this.refnum);

                    obj.Result = pacobj.Result.Trim().Replace("notpass_", "notcomplete_");
                }

            }
            // LogResponse: Insert Log Response
            logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", this.webserviceName, methodName, obj.Result + "|"  + obj.PolicyNumber + "|" + "|" + obj.PlanName + "|" + obj.APLAmount + "|" + obj.PlanName + "|" + obj.PaymentTypeToPay + "|" + obj.SessionID, this.refnum);

            return obj;

        }
        catch (Exception ex)
        {
            obj.Result = "notcomplete_" + ex.Message.ToString();

            // LogResponse: Insert Log Response
            logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", this.webserviceName, methodName, obj.Result, this.refnum);

            return obj;
        }
    }