.net 一般处理程序 接口形式 模板
<%@ WebHandler Language="C#" Class="ManuallyAssign" %> using System; using System.Web; using System.Web.SessionState; using System.Data; using System.Data.SqlClient; //1 获取楼层GetFloor //2 获取房间信息 GetRooming //3 获取总数和已分配未分配数 GetPanelPrompt //4 更新占用房间 //5 更新手动分配 //4+5 执行事务 ExecuteTransaction //6 confirm 占用房间的班级查询 GetClassName public class ManuallyAssign : IHttpHandler{ public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string method = context.Request.QueryString["method"].ToString(); switch (method) { case "getFloor": GetFloor(context); break;//获取楼层 case "getRooming": GetRooming(context); break;//获取房间信息 case "getPanelPrompt": GetPanelPrompt(context); break;//获取总数和已分配未分配数 case "executeTransaction": ExecuteTransaction(context); break;//执行事务:更新占用房间,更新手动分配 case "getClassName": GetClassName(context); break;// 占用房间的班级名称查询 default: context.Response.End(); break; } context.Response.End(); } public void GetFloor(HttpContext c) { string str1 = c.Request.QueryString["str1"].ToString();//参数1 c.Response.Write("111"); } public void GetRooming(HttpContext c) { string str1 = c.Request.QueryString["str1"].ToString();//参数1 c.Response.Write("111"); } public void GetPanelPrompt(HttpContext c) { string str1 = c.Request.QueryString["str1"].ToString();//参数1 c.Response.Write("111"); } public void ExecuteTransaction(HttpContext c) { string str1 = c.Request.QueryString["str1"].ToString();//参数1 c.Response.Write("111"); } public void GetClassName(HttpContext c) { string str1 = c.Request.QueryString["str1"].ToString();//参数1 c.Response.Write("111"); } public bool IsReusable { get { return false; } } }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<%@ WebHandler Language="C#" Class="ManuallyAssign" %> using System; using System.Web; using System.Web.SessionState; using System.Data; using System.Data.SqlClient; //1 获取楼层GetFloor //2 获取房间信息 GetRooming //3 获取总数和已分配未分配数 GetPanelPrompt //4 更新占用房间 //5 更新手动分配 //4+5 执行事务 ExecuteTransaction //6 confirm 占用房间的班级查询 GetClassName public class ManuallyAssign : IHttpHandler{ public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string method = context.Request.QueryString["method"].ToString(); switch (method) { case "getFloor": GetFloor(context); break;//获取楼层 case "getRooming": GetRooming(context); break;//获取房间信息 case "getPanelPrompt": GetPanelPrompt(context); break;//获取总数和已分配未分配数 case "executeTransaction": ExecuteTransaction(context); break;//执行事务:更新占用房间,更新手动分配 case "getClassName": GetClassName(context); break;// 占用房间的班级名称查询 default: context.Response.End(); break; } context.Response.End(); } /// <summary> /// 获取楼层 /// </summary> /// <param name="c"></param> public void GetFloor(HttpContext c) { string strHtml = ""; string Floor_Housing = c.Request.QueryString["Floor_Housing"].ToString(); string sql = "select Floor_number,Floor_name,Floor_Housing from [dbo].[Base_Floor] where Floor_Housing='"+Floor_Housing+"'"; DataTable dt = DataBase.ExecuteTable(CommandType.Text, sql, null); if (dt.Rows.Count > 0) { strHtml=DataSetJson.DataTableJson(dt); } c.Response.Write(strHtml); } /// <summary> /// 获取房间信息 /// </summary> /// <param name="c"></param> public void GetRooming(HttpContext c) { string strHtml = ""; string Floor_Housing = c.Request.QueryString["Floor_Housing"].ToString(); string sql = "select Floor_number,Floor_name,Floor_Housing from [dbo].[Base_Floor] where Floor_Housing='" + Floor_Housing + "'"; DataTable dt = DataBase.ExecuteTable(CommandType.Text, sql, null); if (dt.Rows.Count > 0) { strHtml = DataSetJson.DataTableJson(dt); } c.Response.Write(strHtml); } /// <summary> /// 获取总数和已分配未分配数 /// </summary> /// <param name="c"></param> public void GetPanelPrompt(HttpContext c) { string str1 = c.Request.QueryString["str1"].ToString();//参数1 c.Response.Write("111"); } /// <summary> /// 执行事务:更新占用房间,更新手动分配 /// </summary> /// <param name="c"></param> public void ExecuteTransaction(HttpContext c) { string str1 = c.Request.QueryString["str1"].ToString();//参数1 c.Response.Write("111"); } /// <summary> /// 占用房间的班级名称查询 /// </summary> /// <param name="c"></param> public void GetClassName(HttpContext c) { string str1 = c.Request.QueryString["str1"].ToString();//参数1 c.Response.Write("111"); } public bool IsReusable { get { return false; } } }