码迷,mamicode.com
首页 > 其他好文 > 详细

学生数据

时间:2018-07-29 23:27:33      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:注释   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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!