|
|
@@ -0,0 +1,259 @@
|
|
|
+<%@ WebHandler Language="C#" Class="post" %>
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Web;
|
|
|
+using System.Web.SessionState;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Collections.Specialized;
|
|
|
+using System.Data;
|
|
|
+using Curtain.DataAccess;
|
|
|
+using DK.XuWei.WebMes;
|
|
|
+
|
|
|
+/// <summary>
|
|
|
+///
|
|
|
+/// xuwei create 2020-01-14
|
|
|
+/// </summary>
|
|
|
+public class post : IHttpHandler, IReadOnlySessionState
|
|
|
+{
|
|
|
+ public void ProcessRequest(HttpContext context)
|
|
|
+ {
|
|
|
+ context.Response.ContentType = "text/plain";
|
|
|
+
|
|
|
+ if (mes.LoginCheck() && context.Request["m"] is object)
|
|
|
+ {
|
|
|
+ Button b = new Button();
|
|
|
+ if(mes.RightCheck("系统管理"))
|
|
|
+ {
|
|
|
+ b.btnIndex = true;
|
|
|
+ b.btnInsert = true;
|
|
|
+ b.btnInsertBatch = true;
|
|
|
+ b.btnCopy = true;
|
|
|
+ b.btnUpdate = true;
|
|
|
+ b.btnDelete = true;
|
|
|
+ b.btnCancel = true;
|
|
|
+ b.btnSearch = true;
|
|
|
+ b.btnDetail = true;
|
|
|
+ b.btnCheckbox = true;
|
|
|
+ b.btnExport = false;
|
|
|
+ b.btnReload = true;
|
|
|
+ };
|
|
|
+ switch (context.Request["m"].ToString().ToLower())
|
|
|
+ {
|
|
|
+ case "b":
|
|
|
+ {
|
|
|
+ //按钮
|
|
|
+ context.Response.Write(new JsonResult(b).ToJson());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "a":
|
|
|
+ {
|
|
|
+ //添加
|
|
|
+ if (b.btnDetail && context.Request["id"].ToString() != "")
|
|
|
+ context.Response.Write(detail());
|
|
|
+ else
|
|
|
+ {
|
|
|
+ xRecord r = new xRecord();
|
|
|
+ context.Response.Write(new JsonResult(r).ToJson());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "s":
|
|
|
+ {
|
|
|
+ //搜索
|
|
|
+ if (b.btnIndex)
|
|
|
+ context.Response.Write(search(context.Request.Form));
|
|
|
+ else
|
|
|
+ context.Response.Write(new JsonResult(JsonStatus.rightError).ToJson());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "t":
|
|
|
+ {
|
|
|
+ //详细
|
|
|
+ if (b.btnDetail)
|
|
|
+ context.Response.Write(detail());
|
|
|
+ else
|
|
|
+ context.Response.Write(new JsonResult(JsonStatus.rightError).ToJson());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "i":
|
|
|
+ {
|
|
|
+ //插入
|
|
|
+ if (b.btnInsert)
|
|
|
+ context.Response.Write(insert(context.Request.Form));
|
|
|
+ else
|
|
|
+ context.Response.Write(new JsonResult(JsonStatus.rightError).ToJson());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ case "d":
|
|
|
+ {
|
|
|
+ //删除
|
|
|
+ if (b.btnDelete)
|
|
|
+ context.Response.Write(delete());
|
|
|
+ else
|
|
|
+ context.Response.Write(new JsonResult(JsonStatus.rightError).ToJson());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "e":
|
|
|
+ {
|
|
|
+ //导出
|
|
|
+ if (b.btnExport)
|
|
|
+ {
|
|
|
+ context.Response.Write(export());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ context.Response.Write(new JsonResult(JsonStatus.rightError).ToJson());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ context.Response.Write(new JsonResult(JsonStatus.loginError).ToJson());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>json</returns>
|
|
|
+ private string search(NameValueCollection form)
|
|
|
+ {
|
|
|
+ using(IDataAccess conn=DataAccess.Create())
|
|
|
+ {
|
|
|
+ int page = HttpContext.Current.Request["page"] is object ? Convert.ToInt32(HttpContext.Current.Request["page"]) : 1;
|
|
|
+ int rows = HttpContext.Current.Request["rows"] is object ? Convert.ToInt32(HttpContext.Current.Request["rows"]) : 10;
|
|
|
+ string sort = HttpContext.Current.Request["sort"] is object ? HttpContext.Current.Request["sort"] : "POSTCODE";
|
|
|
+ string order = HttpContext.Current.Request["order"] is object ? HttpContext.Current.Request["order"] : "";
|
|
|
+
|
|
|
+ string sqlStr = @"
|
|
|
+ SELECT
|
|
|
+ TO_CHAR(m.DAY_YMD_START,'yyyy-mm-dd') DAYYMDSTART,
|
|
|
+ TO_CHAR(m.DAY_YMD_END,'yyyy-mm-dd') DAYYMDEND
|
|
|
+ FROM
|
|
|
+ TP_HOLIDAY_CONFIG m
|
|
|
+ ";
|
|
|
+ List<CDAParameter> sqlPara = new List<CDAParameter>();
|
|
|
+ int total = 0;
|
|
|
+ DataTable dt = conn.SelectPages(page, rows,out total, sqlStr, sqlPara.ToArray());
|
|
|
+ return new JsonResult(dt) { total = total}.ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 详细
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>json</returns>
|
|
|
+ private string detail()
|
|
|
+ {
|
|
|
+ using(IDataAccess conn= DataAccess.Create())
|
|
|
+ {
|
|
|
+ List<CDAParameter> sqlPara = new List<CDAParameter>();
|
|
|
+ DataTable dt = conn.ExecuteDatatable(@"
|
|
|
+ SELECT
|
|
|
+ TO_CHAR(m.DAY_YMD_START,'yyyy-mm-dd') DAYYMDSTART,
|
|
|
+ TO_CHAR(m.DAY_YMD_END,'yyyy-mm-dd') DAYYMDEND
|
|
|
+ FROM
|
|
|
+ TP_HOLIDAY_CONFIG m
|
|
|
+ ",
|
|
|
+ sqlPara.ToArray()
|
|
|
+ );
|
|
|
+ return new JsonResult(dt).ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 插入
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>json</returns>
|
|
|
+ private string insert(NameValueCollection form)
|
|
|
+ {
|
|
|
+ using(IDataAccess conn= DataAccess.Create())
|
|
|
+ {
|
|
|
+ int result = conn.ExecuteNonQuery(@"
|
|
|
+ INSERT INTO TP_HOLIDAY_CONFIG (
|
|
|
+ DAY_YMD_START,
|
|
|
+ DAY_YMD_END
|
|
|
+ ) VALUES ( @DAYYMDSTART@,@DAYYMDEND@ ) ",
|
|
|
+ new CDAParameter("DAYYMDSTART",form["DAYYMDSTART"].ToString()),
|
|
|
+ new CDAParameter("DAYYMDEND",form["DAYYMDEND"].ToString())
|
|
|
+ );
|
|
|
+ return new JsonResult(JsonStatus.success).ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>json</returns>
|
|
|
+ private string delete()
|
|
|
+ {
|
|
|
+ using(IDataAccess conn= DataAccess.Create())
|
|
|
+ {
|
|
|
+ if (HttpContext.Current.Request["id"] is object)
|
|
|
+ {
|
|
|
+ int result = conn.ExecuteNonQuery(@"
|
|
|
+ DELETE
|
|
|
+ TP_HOLIDAY_CONFIG
|
|
|
+ WHERE
|
|
|
+ DAY_YMD_START = @POSTID@ ",
|
|
|
+ new CDAParameter("DAYYMDSTART", HttpContext.Current.Request["DAYYMDSTART"].ToString())
|
|
|
+ );
|
|
|
+ return new JsonResult(JsonStatus.success).ToJson();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new JsonResult(JsonStatus.otherError).ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 导出
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>json</returns>
|
|
|
+ private string export()
|
|
|
+ {
|
|
|
+ return search(new NameValueCollection());
|
|
|
+ }
|
|
|
+
|
|
|
+ private class Button
|
|
|
+ {
|
|
|
+ public bool btnIndex = false;
|
|
|
+ public bool btnInsert = false;
|
|
|
+ public bool btnInsertBatch = false;
|
|
|
+ public bool btnCopy = false;
|
|
|
+ public bool btnUpdate = false;
|
|
|
+ public bool btnDelete = false;
|
|
|
+ public bool btnCancel = false;
|
|
|
+ public bool btnSearch = false;
|
|
|
+ public bool btnDetail = false;
|
|
|
+ public bool btnCheckbox = false;
|
|
|
+ public bool btnExport = false;
|
|
|
+ public bool btnReload = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private class xRecord
|
|
|
+ {
|
|
|
+ public string sid { get; set; }
|
|
|
+ public string POSTCODE { get; set; }
|
|
|
+ public string POSTNAME { get; set; }
|
|
|
+ public string REMARKS { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool IsReusable
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|