95 lines
2.9 KiB
C#
95 lines
2.9 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web;
|
||
|
||
namespace VRS.Handler
|
||
{
|
||
/// <summary>
|
||
/// 科目管理
|
||
/// </summary>
|
||
public class Subject : BaseHandler, IHttpHandler
|
||
{
|
||
DataService.BLL.admin_user bll = new DataService.BLL.admin_user();
|
||
DataService.BLL.pro_subject bll_subject = new DataService.BLL.pro_subject();
|
||
DataService.BLL.pro_subject_proc bll_subject_proc = new DataService.BLL.pro_subject_proc();
|
||
public void ProcessRequest(HttpContext context)
|
||
{
|
||
context.Response.ContentType = "text/plain";
|
||
if (null == context.Request["action"])
|
||
{
|
||
var result = GetResult(false, "缺少参数:action");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
string action = context.Request["action"];
|
||
switch (action)
|
||
{
|
||
|
||
//查询单个科目
|
||
case "query":
|
||
Query(context);
|
||
break;
|
||
|
||
//查询所有科目
|
||
case "all":
|
||
ALL(context);
|
||
break;
|
||
|
||
default:
|
||
var result = GetResult(false, "方法名不存在:" + action);
|
||
context.Response.Write(result);
|
||
break;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询所有科目
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void ALL(HttpContext context)
|
||
{
|
||
var list_subject = bll_subject.GetModelList("");
|
||
var result = GetResult(true, list_subject);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询单个科目
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void Query(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
var subject_id = context.Request.Params["subject_id"];
|
||
if (string.IsNullOrEmpty(subject_id))
|
||
{
|
||
ret = GetResult(false, "科目:subject_id 不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var subject = bll_subject.GetModel(subject_id);
|
||
if (null != subject)
|
||
{
|
||
var result = GetResult(true, subject);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, null, "科目不存在!");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
public bool IsReusable
|
||
{
|
||
get
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
} |