js调用webservice中的方法实现思路及代码_javascript技巧
程序员文章站
2024-01-25 13:22:22
...
webservice代码:
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using StoreHouse.Common;
using StoreHouse.IDAL;
using StoreHouse.Model;
using System.Data.SqlClient;
using System.Data;
using System.Xml;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Net.NetworkInformation;
///
/// PageService 的摘要说明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class PageService : System.Web.Services.WebService
{
ArrayList al = new ArrayList();
public PageService()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
///
/// 添加收藏
///
/// 产品ID
/// 用户ID
/// 标识(产品收藏、企业收藏、电子样本收藏、图库收藏)
///返回收藏状态
[WebMethod]
public int AddCollect(int fid,int sid,int flag)
{
IProductDataProvider ipdp = ProviderManager.Create();
IEnterpriseDataProvider iedp = ProviderManager.Create();
if (flag == 1)
{
ProductCollect pc = new ProductCollect();
pc.ProductID = fid;
pc.UserID = sid;
pc.AddDatetime = DateTime.Now;
pc.UpdateDatetime = DateTime.Now;
return ipdp.AddProductCollect(pc);
}
else if (flag == 2)
{
EnterpriseCollect ec = new EnterpriseCollect();
ec.EnterpriseID = fid;
ec.UserID = sid;
ec.AddDatetime = DateTime.Now;
ec.UpdateDatetime = DateTime.Now;
return iedp.AddEnterpriseCollect(ec);
}
else if (flag == 3)
{
EElecSampleCollect epesc = new EElecSampleCollect();
epesc.EElecSampleID = fid;
epesc.UserID = sid;
epesc.AddDatetime = DateTime.Now;
epesc.UpdateDatetime = DateTime.Now;
return ipdp.AddEElecSampleCollect(epesc);
}
else if (flag == 4)
{
EPAtlasCollect epac = new EPAtlasCollect ();
epac.EPAtlasID= fid;
epac.UserID = sid;
epac.AddDatetime = DateTime.Now;
epac.UpdateDatetime = DateTime.Now;
return ipdp.AddEPAtlasCollect(epac);
}
return 000000;
}
复制代码 代码如下:
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using StoreHouse.Common;
using StoreHouse.IDAL;
using StoreHouse.Model;
using System.Data.SqlClient;
using System.Data;
using System.Xml;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Net.NetworkInformation;
///
/// PageService 的摘要说明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class PageService : System.Web.Services.WebService
{
ArrayList al = new ArrayList();
public PageService()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
///
/// 添加收藏
///
/// 产品ID
/// 用户ID
/// 标识(产品收藏、企业收藏、电子样本收藏、图库收藏)
///
[WebMethod]
public int AddCollect(int fid,int sid,int flag)
{
IProductDataProvider ipdp = ProviderManager.Create
IEnterpriseDataProvider iedp = ProviderManager.Create
if (flag == 1)
{
ProductCollect pc = new ProductCollect();
pc.ProductID = fid;
pc.UserID = sid;
pc.AddDatetime = DateTime.Now;
pc.UpdateDatetime = DateTime.Now;
return ipdp.AddProductCollect(pc);
}
else if (flag == 2)
{
EnterpriseCollect ec = new EnterpriseCollect();
ec.EnterpriseID = fid;
ec.UserID = sid;
ec.AddDatetime = DateTime.Now;
ec.UpdateDatetime = DateTime.Now;
return iedp.AddEnterpriseCollect(ec);
}
else if (flag == 3)
{
EElecSampleCollect epesc = new EElecSampleCollect();
epesc.EElecSampleID = fid;
epesc.UserID = sid;
epesc.AddDatetime = DateTime.Now;
epesc.UpdateDatetime = DateTime.Now;
return ipdp.AddEElecSampleCollect(epesc);
}
else if (flag == 4)
{
EPAtlasCollect epac = new EPAtlasCollect ();
epac.EPAtlasID= fid;
epac.UserID = sid;
epac.AddDatetime = DateTime.Now;
epac.UpdateDatetime = DateTime.Now;
return ipdp.AddEPAtlasCollect(epac);
}
return 000000;
}
推荐阅读
-
js调用webservice中的方法实现思路及代码_javascript技巧
-
js将iframe中控件的值传到主页面控件中的实现方法_javascript技巧
-
js对数组中的数字从小到大排序实现代码_javascript技巧
-
用js实现计算代码行数的简单方法附代码_javascript技巧
-
js将iframe中控件的值传到主页面控件中的实现方法_javascript技巧
-
jQuery及JS实现循环中暂停的方法_javascript技巧
-
JS链式调用的实现方法_javascript技巧
-
JS关键字变色实现思路及代码_javascript技巧
-
js如何实现设计模式中的模板方法_javascript技巧
-
js实现点小图看大图效果的思路及示例代码_javascript技巧