You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
190 lines
5.6 KiB
190 lines
5.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Reflection;
|
|
using System.Web.Script.Serialization;
|
|
using FangYar.Model;
|
|
using FangYar.BLL;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class OaHolidayHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.OA.OA_HOLIDAY bll = new FangYar.BLL.OA.OA_HOLIDAY();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
case "List":
|
|
returnstr = List(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = Add(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = Edit(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = Del(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//根据值班日期查询
|
|
private string List(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
string whereStr = "";
|
|
try
|
|
{
|
|
string DutyDate = context.Request.Params["DutyDate"];
|
|
string searchTime = context.Request.Params["searchTime"];
|
|
string searchRest = context.Request.Params["searchRest"];
|
|
|
|
whereStr = " HDATE like '%" + searchTime + "%' ";
|
|
if (!string.IsNullOrEmpty(searchRest))
|
|
{
|
|
whereStr += " and REST = '" + searchRest + "'";
|
|
}
|
|
|
|
whereStr += " order by HDATE asc ";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable list = bll.GetList(whereStr).Tables[0];
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
|
|
returnstr += "}";
|
|
}
|
|
catch
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
//添加
|
|
private string Add(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = Guid.NewGuid().ToString("N");
|
|
string hdate = context.Request.Params["hdate"];
|
|
string name = context.Request.Params["name"];
|
|
string rest = context.Request.Params["rest"];
|
|
|
|
FangYar.Model.OA.OA_HOLIDAY model = new FangYar.Model.OA.OA_HOLIDAY();
|
|
model.ID = ID;
|
|
model.HDATE = hdate;
|
|
model.NAME = name;
|
|
model.REST = rest;
|
|
model.HOLIDAY = "true";
|
|
|
|
string whereStr = " HDATE='" + hdate + "'";
|
|
|
|
DataTable dt = bll.GetList(whereStr).Tables[0];
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
msg = "添加失败,请在列表中修改!";
|
|
}
|
|
else
|
|
{
|
|
if (bll.Add(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "添加失败!"; }
|
|
}
|
|
|
|
}
|
|
catch
|
|
{
|
|
msg = "添加失败";
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
//修改
|
|
private string Edit(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
string hdate = context.Request.Params["hdate"];
|
|
string name = context.Request.Params["name"];
|
|
string rest = context.Request.Params["rest"];
|
|
|
|
FangYar.Model.OA.OA_HOLIDAY model = new FangYar.Model.OA.OA_HOLIDAY();
|
|
model.ID = ID;
|
|
model.HDATE = hdate;
|
|
model.NAME = name;
|
|
model.REST = rest;
|
|
|
|
if (bll.Update(model))
|
|
{
|
|
msg = "编辑成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "编辑失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
//修改
|
|
private string Del(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
|
|
if (bll.Delete(ID))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "删除失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|