一段C#接口代码

using DBUtility;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace webservice
{
    /// <summary>
    /// Summary description for WebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WebService : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            // string dd = "uid=lr;pwd=qw;server=OA.D33;database=jw3elry;Pooling=true;Max Pool Size=500;Min Pool Size=5";
            //string cc= DESEncrypt.Encrypt(dd);
            //return cc;
            return "Hello World";
        }

        /// <summary>
        /// 根据手机号码,查询客户是否购买钻戒
        /// </summary>
        /// <param name = "mobile" > 手机号码 </ param >
        /// < returns ></ returns >
        [WebMethod]
        public string IsBuyDiamond(string mobile)
        {
            string list = "";
            list += "{\"IsBuyDiamond\":[";
            list += "{\"mobile\":\"" + mobile + "\"";
            if (string.IsNullOrEmpty(mobile))
            {
                list += ",\"isBuy\":\"0\"}";
            }
            else
            {
                string sql = @"select a.no from purchaser a
                       left join goods_s b on b.purid=a.no
                       left join goods c on c.id=b.id
                       where  a.type='03' and c.style in ('1','2','3','4','5','6','7')
                       and a.mobile='" + mobile + "'";
                DataTable dt = DbHelperSQL.Query(sql).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    list += ",\"isBuy\":\"1\"}";
                }
                else
                {
                    list += ",\"isBuy\":\"0\"}";
                }
            }
            list += "]}";
            return list;
        }


        /// <summary>
        /// 根据手机号码,查询某个VIP账户信息
        /// </summary>
        /// <param name="mobile">手机号码</param>
        /// <returns></returns>
        [WebMethod]
        public string SalesPerson(string mobile)
        {
            string list = "";
            if (!string.IsNullOrEmpty(mobile))
            {
                string sql = @"select a.no,a.purchaser,0 as Status from purchaser a
                                       left join goods_s b on b.purid=a.no
                                       left join goods c on c.id=b.id
                                       where  a.type='03' and c.style in ('1','2','3','4','5','6','7')
                                       and a.mobile='" + mobile + "'";
                DataTable dt = DbHelperSQL.Query(sql).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    list += "{\"SalesPerson\":[";
                    list += "{\"username\":\"" + dt.Rows[0]["no"].ToString() + "\"";
                    list += ",\"role\":\"" + dt.Rows[0]["purchaser"].ToString() + "\"";
                    list += ",\"status\":\"" + dt.Rows[0]["Status"].ToString() + "\"";
                    list += "}]}";
                }
            }
            return list;
        }

        /// <summary>
        /// 根据手机号码,查询某个雇员账户信息
        /// </summary>
        /// <param name="mobile">手机号码</param>
        /// <returns></returns>
        [WebMethod]
        public string Salesemployer(string mobile)
        {
            string list = "";
            if (!string.IsNullOrEmpty(mobile))
            {

            //    select employer, mobile, ass, dept, isdimis from dbo.employer
                    string sql = @"select b.No,a.employer, a.ass, a.dept, a.pasw,a.isdimis from employer a
left join purchaser b on a.dept=b.purchaser
                                       where  a.mobile='" + mobile + "'";
                DataTable dt = DbHelperSQL.Query(sql).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    list += "{\"Salesemployer\":[";
                    list += "{\"no\":\"" + dt.Rows[0]["no"].ToString() + "\"";
                    list += ",\"username\":\"" + dt.Rows[0]["employer"].ToString() + "\"";
                    list += ",\"role\":\"" + dt.Rows[0]["ass"].ToString() + "\"";
                    list += ",\"dept\":\"" + dt.Rows[0]["dept"].ToString() + "\"";
                    list += ",\"pasw\":\"" + dt.Rows[0]["pasw"].ToString() + "\"";
                    list += ",\"status\":\"" + dt.Rows[0]["isdimis"].ToString() + "\"";
                    list += "}]}";
                }
            }
            return list;
        }

        [WebMethod]
        public string Salesopr(string mobile)
        {
            string list = "";
            if (!string.IsNullOrEmpty(mobile))
            {

                //    select employer, mobile, ass, dept, isdimis from dbo.employer
                string sql = @"select b.name,b.password,a.purchaser,b.status from operators b left join purchaser a on a.no=b.custid
                                       where  b.name='" + mobile + "'";
                DataTable dt = DbHelperSQL.Query(sql).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    list += "{\"Saleseopr\":[";
                    list += "{\"name\":\"" + dt.Rows[0]["name"].ToString() + "\"";
                    list += ",\"password\":\"" + dt.Rows[0]["password"].ToString() + "\"";
                    list += ",\"purchaser\":\"" + dt.Rows[0]["purchaser"].ToString() + "\"";
                    list += ",\"status\":\"" + dt.Rows[0]["status"].ToString() + "\"";
                    list += "}]}";
                }
            }
            return list;
        }


        [WebMethod]
        public string BuyDiamondno(string no)
        {
            string list = "";
            list += "{\"IsBuyDiamond\":[";
            list += "{\"no\":\"" + no + "\"";
            if (string.IsNullOrEmpty(no))
            {
                list += ",\"isBuy\":\"0\"}";
            }
            else
            {
                string sql = @"select a.no from goods_s a
                       
                       left join goods c on c.id=a.id
                       where  c.style in ('1','2','3','4','5','6','7')
                       and a.no='" + no + "'";
                DataTable dt = DbHelperSQL.Query(sql).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    list += ",\"isBuy\":\"1\"}";
                }
                else
                {
                    list += ",\"isBuy\":\"0\"}";
                }
            }
            list += "]}";
            return list;
        }

    }

}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jekc868

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值