标签:注释 pre json contex net oat binding res tput
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; namespace StudentWebserice { using MODEL; using BLL; using System.Data.SqlClient; using Newtonsoft.Json; using System.Data; /// <summary> /// StudentWebService 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 [System.Web.Script.Services.ScriptService] public class StudentWebService : System.Web.Services.WebService { StudentBll bll = new StudentBll(); [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public void Add(int ClassCode, string StudentName, int Gender) { Context.Response.ContentType = "Application/json;charset=utf-8"; int i = bll.Add(ClassCode, StudentName, Gender); Context.Response.Write(i); } [WebMethod] public void GetStudent(int Dpage,int ClassCode,int SchoolCode,string StudentName) { Context.Response.ContentType = "Application/json;charset=utf-8"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@Dpage", Dpage), new SqlParameter("@Count", SqlDbType.Float), new SqlParameter("@ClassCode", ClassCode), new SqlParameter("@SchoolCode", SchoolCode), new SqlParameter("@StudentName", StudentName), }; parameter[1].Direction = System.Data.ParameterDirection.Output; pageBox pagebox = new pageBox(); pagebox.Ddata=bll.GetStudent(parameter); pagebox.Dpage = Dpage; pagebox.Count =Convert.ToInt32(parameter[1].Value); Context.Response.Write(JsonConvert.SerializeObject( pagebox)); } [WebMethod] public void Delete(int StudentId) { Context.Response.ContentType = "Application/json;charset=utf-8"; int i = bll.Delete(StudentId); Context.Response.Write(i); } [WebMethod] public void Update(int ClassCode, string StudentName, int Gender, int StudentId) { Context.Response.ContentType = "Application/json;charset=utf-8"; int i = bll.Update(ClassCode, StudentName, Gender, StudentId); Context.Response.Write(i); } [WebMethod] public void Getid(int StudentId) { Context.Response.ContentType = "Application/json;charset=utf-8"; AllData s = bll.Getid(StudentId); var json = JsonConvert.SerializeObject(s); Context.Response.Write(json); } } }
标签:注释 pre json contex net oat binding res tput
原文地址:https://www.cnblogs.com/mamingyuan/p/9387969.html