public GetAgentStatus_Result GetAgentStatusByName(string partnerUsername, string partnerPassword, string agentName, string agentSurname)
    {
        GetAgentStatus_Result obj = new GetAgentStatus_Result();
        RefRunningTBBLL runningobj = new RefRunningTBBLL();
        this.refnum = runningobj.AddRefRunningTBAndReturn();
        WSLogBLL logobj = new WSLogBLL();
        string methodName = "GetAgentStatusByName";

        try
        {
            if (partnerUsername == "" || partnerPassword == "" || agentName == "" || agentSurname == "")
            {
                this.partnerName = partnerUsername;
                // LogRequest: Insert Log Request
                logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentName + "|" + agentSurname, 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 + "|" + agentName + "|" + agentSurname, this.refnum);

                    // ค้นหาเลขที่ตัวแทนจากชื่อนามสกุล
                    ApplinXGetAgentNumberSearchByNameResult resAdminObj = new ApplinXGetAgentNumberSearchByNameResult();
                    MTL.WS_Admin.WS_Admin_ForCMS.WS_Admin_ForCMSService adminWSObj = new MTL.WS_Admin.WS_Admin_ForCMS.WS_Admin_ForCMSService();
                    resAdminObj.fld_result = adminWSObj.getAgentNumberSearchByName(this.admin_username, this.admin_password, agentName, agentSurname, out resAdminObj.fld_sessionID, out resAdminObj.fld_agent_number);
                    if (resAdminObj.fld_result.Trim() == "found")
                    {
                        // ตรวจสอบสถานะตัวแทน
                        ApplinXGetAgentDetailResult resAgentDetailObj = new ApplinXGetAgentDetailResult();
                        resAgentDetailObj = this.GetAgentDetail(resAdminObj.fld_agent_number.Trim());
                        if (resAgentDetailObj.fld_result.Trim().ToLower() == "found")
                        {
                            // เช็คสถานะตัวแทน
                            if (resAgentDetailObj.fld_agent_status_code.Trim() == "A")
                            {
                                obj.Result = "completed";
                                obj.AgentNumber = resAgentDetailObj.fld_agent_no.Trim();
                                obj.Name = resAgentDetailObj.fld_agent_title.Trim() + " " + resAgentDetailObj.fld_agent_name.Trim() + " " + resAgentDetailObj.fld_agent_surname.Trim();
                                obj.Gender = resAgentDetailObj.fld_agent_gender.Trim();
                                obj.DoB = resAgentDetailObj.fld_agent_dob.Trim();
                                obj.Phone = resAgentDetailObj.fld_agent_phone.Trim();
                                obj.LicenseNumber = resAgentDetailObj.fld_agent_license_number.Trim();
                                obj.Department = resAgentDetailObj.fld_agent_department.Trim();
                                obj.Position = resAgentDetailObj.fld_agent_position.Trim();
                                obj.AgentPictureURL = resAgentDetailObj.AgentPictureURL.Trim();
                            }
                            else
                            {
                                obj.Result = "notcomplete_ตัวแทนคนนี้ได้พ้นสภาพจากการเป็นตัวแทนกับบริษัทฯ แล้ว";
                            }
                        }
                        else
                        {
                            obj.Result = resAgentDetailObj.fld_result.Trim().Replace("notfound_", "notcomplete_");
                        }
                    }
                    else
                    {
                        obj.Result = "notcomplete_ไม่พบตัวแทนที่มีชื่อนามสกุลตามที่ท่านระบุ";
                    }
                }
                else
                {
                    this.partnerName = pacobj.PartnerName;
                    // LogRequest: Insert Log Request
                    logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentName + "|" + agentSurname, 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.AgentNumber + "|" + obj.Name + "|" + obj.LicenseNumber, 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 GetAgentStatus_Result GetAgentStatusByAgentNumber(string partnerUsername, string partnerPassword, string agentNumber)
    {
        GetAgentStatus_Result obj = new GetAgentStatus_Result();
        RefRunningTBBLL runningobj = new RefRunningTBBLL();
        this.refnum = runningobj.AddRefRunningTBAndReturn();
        WSLogBLL logobj = new WSLogBLL();
        string methodName = "GetAgentStatusByAgentNumber";

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

                obj.Result = "notcomplete_กรุณาระบุข้อมูลให้ครบถ้วน";
            }
            else if (agentNumber.Length != 6 || !MTL.Utils.ThisWeb.CheckIsNumeric(agentNumber))
            {
                this.partnerName = partnerUsername;
                // LogRequest: Insert Log Request
                logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber, 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 + "|" + agentNumber, this.refnum);

                    // ตรวจสอบสถานะตัวแทน
                    ApplinXGetAgentDetailResult resAgentDetailObj = new ApplinXGetAgentDetailResult();
                    resAgentDetailObj = this.GetAgentDetail(agentNumber);
                    if (resAgentDetailObj.fld_result.Trim().ToLower() == "found")
                    {
                        // เช็คสถานะตัวแทน
                        if (resAgentDetailObj.fld_agent_status_code.Trim() == "A")
                        {
                            obj.Result = "completed";
                            obj.AgentNumber = resAgentDetailObj.fld_agent_no.Trim();
                            obj.Name = resAgentDetailObj.fld_agent_title.Trim() + " " + resAgentDetailObj.fld_agent_name.Trim() + " " + resAgentDetailObj.fld_agent_surname.Trim();
                            obj.Gender = resAgentDetailObj.fld_agent_gender.Trim();
                            obj.DoB = resAgentDetailObj.fld_agent_dob.Trim();
                            obj.Phone = resAgentDetailObj.fld_agent_phone.Trim();
                            obj.LicenseNumber = resAgentDetailObj.fld_agent_license_number.Trim();
                            obj.Department = resAgentDetailObj.fld_agent_department.Trim();
                            obj.Position = resAgentDetailObj.fld_agent_position.Trim();
                            obj.AgentPictureURL = resAgentDetailObj.AgentPictureURL.Trim();
                        }
                        else
                        {
                            obj.Result = "notcomplete_ตัวแทนคนนี้ได้พ้นสภาพจากการเป็นตัวแทนกับบริษัทฯ แล้ว";
                        }
                    }
                    else
                    {
                        obj.Result = resAgentDetailObj.fld_result.Trim().Replace("notfound_", "notcomplete_");
                    }
                }
                else
                {
                    this.partnerName = pacobj.PartnerName;
                    // LogRequest: Insert Log Request
                    logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber, 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.AgentNumber + "|" + obj.Name + "|" + obj.LicenseNumber, 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;
        }
    }