学生数据
Posted mamingyuan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学生数据相关的知识,希望对你有一定的参考价值。
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); } } }
以上是关于学生数据的主要内容,如果未能解决你的问题,请参考以下文章