|
|
@@ -0,0 +1,207 @@
|
|
|
+<%@ WebHandler Language="C#" Class="Goodsnew" %>
|
|
|
+
|
|
|
+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;
|
|
|
+
|
|
|
+public class Goodsnew : IHttpHandler, IReadOnlySessionState
|
|
|
+{
|
|
|
+ public void ProcessRequest(HttpContext context)
|
|
|
+ {
|
|
|
+ context.Response.ContentType = "text/plain";
|
|
|
+
|
|
|
+ if (mes.LoginCheck() && context.Request["m"] is object)
|
|
|
+ {
|
|
|
+ Button b = new Button();
|
|
|
+
|
|
|
+ b.btnIndex = true;
|
|
|
+ b.btnInsert = true;
|
|
|
+ b.btnDelete = true;
|
|
|
+ b.btnSearch = true;
|
|
|
+
|
|
|
+ switch (context.Request["m"].ToString().ToLower())
|
|
|
+ {
|
|
|
+ case "b":
|
|
|
+ {
|
|
|
+ //按钮
|
|
|
+ context.Response.Write(new JsonResult(b).ToJson());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "i":
|
|
|
+ {
|
|
|
+ //插入
|
|
|
+ if (b.btnInsert)
|
|
|
+ context.Response.Write(insertGood(context.Request.Form));
|
|
|
+ else
|
|
|
+ context.Response.Write(new JsonResult(JsonStatus.rightError).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 "d":
|
|
|
+ {
|
|
|
+ //删除
|
|
|
+ if (b.btnDelete)
|
|
|
+ context.Response.Write(delete());
|
|
|
+ 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 insertGood(NameValueCollection form)
|
|
|
+ {
|
|
|
+ using (IDataAccess conn = DataAccess.Create())
|
|
|
+ {
|
|
|
+ DataTable dt = conn.ExecuteDatatable(@"
|
|
|
+ SELECT
|
|
|
+ m.GOODSID
|
|
|
+ FROM
|
|
|
+ TP_MST_GOODS m
|
|
|
+ WHERE
|
|
|
+ m.GOODSCODE = @GOODSCODE@
|
|
|
+ ",
|
|
|
+ new CDAParameter("GOODSCODE", form["GOOSDCODE"])
|
|
|
+ );
|
|
|
+
|
|
|
+ if (dt != null && dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ int result = conn.ExecuteNonQuery(@"
|
|
|
+ INSERT INTO TP_MST_GOODSNEW (
|
|
|
+ GOODSID,
|
|
|
+ GOODCODE
|
|
|
+ ) VALUES (
|
|
|
+ @GOODSID@,
|
|
|
+ @GOODCODE@
|
|
|
+ )
|
|
|
+ ",
|
|
|
+ new CDAParameter("GOODSID", dt.Rows[0]["GOODSID"]),
|
|
|
+ new CDAParameter("GOODCODE", form["GOOSDCODE"])
|
|
|
+ );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new JsonResult("新品入仓失败").ToJson();
|
|
|
+ }
|
|
|
+ return new JsonResult(JsonStatus.success).ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// TP_PM_Offline 查询
|
|
|
+ /// </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"] : "";
|
|
|
+ string order = HttpContext.Current.Request["order"] is object ? HttpContext.Current.Request["order"] : "";
|
|
|
+
|
|
|
+ string sqlStr = @"
|
|
|
+ SELECT
|
|
|
+ GOODSID AS SID,
|
|
|
+ GOODSID,
|
|
|
+ GOODCODE
|
|
|
+ FROM TP_MST_GOODSNEW
|
|
|
+ ";
|
|
|
+ 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>
|
|
|
+ /// 删除 TP_PM_Offline
|
|
|
+ /// </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_MST_GOODSNEW
|
|
|
+ WHERE
|
|
|
+ INSTR(',' || @GOODSID@ || ',' , ',' || GOODSID || ',') > 0
|
|
|
+ ",
|
|
|
+ new CDAParameter("GOODSID", HttpContext.Current.Request["id"])
|
|
|
+ );
|
|
|
+ return new JsonResult(JsonStatus.success).ToJson();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new JsonResult(JsonStatus.otherError).ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 导出 TP_PM_Offline
|
|
|
+ /// </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 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 GOODSCODE { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool IsReusable
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|