标签:lock web data alt trim 联系 splay function try
一般处理程序类似公共模块,所有页面都可以调用。
一般处理程序
<%@ WebHandler Language="C#" Class="SetGrid" %> using System; using System.Web; public class SetGrid : IHttpHandler { public void ProcessRequest (HttpContext context) { string sql = ""; System.Data.DataTable dtTmp = null; string sf = ""; string result = ""; try { switch (context.Request["oper"]) { case "Supplier"://供应商 sql = "select ID,abbreviation,name,linkman1,Tel,trmo,currency,cess from provider"; if (!string.IsNullOrEmpty(context.Request["q"])) { sf = context.Request["q"].ToString().Trim(); sql += " where abbreviation like ‘%" + sf + "%‘ or linkman1 like ‘%" + sf + "%‘ or name like ‘%" + sf + "%‘ or Tel like ‘%" + sf + "%‘"; } dtTmp = pubCommon.GetDataTable(sql); result = pubCommon.DataTableToJson(dtTmp); //result = "[{\"si_name\":\"三菱\",\"si_linkman\":\"村上\",\"si_mobile\":\"12-002136\"},{\"si_name\":\"西门西\",\"si_linkman\":\"Jon\",\"si_mobile\":\"0223-26565\"}]"; break; case "PODetail": sql = "select 1 as gi_id,*,12 as pi_number,12 as qty from materiel where code = ‘110010030092‘"; dtTmp = pubCommon.GetDataTable(sql); if (dtTmp != null) { result = pubCommon.DataTableToJson(dtTmp); } break; case "Query": sql = "select * from materiel"; dtTmp = pubCommon.GetDataTable(sql); if (dtTmp != null) { result = pubCommon.DataTableToJson(dtTmp); } break; } } catch (Exception ex) { } context.Response.Write(result); context.Response.End(); } public bool IsReusable { get { return false; } } }
脚本
//供应商 $(‘#gys_key‘).combogrid({ panelWidth: 350, delay: 500, mode: ‘remote‘, idField: ‘ID‘, textField: ‘abbreviation‘, url: ‘/Project2/Dispose/SetGrid.ashx?oper=Supplier‘, columns: [[ { field: ‘abbreviation‘, title: ‘简称‘, width: 80 }, { field: ‘name‘, title: ‘供应商名称‘, width: 120 }, { field: ‘linkman1‘, title: ‘联系人‘, width: 80 }, { field: ‘Tel‘, title: ‘电话‘, width: 100 } ]], onSelect: function (rowIndex, rowData) { $("#txtTax").val(rowData.cess); $("#txtpay").val(rowData.trmo); $("#txtcurrency").val(rowData.currency); } });
标签:lock web data alt trim 联系 splay function try
原文地址:http://www.cnblogs.com/chirs888888/p/6252628.html