제이슨 세트

6831 단어 json
JS 파일
function pager1_InitData() {
    //    
    $("#pager1").myPagination({
        currPage: 1,
        pageCount: 1,
        pageSize: 10,
        cssStyle: 'quotes',
        info: {
            cookie_currPage: true, //   Coookie      
            cookie_currPageKey: "pager1_H"	//   cookie    demo1_currPage
        },
        ajax: {
            on: true,                        //    
            callback: 'pager1call',    //    
            url: "/AJAXFUNC/OrderHandler.ashx",            //       
            dataType: 'json',                //    
            param: { on: true, type: '2', ispaid: 'null', payway: '0', bdate: $("[id$='all_beginDate']").val(), edate: $("[id$='all_endDate']").val(), name: $("[id$='all_ticketName']").val() },
            pageContId: "pageCount"
        }
    });
}

 
JS 파일의 콜백 함수
function pager1call(data) {
    var orderInfo = data;
    $("#all_TicketOrder").html("");
    var html = "";
    for (var i = 0; ; i++) {
        if (orderInfo.listPo[i] == undefined) {
            break;
        }
        else {
            html += "<tr>";
            html += "<td width='70' height='35' class='xian'>";
            html += "" + orderInfo.listPo[i].orderid + "</td>";
            html += "<td width='120' class='xian'>";
            html += orderInfo.listPo[i].upname + "</td>";
            html += "<td width='110' class='xian'>";
            html += "" + orderInfo.listPo[i].createtime + "</td>";
            html += "<td width='130' class='xian'>";
            html += "" + orderInfo.listPo[i].name + "</td>";
            html += "<td width='100' class='xian'>";
            html += "" + orderInfo.listPo[i].endtime + "</td>";
            html += "<td width='80' class='xian'>";
            html += "" + orderInfo.listPo[i].totalmoney + "</td>";
            html += "<td width='80' class='xian'>";
        }
    }
    $("#all_TicketOrder").html(html);
    if (orderInfo.pageCount == 0) {
        $("#allEmptyOrder").attr("style", "");
    }
    else {
        $("#allEmptyOrder").attr("style", "display:none");
    }
}

 
ashx 파일, json
public class OrderHandler : IHttpHandler
{
    BLLtourol_B2COrder blltourol_b2corder = new BLLtourol_B2COrder();
    System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        string type = context.Request["type"];
        int userid = int.Parse(System.Web.Security.Membership.GetUser().ProviderUserKey.ToString());
        string name = context.Request["name"];
        bool? ispaid;
        if (context.Request["ispaid"] == "null")
        {
            ispaid = null;
        }
        else
        {
            ispaid = bool.Parse(context.Request["ispaid"]);
        }
        int payway = int.Parse(context.Request["payway"]);
        string bdate = context.Request["bdate"];
        string edate = context.Request["edate"];
        int pageindex = int.Parse(context.Request["page"]) - 1;
        int pagesize = 10;
        if (type == ((int)EnterpriseType.  ).ToString())
        {
            context.Response.Write(GetAtractionView(userid, ispaid, payway, name, bdate, edate, pageindex, pagesize));
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

    public string GetAtractionView(int userid, bool? ispaid, int payway, string name, string bdate, string edate, int pageindex, int pagesize)
    {
        int count = 0;
        DataTable dt = blltourol_b2corder.GetList4TableTicket(userid, ispaid, payway, name, bdate, edate, pageindex, pagesize, out count);
        return jss.Serialize(new ProductOrder2() { pageCount = (int)Math.Ceiling(count * 1.0 / 10), listPo = list4ticket(dt, count) });// list   JSON      
    }

    public List<ProductOrder> list4ticket(DataTable dt, int count)
    {
        List<ProductOrder> listPv = new List<ProductOrder>();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            ProductOrder pv = new ProductOrder();
            pv.orderid = dt.Rows[i]["Orderid"].ToString();
            pv.name = dt.Rows[i]["TicketName"].ToString();
            pv.upname = dt.Rows[i]["Name"].ToString();
            pv.createtime = DateTime.Parse(dt.Rows[i]["Createtime"].ToString()).ToString("yyyy-MM-dd");
            pv.endtime = DateTime.Parse(dt.Rows[i]["Endtime"].ToString()).ToString("yyyy-MM-dd");
            pv.totalmoney = dt.Rows[i]["TotalMoney"].ToString();
            pv.paystate = dt.Rows[i]["Paystate"].ToString();
            pv.payway = dt.Rows[i]["Payway"].ToString();
            pv.state = dt.Rows[i]["State"].ToString();
            listPv.Add(pv);
        }
        return listPv;
    }
}

public class ProductOrder
{
    public string orderid { get; set; }
    public string name { get; set; }
    public string upname { get; set; }
    public string createtime { get; set; }
    public string endtime { get; set; }
    public string totalmoney { get; set; }
    public string paystate { get; set; }
    public string payway { get; set; }
    public string state { get; set; }
}

public class ProductOrder2
{
    public int pageCount { get; set; }
    public List<ProductOrder> listPo { get; set; }
}

좋은 웹페이지 즐겨찾기