標籤: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; } }}View Code
指令碼
//供應商 $(‘#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); } });
asp.net 一般處理常式