json
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Text;
using System.Web.Script.Serialization;
namespace FireNews
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class GetRoportList : IHttpHandler
    {
        DAL.SelfCheckInfo dal_info = new DAL.SelfCheckInfo();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            if (!string.IsNullOrEmpty(context.Request.QueryString["UnitType"]))
            {
                string type = context.Request.QueryString["UnitType"].ToString().Trim();//传过来参数的名字 我这里使用的是get方式
                DataTable dt = dal_info.GetList("type like '%"+type+"%'").Tables[0];//这里改成你需要的sql语句
                List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        Dictionary<string, object> result = new Dictionary<string, object>();
                        foreach (DataColumn  dc in dt.Columns)
                        {
                            result.Add(dc.ColumnName, dr[dc].ToString());
                        }
                        list.Add(result);
                    }
                    context.Response.Write(new JavaScriptSerializer().Serialize(list));
                }
            }
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
 
                    
                 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号