1. 程式人生 > >學生數據

學生數據

soft char ria sof [] .org tex ebo tst

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

學生數據