|
|
@@ -0,0 +1,371 @@
|
|
|
+<%@ WebHandler Language="C#" Class="batchscrap" %>
|
|
|
+
|
|
|
+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>
|
|
|
+/// TP_PM_BATCHSCRAPLOG 批量报损
|
|
|
+/// xuwei create 2024-05-10
|
|
|
+/// </summary>
|
|
|
+public class batchscrap : 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 = false;
|
|
|
+ b.btnInsertBatch = false;
|
|
|
+ b.btnCopy = false;
|
|
|
+ b.btnUpdate = true;
|
|
|
+ b.btnDelete = true;
|
|
|
+ b.btnCancel = true;
|
|
|
+ b.btnSearch = true;
|
|
|
+ b.btnDetail = true;
|
|
|
+ b.btnCheckbox = true;
|
|
|
+ b.btnExport = true;
|
|
|
+ b.btnReload = true;
|
|
|
+ b.btnBatchScrap = 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"] is object)
|
|
|
+ context.Response.Write(detail());
|
|
|
+ else
|
|
|
+ {
|
|
|
+ List<xRecord> list = new List<xRecord>();
|
|
|
+ xRecord r = new xRecord();
|
|
|
+ list.Add(r);
|
|
|
+ context.Response.Write(new JsonResult(list).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 "u":
|
|
|
+ {
|
|
|
+ //修改
|
|
|
+ if (b.btnUpdate)
|
|
|
+ context.Response.Write(update(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>
|
|
|
+ /// TP_PM_BATCHSCRAPLOG 查询
|
|
|
+ /// </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
|
|
|
+ m.GUID AS SID,
|
|
|
+ m.GUID,
|
|
|
+ m.BARCODE,
|
|
|
+ m.SUCCESS,
|
|
|
+ m.REMARKS,
|
|
|
+ m.VALUEFLAG,
|
|
|
+ m.ACCOUNTID,
|
|
|
+ m.CREATEUSERID,
|
|
|
+ m.CREATETIME,
|
|
|
+ m.UPDATEUSERID,
|
|
|
+ m.UPDATETIME
|
|
|
+ FROM
|
|
|
+ TP_PM_BATCHSCRAPLOG m
|
|
|
+ WHERE
|
|
|
+ m.VALUEFLAG = '1'
|
|
|
+ AND m.ACCOUNTID = @ACCOUNTID@
|
|
|
+ ";
|
|
|
+ List<CDAParameter> sqlPara = new List<CDAParameter>();
|
|
|
+ sqlPara.Add(new CDAParameter("ACCOUNTID", HttpContext.Current.Session["accountId"]));
|
|
|
+
|
|
|
+ if(!string.IsNullOrEmpty(form["GUID"]))
|
|
|
+ {
|
|
|
+ sqlStr += " AND m.GUID = @GUID@ ";
|
|
|
+ sqlPara.Add(new CDAParameter("GUID", form["GUID"]));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!string.IsNullOrEmpty(form["BARCODE"]))
|
|
|
+ {
|
|
|
+ sqlStr += " AND INSTR( m.BARCODE, @BARCODE@ ) > 0 ";
|
|
|
+ sqlPara.Add(new CDAParameter("BARCODE", form["BARCODE"]));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!string.IsNullOrEmpty(form["SUCCESS"]))
|
|
|
+ {
|
|
|
+ sqlStr += " AND INSTR( m.SUCCESS, @SUCCESS@ ) > 0 ";
|
|
|
+ sqlPara.Add(new CDAParameter("SUCCESS", form["SUCCESS"]));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!string.IsNullOrEmpty(form["REMARKS"]))
|
|
|
+ {
|
|
|
+ sqlStr += " AND INSTR( m.REMARKS, @REMARKS@ ) > 0 ";
|
|
|
+ sqlPara.Add(new CDAParameter("REMARKS", form["REMARKS"]));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(sort != "")
|
|
|
+ {
|
|
|
+ sqlStr += " ORDER BY " + sort + " " + order;
|
|
|
+ }
|
|
|
+ int total = 0;
|
|
|
+ DataTable dt = conn.SelectPages(page, rows,out total, sqlStr, sqlPara.ToArray());
|
|
|
+ return new JsonResult(dt) { total = total}.ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 详细 TP_PM_BATCHSCRAPLOG
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>json</returns>
|
|
|
+ private string detail()
|
|
|
+ {
|
|
|
+ using(IDataAccess conn= DataAccess.Create())
|
|
|
+ {
|
|
|
+ DataTable dt = conn.ExecuteDatatable(@"
|
|
|
+ SELECT
|
|
|
+ m.GUID,
|
|
|
+ m.BARCODE,
|
|
|
+ m.SUCCESS,
|
|
|
+ m.REMARKS,
|
|
|
+ m.VALUEFLAG,
|
|
|
+ m.ACCOUNTID,
|
|
|
+ m.CREATEUSERID,
|
|
|
+ m.CREATETIME,
|
|
|
+ m.UPDATEUSERID,
|
|
|
+ m.UPDATETIME
|
|
|
+ FROM
|
|
|
+ TP_PM_BATCHSCRAPLOG m
|
|
|
+ WHERE
|
|
|
+ m.VALUEFLAG = '1'
|
|
|
+ AND m.ACCOUNTID = @ACCOUNTID@
|
|
|
+ AND m.GUID = @GUID@
|
|
|
+ ",
|
|
|
+ new CDAParameter("ACCOUNTID",HttpContext.Current.Session["accountId"]),
|
|
|
+ new CDAParameter("GUID",HttpContext.Current.Request["id"])
|
|
|
+ );
|
|
|
+ return new JsonResult(dt).ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 插入 TP_PM_BATCHSCRAPLOG
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>json</returns>
|
|
|
+ private string insert(NameValueCollection form)
|
|
|
+ {
|
|
|
+ using(IDataAccess conn= DataAccess.Create())
|
|
|
+ {
|
|
|
+ //string primaryKey = conn.GetSequenceNextval("SEQ_TP_PM_BATCHSCRAPLOG_ID").ToString();
|
|
|
+ int result = conn.ExecuteNonQuery(@"
|
|
|
+ INSERT INTO TP_PM_BATCHSCRAPLOG (
|
|
|
+ --GUID,
|
|
|
+ BARCODE,
|
|
|
+ SUCCESS,
|
|
|
+ REMARKS,
|
|
|
+ ACCOUNTID,CREATEUSERID,UPDATEUSERID
|
|
|
+ ) VALUES (
|
|
|
+ --@GUID@,
|
|
|
+ @BARCODE@,
|
|
|
+ @SUCCESS@,
|
|
|
+ @REMARKS@,
|
|
|
+ @ACCOUNTID@,@CREATEUSERID@,@UPDATEUSERID@
|
|
|
+ )
|
|
|
+ ",
|
|
|
+ //new CDAParameter("GUID",primaryKey),
|
|
|
+ new CDAParameter("BARCODE",form["BARCODE"]),
|
|
|
+ new CDAParameter("SUCCESS",form["SUCCESS"]),
|
|
|
+ new CDAParameter("REMARKS",form["REMARKS"]),
|
|
|
+ new CDAParameter("ACCOUNTID",HttpContext.Current.Session["accountId"]),
|
|
|
+ new CDAParameter("CREATEUSERID",HttpContext.Current.Session["userId"]),
|
|
|
+ new CDAParameter("UPDATEUSERID",HttpContext.Current.Session["userId"])
|
|
|
+ );
|
|
|
+ return new JsonResult(JsonStatus.success).ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 更新 TP_PM_BATCHSCRAPLOG
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>json</returns>
|
|
|
+ private string update(NameValueCollection form)
|
|
|
+ {
|
|
|
+ using(IDataAccess conn=DataAccess.Create())
|
|
|
+ {
|
|
|
+ int result = conn.ExecuteNonQuery(@"
|
|
|
+ UPDATE TP_PM_BATCHSCRAPLOG
|
|
|
+ SET
|
|
|
+ BARCODE = @BARCODE@,
|
|
|
+ SUCCESS = @SUCCESS@,
|
|
|
+ REMARKS = @REMARKS@,
|
|
|
+ UPDATEUSERID = @UPDATEUSERID@,
|
|
|
+ UPDATETIME = sysdate
|
|
|
+ WHERE
|
|
|
+ GUID = @GUID@
|
|
|
+ ",
|
|
|
+
|
|
|
+ new CDAParameter("BARCODE",form["BARCODE"]),
|
|
|
+ new CDAParameter("SUCCESS",form["SUCCESS"]),
|
|
|
+ new CDAParameter("REMARKS",form["REMARKS"]),
|
|
|
+ new CDAParameter("UPDATEUSERID",HttpContext.Current.Session["userId"]),
|
|
|
+ new CDAParameter("GUID",HttpContext.Current.Request["id"])
|
|
|
+ );
|
|
|
+ return new JsonResult(JsonStatus.success).ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除 TP_PM_BATCHSCRAPLOG
|
|
|
+ /// </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_PM_BATCHSCRAPLOG
|
|
|
+ WHERE
|
|
|
+ INSTR(',' || @GUID@ || ',' , ',' || GUID || ',') > 0
|
|
|
+ ",
|
|
|
+ new CDAParameter("GUID", HttpContext.Current.Request["id"])
|
|
|
+ );
|
|
|
+ return new JsonResult(JsonStatus.success).ToJson();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new JsonResult(JsonStatus.otherError).ToJson();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 导出 TP_PM_BATCHSCRAPLOG
|
|
|
+ /// </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;
|
|
|
+ public bool btnBatchScrap = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private class xRecord
|
|
|
+ {
|
|
|
+ public string sid { get; set; }
|
|
|
+ public string BARCODE { get; set; }
|
|
|
+ public string SUCCESS { get; set; }
|
|
|
+ public string REMARKS { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool IsReusable
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|