52,797
社区成员
发帖
与我相关
我的任务
分享
function SetSession(name,value)
{
var x = new ActiveXObject("Microsoft.XMLDOM");
var xh = new ActiveXObject("Microsoft.XMLHTTP");
var url="../DefaultService.asmx/SetSessions" ;
xh.open("post",url,false);
xh.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") ;
xh.send("Name=" +name+ "&Value=" +value);
// x = xh.responseXML ;
// CodeIsValid = x.selectSingleNode("//SetSession/CodeIsValid") ;
// if ((CodeIsValid!=null) && (CodeIsValid.text=="true"))
// {
// alert("测试成功");
// }
// else
// {
// alert("测试失败");
// }
return false;
}
//用户检查商户编号是否有重复
function CustomerData(objstrcd,objtp,objtxt,oprtp)
{
if (objtxt.value=="")
{
objtxt.value="0";
}
var objs = objtp.getElementsByTagName("INPUT");
var value;
for(i=0 ; i<objs.length ; i++)
{
if(objs[i].checked==true)
{
value=objs[i].value;
break;
}
}
if (objstrcd.value=="")
{
alert("商户ID不可为空!");
return false;
}
var x = new ActiveXObject("Microsoft.XMLDOM");
var xh = new ActiveXObject("Microsoft.XMLHTTP");
var url="../DefaultService.asmx/CustomerDataRow" ;
xh.open("post",url,false);
xh.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") ;
xh.send("sStrcd=" +objstrcd.value+"&sTp="+value+"&sTxt="+objtxt.value+"&sOprtp="+oprtp);
x = xh.responseXML ;
CodeIsValid = x.selectSingleNode("//CustomerData/CodeIsValid") ;
RetMesg= x.selectSingleNode("//CustomerData/RetMesg") ;
if ((CodeIsValid!=null) && (CodeIsValid.text=="true"))
{
if(confirm("是否要进行保存")==true)
return true;
else
return false;
}
else
{
alert(RetMesg.text);
return false;
}
}
------------------------------------------------Web Service---------------------------
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.IO;
using System.Net;
using System.Net.Mail;
using Common;
/// <summary>
/// Summary description for DefaultService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class DefaultService : System.Web.Services.WebService
{
public DefaultService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod(EnableSession = true)]
public void SetSessions(string Name, string Value)
{
Session[Name] = Value;
}
[WebMethod(Description = "检查商户ID的唯一性")]
public CustomerData CustomerDataRow(string sStrcd, string sTp, string sTxt, string sOprtp)
{
Common.CustomerData customerDataRow = new Common.CustomerData();
if (sStrcd == null && sStrcd == "")
{
customerDataRow.RetMesg = "该商户ID为空,请输入商户ID";
customerDataRow.CodeIsValid = false;
return customerDataRow;
}
try
{
if (sOprtp == "1")//增加时检查唯一性
{
DataAccess.CustomerInfo ap = new DataAccess.CustomerInfo();
if (ap.GetInfo(sStrcd) == true)
{
if (ap.List.Rows.Count != 0)
{
customerDataRow.RetMesg = "该商户ID已存在,请重新输入商户ID";
customerDataRow.CodeIsValid = false;
return customerDataRow;
}
}
}
if (sTp == "2")
{
if (System.Convert.ToDouble(sTxt) < 1 || System.Convert.ToDouble(sTxt) > 7)
{
customerDataRow.RetMesg = "只能输入(1-7)数字";
customerDataRow.CodeIsValid = false;
}
else
customerDataRow.CodeIsValid = true;
}
if (sTp == "3")
{
if (System.Convert.ToDouble(sTxt) < 1 || System.Convert.ToDouble(sTxt) > 30)
{
customerDataRow.RetMesg = "只能输入(1-30)数字";
customerDataRow.CodeIsValid = false;
}
else
customerDataRow.CodeIsValid = true;
}
}
catch
{
customerDataRow.RetMesg = "保存失败";
customerDataRow.CodeIsValid = false;
}
return customerDataRow;
}