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;
}
}
}