| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <%@ WebHandler Language="C#" Class="setTestFormGoods" %>
- using System;
- using System.Web;
- using System.Data;
- using Curtain.DataAccess;
- using DK.XuWei.WebMes;
- /// <summary>
- /// 添加产品到实验单
- /// xuwei add 2021-08-31
- /// </summary>
- public class setTestFormGoods : IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- using (IDataAccess conn = DataAccess.Create())
- {
- //实验单ID
- string testformid = context.Request["TESTFORMID"];
- //产品条码
- string barcode = context.Request["BARCODE"];
- //用户ID
- string usercode = context.Request["USERCODE"];
- //操作方式 add 添加 delete 删除
- string mode = context.Request["MODE"] is object ? context.Request["MODE"].ToString() : "";
- if (mode == "add")
- {
- //添加产品处理
- object result0 = conn.ExecuteScalar(@"
- SELECT DISTINCT 1 FROM TP_PM_TESTFORM2_GOODS WHERE TESTFORMGUID = @TESTFORMID@ AND BARCODE =@BARCODE@ AND VALUEFLAG = 1
- ",
- new CDAParameter("BARCODE", barcode),
- new CDAParameter("TESTFORMID", testformid)
- );
- string str = result0 + "";
-
- object result1 = conn.ExecuteScalar(@"
- SELECT DISTINCT 1 FROM TP_PM_GROUTINGDAILYDETAIL WHERE BARCODE =@BARCODE@ AND VALUEFLAG = 1
- ",
- new CDAParameter("BARCODE",barcode)
- ) ;
- string str1 = result1+ "";
- int result = 0;
- if (str == "1" || str1 == "")
- {
- if (str == "1")
- {
- context.Response.Write(new JsonResult() { success = false,message = "条码重复",total = 0,rows = "" }.ToJson()) ;
- }
- if (str1 == "")
- {
- context.Response.Write(new JsonResult() { success = false,message = "条码不存在",total = 0,rows = "" }.ToJson()) ;
- }
- }
- else
- {
- result = conn.ExecuteNonQuery(@"
- INSERT INTO TP_PM_TESTFORM2_GOODS (
- TESTFORMGUID,
- BARCODE,
- ACCOUNTID,CREATEUSERID,UPDATEUSERID
- ) SELECT
- @TESTFORMGUID@ AS TESTFORMGUID,
- @BARCODE@ AS BARCODE,
- 1 AS ACCOUNTID,
- (SELECT USERID FROM TP_MST_USER WHERE USERCODE = @USERCODE@) AS CREATEUSERID,
- (SELECT USERID FROM TP_MST_USER WHERE USERCODE = @USERCODE@) AS UPDATEUSERID
- FROM DUAL
- ",
- new CDAParameter("TESTFORMGUID",testformid),
- new CDAParameter("BARCODE",barcode),
- new CDAParameter("USERCODE", usercode)
- );
- int resultup = conn.ExecuteNonQuery(@"
- UPDATE TP_PM_GROUTINGDAILYDETAIL
- SET
- TESTFORMFLAG =1
- WHERE
- BARCODE = @BARCODE@
- ",
- new CDAParameter("BARCODE",barcode)
- );
- }
- if (result > 0)
- {
- context.Response.Write(new JsonResult() { success = true,message = "保存成功",total = result,rows = "" }.ToJson()) ;
- }
- else {
- //context.Response.Write(new JsonResult(JsonStatus.error).ToJson());
- context.Response.Write(new JsonResult() { success = false,message = "无相关测试单",total = 0,rows = "" }.ToJson()) ;
- }
- }
- if (mode == "delete")
- {
- int resultup = conn.ExecuteNonQuery(@"
- UPDATE TP_PM_GROUTINGDAILYDETAIL
- SET
- TESTFORMFLAG =0
- WHERE
- BARCODE = @BARCODE@
- ",
- new CDAParameter("BARCODE",barcode)
- );
- int result = conn.ExecuteNonQuery(@"
- DELETE
- TP_PM_TESTFORM2_GOODS
- WHERE
- VALUEFLAG = 1
- AND TESTFORMGUID = @TESTFORMID@
- AND BARCODE = @BARCODE@
- ",
- new CDAParameter("BARCODE", barcode),
- new CDAParameter("TESTFORMID", testformid)
- );
- if (result > 0)
- {
- context.Response.Write(new JsonResult() { success = true,message = "删除成功",total = result,rows = "" }.ToJson()) ;
- }
- else {
- //context.Response.Write(new JsonResult(JsonStatus.error).ToJson());
- context.Response.Write(new JsonResult() { success = false,message = "删除失败",total = 0,rows = "" }.ToJson()) ;
- }
- }
- context.Response.Write(new JsonResult(JsonStatus.success).ToJson());
- }
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
|