From c2a9a460e38c7c196fe98a94e29e6330eac3626f Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 03 三月 2023 14:30:06 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/Sc_MouldRepairInBillListController.cs | 1295 ++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 927 insertions(+), 368 deletions(-)

diff --git a/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs b/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
index 3c105dc..63e2e3d 100644
--- a/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
+++ b/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
@@ -1,9 +1,11 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Web.Http;
+using ViewAPI;
 using WebAPI.Models;
 namespace WebAPI.Controllers
 {
@@ -183,28 +185,47 @@
         /// <returns></returns>
         [Route("Sc_MouldMaintainBill/GetMouldMaintainBillList")]
         [HttpGet]
-        public object GetMouldMaintainBillList(string sWhere)
+        public object GetMouldMaintainBillList(string sWhere,string user)
         {
             try
             {
+                List<object> columnNameList = new List<object>();
 
-                ds = Sc_MouldMaintainBillList_s(sWhere);
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBillList", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                else
+
+                ds = Sc_MouldMaintainBillList_s(sWhere);
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception ex)
             {
@@ -223,12 +244,12 @@
         {
             if (sWhere == null || sWhere.Equals(""))
             {
-                return new SQLHelper.ClsCN().RunProcReturn("select *  from h_v_Sc_MouldMaintain order by 鏃ユ湡 desc", "h_v_Sc_MouldMaintain");
+                return new SQLHelper.ClsCN().RunProcReturn("select *  from h_v_Sc_MouldMaintain order by hmainid desc", "h_v_Sc_MouldMaintain");
             }
             else
             {
                 string sql1 = "select * from h_v_Sc_MouldMaintain where 1 = 1 ";
-                string sql = sql1 + sWhere + "order by 鏃ユ湡 desc";
+                string sql = sql1 + sWhere + "order by hmainid desc";
                 return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldMaintain");
 
             }
@@ -244,28 +265,28 @@
         /// <returns></returns>
         [Route("Sc_MouldDotCheckPlanBill/GetMouldDotCheckPlanBillList")]
         [HttpGet]
-        public object GetMouldDotCheckPlanBillList(string sWhere)
+        public object GetMouldDotCheckPlanBillList(string sWhere,string user)
         {
             try
             {
-
-                ds = Sc_MouldDotCheckPlanBillList_s(sWhere);
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckPlanBillList", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+
+                ds = Sc_MouldDotCheckPlanBillList_s(sWhere);
+
+               
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+              
             }
             catch (Exception ex)
             {
@@ -282,7 +303,7 @@
 
         public static DataSet Sc_MouldDotCheckPlanBillList_s(string sWhere)
         {
-            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldDotCheckPlanBillList order by 鏃ユ湡 desc", "h_v_Sc_MouldDotCheckPlanBillList");
+            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldDotCheckPlanBillList where 1=1 "+sWhere+ " order by hmainid desc", "h_v_Sc_MouldDotCheckPlanBillList");
         }
         #endregion
 
@@ -292,28 +313,37 @@
         /// <returns></returns>
         [Route("Sc_MouldDotCheckBill/GetMouldDotCheckBillList")]
         [HttpGet]
-        public object GetMouldDotCheckBillList(string sWhere)
+        public object GetMouldDotCheckBillList(string sWhere,string user)
         {
             try
             {
-
-                ds = Sc_MouldDotCheckBillList_s(sWhere);
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckBillList", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                else
+                ds = Sc_MouldDotCheckBillList_s(sWhere);
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
+
+                
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+
+                return objJsonResult;
             }
             catch (Exception ex)
             {
@@ -330,7 +360,7 @@
 
         public static DataSet Sc_MouldDotCheckBillList_s(string sWhere)
         {
-            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldDotCheckBillList where 1=1 " + sWhere + "order by 鏃ユ湡 desc", "h_v_Sc_MouldDotCheckBillList");
+            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldDotCheckBillList where 1=1 " + sWhere + "order by hmainid desc", "h_v_Sc_MouldDotCheckBillList");
         }
         #endregion
 
@@ -390,28 +420,37 @@
         /// <returns></returns>
         [Route("Sc_MouldMaintainPlanBill/GetMouldMaintainPlanBillList")]
         [HttpGet]
-        public object GetMouldMaintainPlanBillList(string sWhere)
+        public object GetMouldMaintainPlanBillList(string sWhere,string user)
         {
             try
             {
-
-                ds = Sc_MouldMaintainPlanBillList_s(sWhere);
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainPlanBillList", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+
+                ds = Sc_MouldMaintainPlanBillList_s(sWhere);
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception ex)
             {
@@ -428,7 +467,7 @@
 
         public static DataSet Sc_MouldMaintainPlanBillList_s(string sWhere)
         {
-            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldMaintainPlanBillList where 1=1 "+sWhere+" order by 鏃ユ湡 desc", "h_v_Sc_MouldMaintainPlanBillList");
+            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldMaintainPlanBillList where 1=1 "+sWhere+ " order by hmainid desc", "h_v_Sc_MouldMaintainPlanBillList");
         }
         #endregion
 
@@ -439,16 +478,35 @@
         /// <returns></returns>
         [Route("Sc_MouldConkBookBill/GetMouldConkBookBillList")]
         [HttpGet]
-        public object GetMouldConkBookBillList(string sWhere)
+        public object GetMouldConkBookBillList(string sWhere,string user)
         {
             try
             {
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBillList", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
                 ds = Sc_MouldConkBookBillList_s(sWhere);
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "Sucess锛�";
                 objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
                 return objJsonResult;
             }
             catch (Exception ex)
@@ -469,7 +527,7 @@
             DataSet ds;
             if (sWhere == null || sWhere.Equals(""))
             {
-                ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldConkBookBillList order by 鏃ユ湡 desc" + sWhere, "h_v_Sc_MouldConkBookBillList");
+                ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldConkBookBillList where 1=1 " + sWhere+ " order by hmainid desc", "h_v_Sc_MouldConkBookBillList");
             }
             else
             {
@@ -489,11 +547,21 @@
         /// <returns></returns>
         [Route("Sc_MouldRepairCheckBill/GetMouldRepairCheckBillList")]
         [HttpGet]
-        public object GetMouldRepairCheckBillList(string sWhere)
+        public object GetMouldRepairCheckBillList(string sWhere,string user)
         {
             try
             {
+                if (!DBUtility.ClsPub.Security_Log("Sb_EquipRepairCheckBillList", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 ds = Sc_MouldRepairCheckBillList_s(sWhere);
+
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
@@ -519,12 +587,12 @@
             DataSet ds;
             if (sWhere == null || sWhere.Equals(""))
             {
-                ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairCheckBillList_Edit order by 鏃ユ湡 desc" + sWhere, "h_v_Sc_MouldRepairCheckBillList_Edit");
+                ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairCheckBillList_Edit where 1=1" + sWhere+ " order by hmainid desc", "h_v_Sc_MouldRepairCheckBillList_Edit");
             }
             else
             {
                 string sql1 = "select * from h_v_Sc_MouldRepairCheckBillList_Edit where 1 = 1 ";
-                string sql = sql1 + sWhere + "order by 鏃ユ湡 desc";
+                string sql = sql1 + sWhere + "order by hmainid desc";
                 ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairCheckBillList_Edit");
             }
             return ds;
@@ -595,28 +663,47 @@
         /// <returns></returns>
         [Route("Sb_MouldRepairWorkBill/GetMouldRepairWorkBillList")]
         [HttpGet]
-        public object GetMouldRepairWorkBillList(string sWhere)
+        public object GetMouldRepairWorkBillList(string sWhere,string user)
         {
             try
             {
-
-                ds = Sc_MouldRepairWorkBillList_s(sWhere);
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                else
+
+                ds = Sc_MouldRepairWorkBillList_s(sWhere);
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception ex)
             {
@@ -635,12 +722,12 @@
         {
             if (sWhere == null || sWhere.Equals(""))
             {
-                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairWorkBillList order by 鏃ユ湡 desc" + sWhere, "h_v_Sc_MouldRepairWorkBillList");
+                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairWorkBillList where 1=1 " + sWhere+ " order by hmainid desc", "h_v_Sc_MouldRepairWorkBillList");
             }
             else
             {
                 string sql1 = "select * from h_v_Sc_MouldRepairWorkBillList where 1 = 1 ";
-                string sql = sql1 + sWhere + "order by 鏃ユ湡 desc";
+                string sql = sql1 + sWhere + "order by hmainid desc";
                 return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList");
             }
         }
@@ -751,35 +838,36 @@
         /// <returns></returns>
         [Route("Kf_MoveStockBill/GetMoveStockBillList")]
         [HttpGet]
-        public object GetMoveStockBillList(string sWhere)
+        public object GetMoveStockBillList(string sWhere,string user)
         {
             try
             {
-                if (sWhere == null || sWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select * from h_v_IF_MoveStockBillList order by 鏃ユ湡 desc", "h_v_IF_MoveStockBillList");
-                }
-                else
-                {
-                    string sql = "select * from h_v_IF_MoveStockBillList where 1=1 " + sWhere+ "order by 鏃ユ湡 desc";
-                    ds = oCN.RunProcReturn(sql, "h_v_IF_MoveStockBillList");
-                }
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockBillQuery", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄�!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_IF_MoveStockBillList order by hmainid desc", "h_v_IF_MoveStockBillList");
+                }
                 else
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
+                    string sql = "select * from h_v_IF_MoveStockBillList where 1=1 " + sWhere+ "order by hmainid desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_IF_MoveStockBillList");
                 }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+              
             }
             catch (Exception ex)
             {
@@ -791,34 +879,84 @@
             }
         }
 
+
+        #region 璋冩嫧鍗�  鍒犻櫎
+        [Route("Kf_MoveStockBill/DelteteGetMoveStockBill")]
+        [HttpGet]
+        public object DelteteGetMoveStockBill(string HInterID, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockBill_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬垹闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+                oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
+                oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         /// <summary>
         /// 閿�鍞嚭搴撳崟鍒楄〃
         /// </summary>
         /// <returns></returns>
         [Route("Kf_SellOutBill/GetSellOutBillList")]
         [HttpGet]
-        public object GetSellOutBillList(string sWhere)
+        public object GetSellOutBillList(string sWhere,string user)
         {
             try
             {
-
-                ds = Sc_GetSellOutBillList(sWhere);
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_SellOutBillQuery", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "娌℃湁鏌ヨ鏉冮檺!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+
+                ds = Sc_GetSellOutBillList(sWhere);
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception ex)
             {
@@ -835,10 +973,20 @@
         /// <returns></returns>
         [Route("Kf_SellOutBill/DeltetSellOutBill")]
         [HttpGet]
-        public object DeltetSeOutStockBackBill(string HInterID)
+        public object DeltetSeOutStockBackBill(string HInterID,string user)
         {
             try
             {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_SellOutBill_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬垹闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 oCN.BeginTran();
                 oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
                 oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
@@ -864,7 +1012,14 @@
 
         public static DataSet Sc_GetSellOutBillList(string sWhere)
         {
-            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_SellOutBillList order by 鏃ユ湡 desc", "h_v_IF_SellOutBillList");
+            if (sWhere == null || sWhere.Equals(""))
+            {
+                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_SellOutBillList order by hmainid desc", "h_v_IF_SellOutBillList");
+            }
+            else
+            {
+                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_SellOutBillList where 1=1 " + sWhere + " order by hmainid desc", "h_v_IF_SellOutBillList");
+            }
         }
         #endregion
 
@@ -875,36 +1030,46 @@
         /// <returns></returns>
         [Route("Kf_OtherOutBill/GetOtherOutBillList")]
         [HttpGet]
-        public object GetOtherOutBillList(string sWhere)
+        public object GetOtherOutBillList(string sWhere,string user)
         {
             try
             {
-                if (sWhere == null || sWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select * from h_v_Kf_OtherOutBillList where 1=1 order by 鏃ユ湡 desc", "h_v_Kf_OtherOutBillList");
-                }
-                else
-                {
-                    string sql = "select * from h_v_Kf_OtherOutBillList where 1 = 1 " + sWhere+ " order by 鏃ユ湡 desc";
-                    ds = oCN.RunProcReturn(sql, "h_v_Kf_OtherOutBillList");
-                }
-
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_OtherOutBillQuery", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄�!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_Kf_OtherOutBillList where 1=1 order by hmainid desc", "h_v_Kf_OtherOutBillList");
+                }
                 else
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
+                    string sql = "select * from h_v_Kf_OtherOutBillList where 1 = 1 " + sWhere+ " order by hmainid desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Kf_OtherOutBillList");
                 }
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception ex)
             {
@@ -916,6 +1081,44 @@
             }
         }
 
+        #region 鍏朵粬鍑哄簱鍗�  鍒犻櫎
+        [Route("Kf_OtherOutBill/DelteteGetOtherOutBill")]
+        [HttpGet]
+        public object DelteteGetOtherOutBill(string HInterID, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_OtherOutBill_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬垹闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+                oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
+                oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
 
         /// <summary>
         /// 濮斿鍑哄簱鍗曞垪琛�
@@ -1022,36 +1225,38 @@
         /// <returns></returns>
         [Route("Kf_ProductInBill/GetProductInBill")]
         [HttpGet]
-        public object GetProductInBill(string sWhere)
+        public object GetProductInBill(string sWhere,string user)
         {
             try
             {
-
-                if (sWhere == null || sWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select * from h_v_IF_ProductInBillList where 1=1  order by 鏃ユ湡 desc", "h_v_IF_ProductInBillList");
-                }
-                else
-                {
-                    string sql = "select * from h_v_IF_ProductInBillList where 1 = 1 " + sWhere + " order by 鏃ユ湡 desc";
-                    ds = oCN.RunProcReturn(sql, "h_v_IF_ProductInBillList");
-                }
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_ProductInBill_Query", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄�!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_IF_ProductInBillList where 1=1  order by hmainid desc", "h_v_IF_ProductInBillList");
+                }
                 else
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
+                    string sql = "select * from h_v_IF_ProductInBillList where 1 = 1 " + sWhere + " order by hmainid desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_IF_ProductInBillList");
                 }
+
+             
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+               
             }
             catch (Exception ex)
             {
@@ -1062,7 +1267,37 @@
                 return objJsonResult;
             }
         }
-     
+
+        #region 鏉$爜鏄庣粏
+        [Route("Kf_ICStockBillSub_WMS/Kf_ICStockBillSub_WMS_List")]
+        [HttpGet]
+        public object Kf_ICStockBillSub_WMS_List(string sWhere, string user)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn(@"Select m.HNumber 鐗╂枡浠g爜,m.HName 鐗╂枡鍚嶇О,m.HModel 瑙勬牸鍨嬪彿
+                                    ,wms.HBarCode 鏉$爜,wms.HQty 鏁伴噺,w.HNumber 浠撳簱浠g爜,w.HName 浠撳簱鍚嶇О from Kf_ICStockBillSub_WMS wms
+                                    left join h_v_IF_Material m on wms.HMaterID = m.HItemID
+                                    left join h_v_IF_Warehouse w on wms.HWhID = w.HItemID where 1=1 "+ sWhere, "Kf_ICStockBillSub_WMS");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+             
+            }
+            catch (Exception ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         /// <summary>
         ///浜у搧鍏ュ簱鍗曞垹闄ゅ姛鑳�
         /// </summary>
@@ -1102,36 +1337,46 @@
         /// <returns></returns>
         [Route("Kf_OtherInBill/GetOtherInBill")]
         [HttpGet]
-        public object GetOtherInBill(string sWhere)
+        public object GetOtherInBill(string sWhere,string user)
         {
             try
             {
-
-                if (sWhere == null || sWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select * from h_v_Kf_OtherInBillList where 1=1  order by 鏃ユ湡 desc", "h_v_Kf_OtherInBillList");
-                }
-                else
-                {
-                    string sql = "select * from h_v_Kf_OtherInBillList where 1 = 1 " + sWhere+ " order by 鏃ユ湡 desc";
-                    ds = oCN.RunProcReturn(sql, "h_v_Kf_OtherInBillList");
-                }
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_OtherInBillQuery", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄�!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_Kf_OtherInBillList where 1=1  order by hmainid desc", "h_v_Kf_OtherInBillList");
+                }
                 else
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
+                    string sql = "select * from h_v_Kf_OtherInBillList where 1 = 1 " + sWhere+ " order by hmainid desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Kf_OtherInBillList");
                 }
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception ex)
             {
@@ -1149,35 +1394,45 @@
         /// <returns></returns>
         [Route("Kf_EntrustInBill/GetEntrustInBill")]
         [HttpGet]
-        public object GetEntrustInBill(string sWhere)
+        public object GetEntrustInBill(string sWhere,string user)
         {
             try
             {
-                if (sWhere == null || sWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select * from h_v_Kf_EntrustInBillList where 1=1", "h_v_Kf_EntrustInBillList");
-                }
-                else
-                {
-                    string sql = "select * from h_v_Kf_EntrustInBillList where 1 = 1 " + sWhere;
-                    ds = oCN.RunProcReturn(sql, "h_v_Kf_EntrustInBillList");
-                }
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_EntrustInBillQuery", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇�!";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_Kf_EntrustInBillList where 1=1 order by hmainid desc", "h_v_Kf_EntrustInBillList");
+                }
                 else
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
+                    string sql = "select * from h_v_Kf_EntrustInBillList where 1 = 1 " + sWhere+ " order by hmainid desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Kf_EntrustInBillList");
                 }
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception ex)
             {
@@ -1220,7 +1475,7 @@
         #endregion
 
 
-        #region 妯″叿缁翠慨鍗曚繚瀛�/缂栬緫
+        #region 妯″叿缁翠慨璁板綍鍗曚繚瀛�/缂栬緫
         /// <summary>
         /// 淇濆瓨妯″叿缁翠慨鍗�
         /// </summary>
@@ -1235,12 +1490,23 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
+            string msg4 = sArray[2].ToString();
+            string msg5 = sArray[3].ToString();
 
 
             string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
+                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 DAL.ClsSb_MouldRepairWorkBill oBill = new DAL.ClsSb_MouldRepairWorkBill();
                 List<Model.ClsSb_MouldRepairWorkBillMain> lsmain = new List<Model.ClsSb_MouldRepairWorkBillMain>();
                 msg2 = msg2.Replace("\\", "");
@@ -1298,24 +1564,62 @@
                 List<Model.ClsSb_MouldRepairWorkBillSub> ls = new List<Model.ClsSb_MouldRepairWorkBillSub>();
                 ls = oListModels.getObjectByJson_Gy_MouldRepairWorkBillSub(msg3);
                 int i = 0;
-                foreach (Model.ClsSb_MouldRepairWorkBillSub oItemSub in ls)
+                foreach (Model.ClsSb_MouldRepairWorkBillSub oItem in ls)
                 {
 
                     i++;
-                    oItemSub.HEntryID = i;
+                    oItem.HEntryID = i;
                     //oItemSub.HCloseMan = "";       //琛屽叧闂�
-                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
-                    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
+                    oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItem.HCloseType = false;   //鍏抽棴绫诲瀷
                     //oItemSub.HRemark = "";         //澶囨敞
-                    oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                    oItem.HRelationQty = 0;     //鍏宠仈鏁伴噺
                     //oItemSub.HRelationMoney = 0;   //鍏宠仈閲戦
                     //oItemSub.HRepairID = 0;       //缁翠慨椤圭洰
                     //oItemSub.HRepairExplanation ="";   //缁翠慨瑕佹眰
                     //oItemSub.HManagerID = 0;   //璐熻矗浜篒D
                     //oItemSub.HMoney = 0;        //缁翠慨璐圭敤
-                    oBill.DetailColl.Add(oItemSub);
+                    oBill.DetailColl.Add(oItem);
 
                 }
+
+                //閰嶄欢鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg5 = msg5.Substring(1, msg5.Length - 2);
+                msg5 = msg5.Replace("\\", "");
+                msg5 = msg5.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Model.ClsSb_MouldRepairWorkBillSub_Item> ls1 = new List<Model.ClsSb_MouldRepairWorkBillSub_Item>();
+                ls1 = oListModels.getObjectByJson_Gy_MouldRepairWorkBillSub_Item(msg5);
+                int j = 0;
+                foreach (Model.ClsSb_MouldRepairWorkBillSub_Item oItemSub in ls1)
+                {
+
+                    j++;
+                    oItemSub.HEntryID = j;
+                    //oItemSub.HCloseMan = "";       //琛屽叧闂�
+                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
+                    //oItemSub.HRemark = "";         //澶囨敞
+                    oItemSub.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                    oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+                    //oItemSub.HSourceBillNo = "";  //婧愬崟鍗曞彿
+                    //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷
+                    oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                    //oItemSub.HRelationMoney = 0;   //鍏宠仈閲戦
+                    //HMaterID = "";//閰嶄欢浠g爜
+                    //HUnitID = "";//鍗曚綅浠g爜
+                    //HQty = "";//瀹為檯鐢ㄩ噺
+                    //HQtyMust = "";//鍗曚綅鐢ㄩ噺
+                    //HRemark = "";//澶囨敞
+                    //oItemSub.HRepairID = 0;       //缁翠慨椤圭洰
+                    //oItemSub.HRepairExplanation ="";   //缁翠慨瑕佹眰
+                    //oItemSub.HManagerID = 0;   //璐熻矗浜篒D
+                    //oItemSub.HMoney = 0;        //缁翠慨璐圭敤
+                    oBill.DetailCol.Add(oItemSub);
+
+                }
+
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
@@ -1377,30 +1681,27 @@
         [HttpGet]
         public object Sb_MouldRepairWorkBillListProjectDetai(string sqlWhere)
         {
-            DataSet ds;
+            DataSet ds, ds1;
+            List<object> list = new List<object>();
             try
             {
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-                if (sqlWhere == null || sqlWhere.Equals(""))
-                {
-                    //ds = oCN.RunProcReturn("select HRepairID,HRepairExplanation,HManagerID,HMoney,HRemark   from Sc_MouldRepairWorkBillSub", "Sc_MouldRepairWorkBillSub");
-                    ds = oCN.RunProcReturn("select HRepairID, 瀛愮淮淇」鐩唬鐮� HRepairCode,瀛愮淮淇」鐩� HRepairName,瀛愮淮淇姹� HRepairExplanation,HManagerSonID HManagerID,瀛愯礋璐d汉浠g爜 HManagerCode,瀛愯礋璐d汉 HManagerName,缁翠慨璐圭敤 HMoney,琛ㄤ綋澶囨敞 HRemark,婧愬崟涓诲唴鐮� HSourceInterID,婧愬崟瀛愬唴鐮� HSourceEntryID,婧愬崟鍗曞彿 HSourceBillNo,婧愬崟绫诲瀷 HSourceBillType   from h_v_Sc_MouldRepairWorkBillList_Edit", "h_v_Sc_MouldRepairWorkBillList_Edit");
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                }
-                else
-                {
-                    //string sql1 = "select HRepairID,HRepairExplanation,HManagerID,HMoney,HRemark  from Sc_MouldRepairWorkBillSub where 1 = 1 ";
-                    string sql1 = "select HRepairID,瀛愮淮淇」鐩唬鐮� HRepairCode,瀛愮淮淇」鐩� HRepairName,瀛愮淮淇姹� HRepairExplanation,HManagerSonID HManagerID,瀛愯礋璐d汉浠g爜 HManagerCode,瀛愯礋璐d汉 HManagerName,缁翠慨璐圭敤 HMoney,琛ㄤ綋澶囨敞 HRemark,婧愬崟涓诲唴鐮� HSourceInterID,婧愬崟瀛愬唴鐮� HSourceEntryID,婧愬崟鍗曞彿 HSourceBillNo,婧愬崟绫诲瀷 HSourceBillType   from h_v_Sc_MouldRepairWorkBillList_Edit where 1 = 1 ";
-                    string sql = sql1 + sqlWhere;
-                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList_Edit");
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                }
+
+                string sql = "select HRepairID,瀛愮淮淇」鐩唬鐮� HRepairCode,瀛愮淮淇」鐩� HRepairName,瀛愮淮淇姹� HRepairExplanation,HManagerSonID HManagerID,瀛愯礋璐d汉浠g爜 HManagerCode,瀛愯礋璐d汉 HManagerName,缁翠慨璐圭敤 HMoney,琛ㄤ綋澶囨敞 HRemark,婧愬崟涓诲唴鐮� HSourceInterID,婧愬崟瀛愬唴鐮� HSourceEntryID,婧愬崟鍗曞彿 HSourceBillNo,婧愬崟绫诲瀷 HSourceBillType   from h_v_Sc_MouldRepairWorkBillList_Edit where 1 = 1 "+ sqlWhere;
+                ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList_Edit");
+
+                string sql1 = "select 閰嶄欢ID HMaterID, 閰嶄欢浠g爜 HMaterNumber,閰嶄欢鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,鍗曚綅ID HUnitID,璁¢噺鍗曚綅浠g爜 HUnitNumber,璁¢噺鍗曚綅鍚嶇О HUnitName,鐢ㄩ噺 HQty,鏍囧噯鐢ㄩ噺 HQtyMust,瀛愬娉�1 HRemark,瑙勬牸鍨嬪彿 HMaterSpec  from h_v_Sc_MouldRepairWorkBillSub_Item  where 1 = 1 " + sqlWhere ;
+                ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldRepairWorkBillSub_Item");
+
+                list.Add(ds.Tables[0]);
+                list.Add(ds1.Tables[0]);
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                objJsonResult.data = null;
+                objJsonResult.list = list;
+
             }
             catch (Exception e)
             {
@@ -1420,17 +1721,17 @@
         /// <returns></returns>
         [Route("Sb_MouldRepairWorkBill/DeltetMouldRepairWorkBill")]
         [HttpGet]
-        public object DeltetMouldRepairWorkBill(string HInterID)
+        public object DeltetMouldRepairWorkBill(string HInterID,string user)
         {
             //缂栬緫鏉冮檺
-            //if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Delete", 1, false, DBUtility.ClsPub.CurUserName))
-            //{
-            //    objJsonResult.code = "0";
-            //    objJsonResult.count = 0;
-            //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-            //    objJsonResult.data = null;
-            //    return objJsonResult;
-            //}
+            if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
 
             Int64 lngBillKey = 0;
@@ -1656,6 +1957,15 @@
             ListModels oListModels = new ListModels();
             try
             {
+                if (!DBUtility.ClsPub.Security_Log("Sb_EquipRepairCheckBill_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 DLL.ClsSc_MouldRepairCheckBill oBill = new DLL.ClsSc_MouldRepairCheckBill();
                 List<Model.ClsSc_MouldRepairCheckBillMain> lsmain = new List<Model.ClsSc_MouldRepairCheckBillMain>();
                 msg2 = msg2.Replace("\\", "");
@@ -1839,17 +2149,17 @@
         /// <returns></returns>
         [Route("Sc_MouldRepairCheckBill/DeltetMouldRepairCheckBill")]
         [HttpGet]
-        public object DeltetMouldRepairCheckBill(string HInterID)
+        public object DeltetMouldRepairCheckBill(string HInterID,string user)
         {
             //缂栬緫鏉冮檺
-            //if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairCheckBill_Delete", 1, false, DBUtility.ClsPub.CurUserName))
-            //{
-            //    objJsonResult.code = "0";
-            //    objJsonResult.count = 0;
-            //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-            //    objJsonResult.data = null;
-            //    return objJsonResult;
-            //}
+            if (!DBUtility.ClsPub.Security_Log("Sb_EquipRepairCheckBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
 
             Int64 lngBillKey = 0;
@@ -1917,7 +2227,7 @@
 
         #region 妯″叿鏁呴殰鐧昏琛ㄤ繚瀛�/缂栬緫
         /// <summary>
-        /// 淇濆瓨妯″叿缁翠慨鍗�
+        /// 淇濆瓨鏁呴殰鐧昏琛�
         /// </summary>
         /// <param name="msg"></param>
         /// <returns></returns>
@@ -1930,12 +2240,20 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
-
+            string msg4 = sArray[2].ToString();
 
             string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBill_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
                 DAL.ClsSc_MouldConkBookBill oBill = new DAL.ClsSc_MouldConkBookBill();
                 List<Model.ClsSc_MouldConkBookBillMain> lsmain = new List<Model.ClsSc_MouldConkBookBillMain>();
                 msg2 = msg2.Replace("\\", "");
@@ -2115,22 +2433,22 @@
 
         #region [妯″叿鏁呴殰鐧昏琛ㄥ垹闄ゅ姛鑳絔
         /// <summary>
-        /// 妯″叿缁翠慨鍗曞垹闄ゅ姛鑳�
+        /// 妯″叿鏁呴殰鐧昏琛ㄥ垹闄ゅ姛鑳�
         /// </summary>
         /// <returns></returns>
         [Route("Sc_MouldConkBookBill/DeltetMouldConkBookBill")]
         [HttpGet]
-        public object DeltetMouldConkBookBill(string HInterID)
+        public object DeltetMouldConkBookBill(string HInterID,string user)
         {
             //缂栬緫鏉冮檺
-            //if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBill_Delete", 1, false, DBUtility.ClsPub.CurUserName))
-            //{
-            //    objJsonResult.code = "0";
-            //    objJsonResult.count = 0;
-            //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-            //    objJsonResult.data = null;
-            //    return objJsonResult;
-            //}
+            if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
 
             Int64 lngBillKey = 0;
@@ -2212,12 +2530,23 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
+            string msg4 = sArray[2].ToString();
+            string msg5 = sArray[3].ToString();
 
 
             string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainPlanBill_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 DAL.ClsSc_MouldMaintainPlanBill oBill = new DAL.ClsSc_MouldMaintainPlanBill();
                 List<Model.ClsSc_MouldMaintainPlanBillMain> lsmain = new List<Model.ClsSc_MouldMaintainPlanBillMain>();
                 msg2 = msg2.Replace("\\", "");
@@ -2256,6 +2585,34 @@
                     }
                     oBill.omodel = oItem;
                 }
+
+                //淇濆吇椤硅〃浣撴暟鎹�
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg5 = msg5.Substring(1, msg5.Length - 2);
+                msg5 = msg5.Replace("\\", "");
+                msg5 = msg5.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Model.ClsSc_MouldMaintainPlanBillSub_Item> ls1 = new List<Model.ClsSc_MouldMaintainPlanBillSub_Item>();
+                ls1 = oListModels.getObjectByJson_Gy_MouldMaintainPlanBillSub_Item(msg5);
+                int j = 0;
+                foreach (Model.ClsSc_MouldMaintainPlanBillSub_Item item in ls1)
+                {
+
+                    j++;
+                    item.HEntryID = j;
+                    //oItemSub.HCloseMan = "";       //琛屽叧闂�
+                    item.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    item.HCloseType = false;   //鍏抽棴绫诲瀷
+                    //oItemSub.HRemark = "";         //澶囨敞
+                    item.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                    item.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+                    //oItemSub.HSourceBillNo = "";  //婧愬崟鍗曞彿
+                    //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷
+                    item.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                    oBill.DetailCol.Add(item);
+
+                }
+
                 //琛ㄤ綋鏁版嵁
                 //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
                 msg3 = msg3.Substring(1, msg3.Length - 2);
@@ -2351,28 +2708,28 @@
         [HttpGet]
         public object Sc_MouldMaintainPlanBillListProjectDetai(string sqlWhere)
         {
-            DataSet ds;
+            DataSet ds, ds1;
+            List<object> list = new List<object>();
+           
             try
             {
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-                if (sqlWhere == null || sqlWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select a.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName,a.HUnitID,u.HNumber HUnitNumber,u.HName HUnitName,a.HQty,a.HQtyMust,a.HRemark  from Sc_MouldMaintainPlanBillSub a left join Gy_Unit u on a.HUnitID=u.HItemID left join h_v_IF_Material m on a.HMaterID=m.HItemID", "Sc_MouldMaintainPlanBillSub");
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                }
-                else
-                {
-                    string sql1 = "select a.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName,a.HUnitID,u.HNumber HUnitNumber,u.HName HUnitName,a.HQty,a.HQtyMust,a.HRemark  from Sc_MouldMaintainPlanBillSub a left join Gy_Unit u on a.HUnitID=u.HItemID left join h_v_IF_Material m on a.HMaterID=m.HItemID where 1 = 1 ";
-                    string sql = sql1 + sqlWhere;
-                    ds = oCN.RunProcReturn(sql, "Sc_MouldMaintainPlanBillSub");
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                }
+                //鑾峰彇淇濆吇椤圭洰缂栬緫鏁版嵁
+                string sql = "select 淇濆吇椤圭洰ID HMaintainItemID, 淇濆吇椤圭洰浠g爜 HMaintainItemNumber,淇濆吇椤圭洰 HMaintainItem,淇濆吇閮ㄤ綅 HMaintainPart,鍏蜂綋瑕佹眰 HClaim,璐熻矗浜篒D,璐熻矗浜轰唬鐮� HManagerNumber,璐熻矗浜哄悕绉� HManagerName,瀛愬娉�2 HRemark,HMouldMaintainRuleID,HEquipDotCheckNo  from h_v_Sc_MouldMaintainPlanBillSub_Item where 1 = 1 " + sqlWhere + "";
+
+                ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldMaintainPlanBillSub_Item");
+                //鑾峰彇閰嶄欢椤圭洰缂栬緫鏁版嵁
+                string sql1 = "select 閰嶄欢ID HMaterID, 閰嶄欢浠g爜 HMaterNumber,閰嶄欢鍚嶇О HMaterName,鍗曚綅ID HUnitID,璁¢噺鍗曚綅浠g爜 HUnitNumber,璁¢噺鍗曚綅鍚嶇О HUnitName,鐢ㄩ噺 HQty,鏍囧噯鐢ㄩ噺 HQtyMust,瀛愬娉�1 HRemark,瑙勬牸鍨嬪彿 HMaterSpec  from h_v_Sc_MouldMaintainPlanBillSub  where 1 = 1 " + sqlWhere + "";
+                ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldMaintainPlanBillSub");
+
+                list.Add(ds.Tables[0]);
+                list.Add(ds1.Tables[0]);
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                objJsonResult.data = null;
+                objJsonResult.list = list;
             }
             catch (Exception e)
             {
@@ -2391,17 +2748,17 @@
         /// <returns></returns>
         [Route("Sc_MouldMaintainPlanBill/DeltetMouldMaintainPlanBill")]
         [HttpGet]
-        public object DeltetMouldMaintainPlanBill(string HInterID)
+        public object DeltetMouldMaintainPlanBill(string HInterID,string user)
         {
             //缂栬緫鏉冮檺
-            //if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Delete", 1, false, DBUtility.ClsPub.CurUserName))
-            //{
-            //    objJsonResult.code = "0";
-            //    objJsonResult.count = 0;
-            //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-            //    objJsonResult.data = null;
-            //    return objJsonResult;
-            //}
+            if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainPlanBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
 
             Int64 lngBillKey = 0;
@@ -2484,11 +2841,21 @@
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
             string msg4 = sArray[2].ToString();
+            string msg5 = sArray[3].ToString();
 
             string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBill_Edit", 1, false, msg5))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 DAL.ClsSc_MouldMaintainBill oBill = new DAL.ClsSc_MouldMaintainBill();
                 List<Model.ClsSc_MouldMaintainBillMain> lsmain = new List<Model.ClsSc_MouldMaintainBillMain>();
                 msg2 = msg2.Replace("\\", "");
@@ -2732,8 +3099,17 @@
         /// <returns></returns>
         [Route("Sc_MouldMaintainBill/DeltetSc_MouldMaintainBill")]
         [HttpGet]
-        public object DeltetSc_MouldMaintainBill(string HInterID)
+        public object DeltetSc_MouldMaintainBill(string HInterID,string user)
         {
+            if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
             Int64 lngBillKey = 0;
             lngBillKey = DBUtility.ClsPub.isLong(HInterID);
             if (lngBillKey == 0)
@@ -2813,12 +3189,22 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
-
+            string msg4 = sArray[2].ToString();
+            //string msg5 = sArray[3].ToString();
 
             string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckBill_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 DAL.ClsSc_MouldDotCheckBill oBill = new DAL.ClsSc_MouldDotCheckBill();
                 List<Model.ClsSc_MouldDotCheckBillMain> lsmain = new List<Model.ClsSc_MouldDotCheckBillMain>();
                 msg2 = msg2.Replace("\\", "");
@@ -2828,6 +3214,7 @@
                 {
                     //oItem.HMaker = "";
                     UserName = oItem.HMaker;  //鍒跺崟浜�
+                    oItem.HMaker = msg4;
                     oItem.HBillType = "3821";
                     oItem.HBillSubType = "3821";
 
@@ -2890,6 +3277,32 @@
                     oBill.DetailColl.Add(oItemSub);
 
                 }
+
+                ////閰嶄欢椤硅〃浣撴暟鎹�
+                ////鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                //msg5 = msg5.Substring(1, msg5.Length - 2);
+                //msg5 = msg5.Replace("\\", "");
+                //msg5 = msg5.Replace("\n", "");  //\n
+                //                                //msg2 = msg2.Replace("'", "鈥�");
+                //List<Model.ClsSc_MouldDotCheckBillSub_Item> ls1 = new List<Model.ClsSc_MouldDotCheckBillSub_Item>();
+                //ls1 = oListModels.getObjectByJson_Sc_MouldDotCheckBillSub_Item(msg5);
+                //int j = 0;
+                //foreach (Model.ClsSc_MouldDotCheckBillSub_Item oItemSub in ls1)
+                //{
+
+                //    j++;
+                //    oItemSub.HEntryID = j;
+                //    //oItemSub.HCloseMan = "";       //琛屽叧闂�
+                //    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                //    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
+
+                //    oItemSub.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                //    oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+
+                //    oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                //    oBill.DetailCol.Add(oItemSub);
+                //}
+
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
@@ -2951,28 +3364,29 @@
         [HttpGet]
         public object Sc_MouldDotCheckBillListProjectDetai(string sqlWhere)
         {
-            DataSet ds;
+            DataSet ds, ds1;
+            List<object> list = new List<object>();
+            string Swhere = "";
             try
             {
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-                if (sqlWhere == null || sqlWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select HDotCheckItemID,鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,HManagerID,璐熻矗浜轰唬鐮� HManagerNumber,璐熻矗浜� HManagerName from h_v_Sc_MouldDotCheckBillList", "h_v_Sc_MouldDotCheckBillList");
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                }
-                else
-                {
-                    string sql1 = "select HDotCheckItemID,鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,HManagerID,璐熻矗浜轰唬鐮� HManagerNumber,璐熻矗浜� HManagerName from h_v_Sc_MouldDotCheckBillList where 1 = 1 ";
-                    string sql = sql1 + sqlWhere;
-                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldDotCheckBillList");
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                }
+                //鑾峰彇鐐规椤圭洰缂栬緫鏁版嵁
+                ds = oCN.RunProcReturn("select HDotCheckItem, HDotCheckPart , HClaim, a.HRemark,a.HManagerID,e.HNumber HManagerCode,e.HName HManagerName from Sc_MouldDotCheckBillSub a left join Gy_Employee e on a.HManagerID=e.HItemID where 1=1 " + sqlWhere, "Sc_MouldDotCheckBillSub");
+                //鑾峰彇閰嶄欢椤圭洰缂栬緫鏁版嵁
+                ds1 = oCN.RunProcReturn(@"select b.HMaterID,  mt.Hnumber HMaterNumber ,mt.HName HMaterName, b.HUnitID
+                    ,u2.hnumber HUnitNumber,u2.HName HUnitName,b.HQty,b.HQtyMust,b.HRemark 
+                    from Sc_MouldDotCheckBillSub_Item b 
+                    left join Gy_Material mt on b.HMaterID=mt.HItemID 
+                    left join h_v_IF_Unit u2 on b.HUnitID=u2.HItemID  where 1=1 " + sqlWhere, "Sc_MouldDotCheckBillSub_Item");
+                list.Add(ds.Tables[0]);
+                list.Add(ds1.Tables[0]);
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                objJsonResult.data = null;
+                objJsonResult.list = list;
+
             }
             catch (Exception e)
             {
@@ -2984,25 +3398,50 @@
             return objJsonResult;
         }
         #endregion
-
+        #region[妯″叿鐐规璁板綍琛ㄩ�夋嫨鐐规璁″垝甯﹀嚭琛ㄦ牸鏁版嵁]
+        [Route("Sc_MouldDotCheckBill/Sc_MouldDotCheckSubBillListByPlan")]
+        [HttpGet]
+        public object Sc_MouldDotCheckSubBillListByPlan(string HPlanInterID)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                string sql1 = "select hsubid HDotCheckItemID,鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,HManagerID,璐熻矗浜轰唬鐮� HManagerNumber,璐熻矗浜� HManagerName from h_v_Sc_MouldDotCheckPlanBillList where hmainid =" + HPlanInterID;
+                ds = oCN.RunProcReturn(sql1, "h_v_Sc_MouldDotCheckPlanBillList");
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                objJsonResult.data = ds.Tables[0];
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+            }
+            return objJsonResult;
+        }
+        #endregion
         #region [妯″叿鐐规璁板綍琛ㄥ垹闄ゅ姛鑳絔
         /// <summary>
-        /// 妯″叿缁翠慨鍗曞垹闄ゅ姛鑳�
+        /// 妯″叿鐐规璁板綍鍒犻櫎鍔熻兘
         /// </summary>
         /// <returns></returns>
         [Route("Sc_MouldDotCheckBill/DeltetSc_MouldDotCheckBill")]
         [HttpGet]
-        public object DeltetSc_MouldDotCheckBill(string HInterID)
+        public object DeltetSc_MouldDotCheckBill(string HInterID,string user)
         {
             //缂栬緫鏉冮檺
-            //if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Delete", 1, false, DBUtility.ClsPub.CurUserName))
-            //{
-            //    objJsonResult.code = "0";
-            //    objJsonResult.count = 0;
-            //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-            //    objJsonResult.data = null;
-            //    return objJsonResult;
-            //}
+            if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
 
             Int64 lngBillKey = 0;
@@ -3085,12 +3524,23 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
+            string msg4 = sArray[2].ToString();
+            //string msg5 = sArray[3].ToString();
 
 
             string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckPlanBill_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                DBUtility.ClsPub.CurUserName = msg4;
                 DAL.ClsSc_MouldDotCheckPlanBill oBill = new DAL.ClsSc_MouldDotCheckPlanBill();
                 List<Model.ClsSc_MouldDotCheckPlanBillMain> lsmain = new List<Model.ClsSc_MouldDotCheckPlanBillMain>();
                 msg2 = msg2.Replace("\\", "");
@@ -3100,8 +3550,8 @@
                 {
                     //oItem.HMaker = "";
                     UserName = oItem.HMaker;  //鍒跺崟浜�
-                    oItem.HBillType = "3821";
-                    oItem.HBillSubType = "3821";
+                    oItem.HBillType = "3820";
+                    oItem.HBillSubType = "3820";
 
                     //oItem.HInterID =0;
                     //oItem.HBillNo = "";
@@ -3129,7 +3579,7 @@
                     }
                     oBill.omodel = oItem;
                 }
-                //琛ㄤ綋鏁版嵁
+                //鐐规椤圭洰琛ㄤ綋鏁版嵁
                 //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
                 msg3 = msg3.Substring(1, msg3.Length - 2);
                 msg3 = msg3.Replace("\\", "");
@@ -3162,6 +3612,32 @@
                     oBill.DetailColl.Add(oItemSub);
 
                 }
+
+                ////閰嶄欢椤硅〃浣撴暟鎹�
+                ////鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                //msg5 = msg5.Substring(1, msg5.Length - 2);
+                //msg5 = msg5.Replace("\\", "");
+                //msg5 = msg5.Replace("\n", "");  //\n
+                //                                //msg2 = msg2.Replace("'", "鈥�");
+                //List<Model.ClsSc_MouldDotCheckPlanBillSub_Item> ls1 = new List<Model.ClsSc_MouldDotCheckPlanBillSub_Item>();
+                //ls1 = oListModels.getObjectByJson_Sc_MouldDotCheckPlanBillSub_Item(msg5);
+                //int j = 0;
+                //foreach (Model.ClsSc_MouldDotCheckPlanBillSub_Item oItemSub in ls1)
+                //{
+
+                //    j++;
+                //    oItemSub.HEntryID = j;
+                //    //oItemSub.HCloseMan = "";       //琛屽叧闂�
+                //    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                //    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
+
+                //    oItemSub.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                //    oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+
+                //    oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                //    oBill.DetailCol.Add(oItemSub);
+                //}
+
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
@@ -3223,28 +3699,29 @@
         [HttpGet]
         public object Sc_MouldDotCheckPlanBillListProjectDetai(string sqlWhere)
         {
-            DataSet ds;
+            DataSet ds, ds1;
+            List<object> list = new List<object>();
+            string Swhere = "";
             try
             {
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-                if (sqlWhere == null || sqlWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select HDotCheckItem, HDotCheckPart , HClaim, a.HRemark,a.HManagerID,e.HNumber HManagerCode,e.HName HManagerName from Sc_MouldDotCheckPlanBillSub a left join Gy_Employee e on a.HManagerID=e.HItemID", "Sc_MouldDotCheckPlanBillSub");
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                }
-                else
-                {
-                    string sql1 = "select HDotCheckItem, HDotCheckPart , HClaim, a.HRemark,a.HManagerID,e.HNumber HManagerCode,e.HName HManagerName from Sc_MouldDotCheckPlanBillSub a left join Gy_Employee e on a.HManagerID=e.HItemID where 1 = 1 ";
-                    string sql = sql1 + sqlWhere;
-                    ds = oCN.RunProcReturn(sql, "Sc_MouldDotCheckPlanBillSub");
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                }
+                //鑾峰彇鐐规椤圭洰缂栬緫鏁版嵁
+                ds = oCN.RunProcReturn(@"select a.HDotCheckItemID,HDotCheckItem, HDotCheckPart , HClaim, a.HRemark,a.HManagerID,e.HNumber HManagerCode,e.HName HManagerName from Sc_MouldDotCheckPlanBillSub a 
+                  left join Gy_Employee e on a.HManagerID=e.HItemID
+                        where 1=1 " + sqlWhere, "Sc_MouldDotCheckPlanBillSub");
+                ////鑾峰彇閰嶄欢椤圭洰缂栬緫鏁版嵁
+                //ds1 = oCN.RunProcReturn(@"select b.HMaterID,  mt.Hnumber HMaterNumber ,mt.HName HMaterName, b.HUnitID
+                //    ,u2.hnumber HUnitNumber,u2.HName HUnitName,b.HQty,b.HQtyMust,b.HRemark 
+                //    from Sc_MouldDotCheckPlanBillSub_Item b 
+                //    left join Gy_Material mt on b.HMaterID=mt.HItemID 
+                //    left join h_v_IF_Unit u2 on b.HUnitID=u2.HItemID  where 1=1 " + sqlWhere, "Sc_MouldDotCheckPlanBillSub_Item");
+                list.Add(ds.Tables[0]);
+                //list.Add(ds1.Tables[0]);
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                objJsonResult.data = null;
+                objJsonResult.list = list;
             }
             catch (Exception e)
             {
@@ -3265,17 +3742,17 @@
         /// <returns></returns>
         [Route("Sc_MouldDotCheckPlanBill/DeltetSc_MouldDotCheckPlanBillBill")]
         [HttpGet]
-        public object DeltetSc_MouldDotCheckPlanBillBill(string HInterID)
+        public object DeltetSc_MouldDotCheckPlanBillBill(string HInterID,string user)
         {
             //缂栬緫鏉冮檺
-            //if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Delete", 1, false, DBUtility.ClsPub.CurUserName))
-            //{
-            //    objJsonResult.code = "0";
-            //    objJsonResult.count = 0;
-            //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-            //    objJsonResult.data = null;
-            //    return objJsonResult;
-            //}
+            if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckPlanBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
 
             Int64 lngBillKey = 0;
@@ -3378,7 +3855,7 @@
                     ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,妯″叿浠g爜 HMaterCode,妯″叿鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,HPropertyID,杈呭姪灞炴�т唬鐮� HPropertyCode,杈呭姪灞炴�у悕绉� HPropertyName,
                                             HSecUnitID, 杈呭姪璁¢噺鍗曚綅浠g爜 HSecUnitCode, 杈呭姪璁¢噺鍗曚綅鍚嶇О HSecUnitName, HUnitID, 璁¢噺鍗曚綅浠g爜 HUnitCode, 璁¢噺鍗曚綅鍚嶇О HUnitName, 鎵规 HBatchNo,
                                             璁捐瀵垮懡 HDesignLife, 鍓╀綑瀵垮懡 HLeaveLife, 浣跨敤瀵垮懡 HUseLife, 瀹炴敹鏁伴噺 HQty, 鍗曚环 HPrice, 閲戦 HMoney, HWHID, 鏀舵枡浠撳簱浠g爜 HWHCode, 鏀舵枡浠撳簱鍚嶇О HWHName,
-                                            HSPID, 浠撲綅浠g爜 HSPCode, 浠撲綅鍚嶇О HSPName, 澶囨敞 HRemark,HStockOrgID
+                                            HSPID, 浠撲綅浠g爜 HSPCode, 浠撲綅鍚嶇О HSPName, 瀛愬娉� HRemark,HStockOrgID
                                             FROM h_v_Sc_MouldScrapInHouseBillList"), "h_v_Sc_MouldScrapInHouseBillList");
 
                 }
@@ -3389,7 +3866,7 @@
                     string sql1 = string.Format(@"SELECT HMaterID,妯″叿浠g爜 HMaterCode,妯″叿鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,HPropertyID,杈呭姪灞炴�т唬鐮� HPropertyCode,杈呭姪灞炴�у悕绉� HPropertyName,
                                             HSecUnitID, 杈呭姪璁¢噺鍗曚綅浠g爜 HSecUnitCode, 杈呭姪璁¢噺鍗曚綅鍚嶇О HSecUnitName, HUnitID, 璁¢噺鍗曚綅浠g爜 HUnitCode, 璁¢噺鍗曚綅鍚嶇О HUnitName, 鎵规 HBatchNo,
                                             璁捐瀵垮懡 HDesignLife, 鍓╀綑瀵垮懡 HLeaveLife, 浣跨敤瀵垮懡 HUseLife, 瀹炴敹鏁伴噺 HQty, 鍗曚环 HPrice, 閲戦 HMoney, HWHID, 鏀舵枡浠撳簱浠g爜 HWHCode, 鏀舵枡浠撳簱鍚嶇О HWHName,
-                                            HSPID, 浠撲綅浠g爜 HSPCode, 浠撲綅鍚嶇О HSPName, 澶囨敞 HRemark,HStockOrgID
+                                            HSPID, 浠撲綅浠g爜 HSPCode, 浠撲綅鍚嶇О HSPName, 瀛愬娉� HRemark,HStockOrgID
                                             FROM h_v_Sc_MouldScrapInHouseBillList where 1 = 1 ");
                     string sql = sql1 + sqlWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldScrapInHouseBillList");
@@ -3426,7 +3903,7 @@
         /// <returns></returns>
         [Route("Sc_MouldScrapInHouseBill/SaveGetMouldScrapInHouseBillList")]
         [HttpPost]
-        public object fSaveGetMouldScrapInHouseBillList([FromBody] JObject msg)
+        public object SaveGetMouldScrapInHouseBillList([FromBody] JObject msg)
         {
             var _value = msg["msg"].ToString();
             string msg1 = _value.ToString();
@@ -3579,15 +4056,19 @@
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeFileStatus  'in','{oBill.omodel.HInterID.ToString()}' ");
+                    oCn.RunProc(sql);
                 }
                 else
                 {
                     bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                    //淇敼鎴愬姛
+                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  1,{oBill.omodel.HInterID.ToString()},' ' ");
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
+                    oCn.RunProc(sql);
                 }
                 if (bResult)
                 {
-                    string sql = $"exec h_p_Sc_MouldChangeFileStatus  'in','{oBill.omodel.HInterID.ToString()}' ";
-                    oCn.RunProc(sql);
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
@@ -3774,6 +4255,7 @@
                 }
 
                 ds = Sc_GetMouldScrapOutHouseBill(sWhere, Organization);
+
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
@@ -3795,11 +4277,11 @@
             string sql1 = string.Format(@"select * from h_v_Sc_MouldScrapOutHouseBillList where 搴撳瓨缁勭粐='" + Organization + "'");
             if (sWhere == null || sWhere.Equals(""))
             {
-                return new SQLHelper.ClsCN().RunProcReturn(sql1 + "order by 鏃ユ湡 desc", "h_v_Sc_MouldScrapOutHouseBillList");
+                return new SQLHelper.ClsCN().RunProcReturn(sql1 + " order by 鍒跺崟鏃ユ湡 desc", "h_v_Sc_MouldScrapOutHouseBillList");
             }
             else
             {
-                string sql = sql1 + sWhere + "order by 鏃ユ湡 desc";
+                string sql = sql1 + sWhere + " order by 鍒跺崟鏃ユ湡 desc";
                 return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldScrapOutHouseBillList");
             }
         }
@@ -3988,15 +4470,19 @@
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeFileStatus  'out','{oBill.omodel.HInterID.ToString()}' ");
+                    oCn.RunProc(sql);
                 }
                 else
                 {
                     bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                    //淇敼鎴愬姛
+                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  1,{oBill.omodel.HInterID.ToString()},' ' ");
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
+                    oCn.RunProc(sql);
                 }
                 if (bResult)
                 {
-                    string sql = $"exec h_p_Sc_MouldChangeFileStatus  'out','{oBill.omodel.HInterID.ToString()}' ";
-                    oCn.RunProc(sql);
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
@@ -4073,10 +4559,21 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-
+                //鍒犻櫎鍓嶆煡鎵惧綋鍓嶅崟鎹殑鎵�鏈夊櫒鍏稩D
+                //string swhere = "";
+                //DataSet ds = oCn.RunProcReturn("select HMaterID from Sc_MouldStockBillSub where HinterID=" + HInterID, "Sc_MouldStockBillSub");
+                //for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
+                //{
+                //    swhere = swhere + ds.Tables[0].Rows[i]["HMaterID"].ToString()+",";
+                //}
+                //swhere = swhere.Substring(0, swhere.Length - 1);
                 bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                 if (IsDete)
                 {
+                    //鍒犻櫎鎴愬姛淇敼鍣ㄥ叿妗f浣嶇疆
+                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  0,0,'{swhere}' ");
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
+                    oCn.RunProc(sql);
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
@@ -4349,6 +4846,7 @@
                 }
 
                 ds = Sc_GetMouldProdBackBill(sWhere, Organization);
+
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
@@ -4370,11 +4868,11 @@
             string sql1 = string.Format(@"select * from h_v_Sc_MouldProdBackBillList where 搴撳瓨缁勭粐='" + Organization + "'");
             if (sWhere == null || sWhere.Equals(""))
             {
-                return new SQLHelper.ClsCN().RunProcReturn(sql1 + "order by 鏃ユ湡 desc", "h_v_Sc_MouldProdBackBillList");
+                return new SQLHelper.ClsCN().RunProcReturn(sql1 + "order by 鍒跺崟鏃ユ湡 desc", "h_v_Sc_MouldProdBackBillList");
             }
             else
             {
-                string sql = sql1 + sWhere + "order by 鏃ユ湡 desc";
+                string sql = sql1 + sWhere + "order by 鍒跺崟鏃ユ湡 desc";
                 return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldProdBackBillList");
             }
 
@@ -4414,8 +4912,8 @@
                 {
                     ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,妯″叿浠g爜 HMaterCode,妯″叿鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,鎵规 HBatchNo,
                                                 璁捐瀵垮懡 HDesignLife, 鍓╀綑瀵垮懡 HLeaveLife, 绱Н浣跨敤瀵垮懡 HUseLife, 搴斿彂鏁伴噺 HQtyMust, 瀹炲彂鏁伴噺 HQty, 
-                                                鍗曚环 HPrice, 閲戦 HMoney,HWHSonID HWHID, 鍙戞枡浠撳簱浠g爜 HWHCode, 鍙戞枡浠撳簱 HWHName,HSPID, 
-                                                浠撲綅浠g爜 HSPCode, 浠撲綅 HSPName,琛ㄤ綋澶囨敞 HRemark,HStockOrgID,HUnitID,璁¢噺鍗曚綅浠g爜,璁¢噺鍗曚綅 FROM h_v_Sc_MouldProdBackBillList"), "h_v_Sc_MouldProdBackBillList");
+                                                鍗曚环 HPrice, 閲戦 HMoney,鏀舵枡浠撳簱ID HWHID, 鏀舵枡浠撳簱浠g爜 HWHCode, 鏀舵枡浠撳簱 HWHName,HSPID, 
+                                                浠撲綅浠g爜 HSPCode, 浠撲綅 HSPName,琛ㄤ綋澶囨敞 HRemark,HStockOrgID,HUnitID,璁¢噺鍗曚綅浠g爜 HUnitCode,璁¢噺鍗曚綅 HUnitName FROM h_v_Sc_MouldProdBackBillList"), "h_v_Sc_MouldProdBackBillList");
 
                 }
                 else
@@ -4424,16 +4922,16 @@
                     //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark  from Sc_MouldRepairCheckBillSub where 1 = 1 ";
                     string sql1 = string.Format(@"SELECT HMaterID,妯″叿浠g爜 HMaterCode,妯″叿鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,鎵规 HBatchNo,
                                                 璁捐瀵垮懡 HDesignLife, 鍓╀綑瀵垮懡 HLeaveLife, 绱Н浣跨敤瀵垮懡 HUseLife, 搴斿彂鏁伴噺 HQtyMust, 瀹炲彂鏁伴噺 HQty, 
-                                                鍗曚环 HPrice, 閲戦 HMoney,HWHSonID HWHID, 鍙戞枡浠撳簱浠g爜 HWHCode, 鍙戞枡浠撳簱 HWHName,HSPID, 
-                                                浠撲綅浠g爜 HSPCode, 浠撲綅 HSPName,琛ㄤ綋澶囨敞 HRemark,HStockOrgID,HUnitID,璁¢噺鍗曚綅浠g爜,璁¢噺鍗曚綅 FROM h_v_Sc_MouldProdBackBillList where 1 = 1 ");
+                                                鍗曚环 HPrice, 閲戦 HMoney,鏀舵枡浠撳簱ID HWHID, 鏀舵枡浠撳簱浠g爜 HWHCode, 鏀舵枡浠撳簱 HWHName,HSPID, 
+                                                浠撲綅浠g爜 HSPCode, 浠撲綅 HSPName,琛ㄤ綋澶囨敞 HRemark,HStockOrgID,HUnitID,璁¢噺鍗曚綅浠g爜 HUnitCode,璁¢噺鍗曚綅 HUnitName FROM h_v_Sc_MouldProdBackBillList where 1 = 1 ");
                     string sql = sql1 + sqlWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldProdBackBillList");
 
                 }
                 //鏌ユ眹鎬�
                 ds1 = oCN.RunProcReturn(string.Format(@"select  鐗╂枡浠g爜,max(鐗╂枡鍚嶇О)鐗╂枡鍚嶇О,瑙勬牸鍨嬪彿,max(鍗曟嵁鍙�)鍗曟嵁鍙�,鎵规,sum(瀹炲彂鏁伴噺)瀹炲彂鏁伴噺,
-                                            HWHSonID,max(鍙戞枡浠撳簱浠g爜)鍙戞枡浠撳簱浠g爜,max(鍙戞枡浠撳簱)鍙戞枡浠撳簱,琛ㄤ綋澶囨敞 from h_v_Sc_MouldProdBackBillList 
-                                            where 1=1 " + sqlWhere + " group by 鐗╂枡浠g爜,瑙勬牸鍨嬪彿,HWHSonID,鎵规,琛ㄤ綋澶囨敞"), "h_v_Sc_MouldProdBackBillList");
+                                            鏀舵枡浠撳簱ID,max(鏀舵枡浠撳簱浠g爜)鏀舵枡浠撳簱浠g爜,max(鏀舵枡浠撳簱)鏀舵枡浠撳簱,琛ㄤ綋澶囨敞 from h_v_Sc_MouldProdBackBillList 
+                                            where 1=1 " + sqlWhere + " group by 鐗╂枡浠g爜,瑙勬牸鍨嬪彿,鏀舵枡浠撳簱ID,鎵规,琛ㄤ綋澶囨敞"), "h_v_Sc_MouldProdBackBillList");
 
                 list.Add(ds.Tables[0]);
                 list.Add(ds1.Tables[0]);
@@ -4563,18 +5061,21 @@
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                  
+                    string sql1 = string.Format($"exec h_p_Sc_MouldChangeFileStatus  'in','{oBill.omodel.HInterID.ToString()}' ");
+                    oCn.RunProc(sql1);
                 }
                 else
                 {
                     bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                    //淇敼鎴愬姛
+                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  1,{oBill.omodel.HInterID.ToString()},' ' ");
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
+                    oCn.RunProc(sql);
                 }
                 if (bResult)
                 {
-                    string sql = $"exec h_p_Sc_MouldProdBackBillList '{oBill.omodel.HBillNo}' ";
+                    string sql =string.Format($"exec h_p_Sc_MouldProdBackBillList '{oBill.omodel.HBillNo}' ") ;
                     oCn.RunProc(sql);
-                    string sql1 = $"exec h_p_Sc_MouldChangeFileStatus  'in','{oBill.omodel.HInterID.ToString()}' ";
-                    oCn.RunProc(sql1);
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
@@ -4651,10 +5152,21 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-
+                //鍒犻櫎鍓嶆煡鎵惧綋鍓嶅崟鎹殑鎵�鏈夊櫒鍏稩D
+                //string swhere = "";
+                //DataSet ds = oCn.RunProcReturn("select HMaterID from Sc_MouldStockBillSub where HinterID=" + HInterID, "Sc_MouldStockBillSub");
+                //for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
+                //{
+                //    swhere = swhere + ds.Tables[0].Rows[i]["HMaterID"].ToString()+",";
+                //}
+                //swhere = swhere.Substring(0, swhere.Length - 1);
                 bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                 if (IsDete)
                 {
+                    //鍒犻櫎鎴愬姛淇敼鍣ㄥ叿妗f浣嶇疆
+                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  0,0,'{swhere}' ");
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
+                    oCn.RunProc(sql);
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
@@ -4787,6 +5299,7 @@
                 }
 
                 ds = Sc_GetMouldProdOutBill(sWhere, Organization);
+
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
@@ -4808,11 +5321,12 @@
             string sql1 = string.Format(@"select * from h_v_Sc_MouldProdOutHouseBillList where 搴撳瓨缁勭粐='" + Organization + "'");
             if (sWhere == null || sWhere.Equals(""))
             {
-                return new SQLHelper.ClsCN().RunProcReturn(sql1 + "order by 鏃ユ湡 desc", "h_v_Sc_MouldProdOutHouseBillList");
+                Log.LogInfo(sql1);
+                return new SQLHelper.ClsCN().RunProcReturn(sql1 + "order by 鍒跺崟鏃ユ湡 desc", "h_v_Sc_MouldProdOutHouseBillList");
             }
             else
             {
-                string sql = sql1 + sWhere + "order by 鏃ユ湡 desc";
+                string sql = sql1 + sWhere + "order by 鍒跺崟鏃ユ湡 desc";
                 return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldProdOutHouseBillList");
             }
 
@@ -4853,7 +5367,7 @@
                     ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,妯″叿浠g爜 HMaterCode,妯″叿鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,鎵规 HBatchNo,
                                                 璁捐瀵垮懡 HDesignLife, 鍓╀綑瀵垮懡 HLeaveLife, 绱Н浣跨敤瀵垮懡 HUseLife, 搴斿彂鏁伴噺 HQtyMust, 瀹炲彂鏁伴噺 HQty, 
                                                 鍗曚环 HPrice, 閲戦 HMoney,HWHSonID HWHID, 鍙戞枡浠撳簱浠g爜 HWHCode, 鍙戞枡浠撳簱 HWHName,HSPID, 
-                                                浠撲綅浠g爜 HSPCode, 浠撲綅 HSPName,琛ㄤ綋澶囨敞 HRemark,HStockOrgID,HUnitID,璁¢噺鍗曚綅浠g爜,璁¢噺鍗曚綅 FROM h_v_Sc_MouldProdOutHouseBillList"), "h_v_Sc_MouldProdOutHouseBillList");
+                                                浠撲綅浠g爜 HSPCode, 浠撲綅 HSPName,琛ㄤ綋澶囨敞 HRemark,HStockOrgID,HUnitID,璁¢噺鍗曚綅浠g爜 HUnitCode,璁¢噺鍗曚綅 HUnitName FROM h_v_Sc_MouldProdOutHouseBillList"), "h_v_Sc_MouldProdOutHouseBillList");
 
                 }
                 else
@@ -4863,7 +5377,7 @@
                     string sql1 = string.Format(@"SELECT HMaterID,妯″叿浠g爜 HMaterCode,妯″叿鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,鎵规 HBatchNo,
                                                 璁捐瀵垮懡 HDesignLife, 鍓╀綑瀵垮懡 HLeaveLife, 绱Н浣跨敤瀵垮懡 HUseLife, 搴斿彂鏁伴噺 HQtyMust, 瀹炲彂鏁伴噺 HQty, 
                                                 鍗曚环 HPrice, 閲戦 HMoney,HWHSonID HWHID, 鍙戞枡浠撳簱浠g爜 HWHCode, 鍙戞枡浠撳簱 HWHName,HSPID, 
-                                                浠撲綅浠g爜 HSPCode, 浠撲綅 HSPName,琛ㄤ綋澶囨敞 HRemark,HStockOrgID,HUnitID,璁¢噺鍗曚綅浠g爜,璁¢噺鍗曚綅 FROM h_v_Sc_MouldProdOutHouseBillList where 1 = 1 ");
+                                                浠撲綅浠g爜 HSPCode, 浠撲綅 HSPName,琛ㄤ綋澶囨敞 HRemark,HStockOrgID,HUnitID,璁¢噺鍗曚綅浠g爜 HUnitCode,璁¢噺鍗曚綅 HUnitName FROM h_v_Sc_MouldProdOutHouseBillList where 1 = 1 ");
                     string sql = sql1 + sqlWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldProdOutHouseBillList");
                 }
@@ -5001,15 +5515,19 @@
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeFileStatus  'out','{oBill.omodel.HInterID.ToString()}' ");
+                    oCn.RunProc(sql);
                 }
                 else
                 {
                     bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                    //淇敼鎴愬姛
+                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  1,{oBill.omodel.HInterID.ToString()},' ' ");
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
+                    oCn.RunProc(sql);
                 }
                 if (bResult)
                 {
-                    string sql = $"exec h_p_Sc_MouldChangeFileStatus  'out','{oBill.omodel.HInterID.ToString()}' ";
-                    oCn.RunProc(sql);
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
@@ -5124,10 +5642,21 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-
+                //鍒犻櫎鍓嶆煡鎵惧綋鍓嶅崟鎹殑鎵�鏈夊櫒鍏稩D
+                //string swhere = "";
+                //DataSet ds = oCn.RunProcReturn("select HMaterID from Sc_MouldStockBillSub where HinterID=" + HInterID, "Sc_MouldStockBillSub");
+                //for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
+                //{
+                //    swhere = swhere + ds.Tables[0].Rows[i]["HMaterID"].ToString() + ",";
+                //}
+                //swhere = swhere.Substring(0, swhere.Length - 1);
                 bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                 if (IsDete)
                 {
+                    //鍒犻櫎鎴愬姛淇敼鍣ㄥ叿妗f浣嶇疆
+                    // string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  0,0,'{swhere}' ");
+                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
+                    oCn.RunProc(sql);
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
@@ -5245,16 +5774,36 @@
 
         [Route("Sc_MouldLifeChangeBill/GetMouldLifeChangeBill")]
         [HttpGet]
-        public object GetMouldLifeChangeBill(string sWhere)
+        public object GetMouldLifeChangeBill(string sWhere,string user)
         {
             try
             {
+                List<object> columnNameList = new List<object>();
+
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldLifeChangeBillList", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
                 ds = Sc_GetMouldLifeChangeBill(sWhere);
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
                 objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
                 return objJsonResult;
             }
             catch (Exception ex)
@@ -5271,12 +5820,12 @@
         {
             if (sWhere == null || sWhere.Equals(""))
             {
-                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldLifeChangeBillList order by 鏃ユ湡 desc", "h_v_Sc_MouldLifeChangeBillList");
+                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldLifeChangeBillList order by hmainid desc", "h_v_Sc_MouldLifeChangeBillList");
             }
             else
             {
                 string sql1 = "select * from h_v_Sc_MouldLifeChangeBillList where 1 = 1 ";
-                string sql = sql1 + sWhere + "order by 鏃ユ湡 desc";
+                string sql = sql1 + sWhere + "order by hmainid desc";
                 return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldLifeChangeBillList");
             }
 
@@ -5315,7 +5864,7 @@
                     ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,妯″叿浠g爜 HMaterCode,妯″叿 HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,HPropertyID,杈呭姪灞炴�т唬鐮� HPropertyCode,杈呭姪灞炴�� HPropertyName,
                                                            HSecUnitID, 杈呭姪璁¢噺鍗曚綅浠g爜 HSecUnitCode, 杈呭姪璁¢噺鍗曚綅 HSecUnitName,鎹㈢畻鐜� HSecUnitRate,
                                                            HUnitID, 璁¢噺鍗曚綅浠g爜 HUnitCode, 璁¢噺鍗曚綅 HUnitName,
-                                                           璁捐瀵垮懡 HDesignLife, 鍘熷墿浣欏鍛� HLeaveLife, 鏂板墿浣欏鍛� HNewLife,琛ㄤ綋澶囨敞 HRemark 
+                                                           璁捐瀵垮懡 HDesignLife, 鍘熷墿浣欏鍛� HLeaveLife, 鏂板墿浣欏鍛� HNewLeaveLife,琛ㄤ綋澶囨敞 HRemark 
 	                                                       FROM h_v_Sc_MouldLifeChangeBillList_Edit"), "h_v_Sc_MouldLifeChangeBillList_Edit");
 
                     objJsonResult.code = "0";
@@ -5330,7 +5879,7 @@
                     string sql1 = string.Format(@"SELECT HMaterID,妯″叿浠g爜 HMaterCode,妯″叿 HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,HPropertyID,杈呭姪灞炴�т唬鐮� HPropertyCode,杈呭姪灞炴�� HPropertyName,
                                                   HSecUnitID, 杈呭姪璁¢噺鍗曚綅浠g爜 HSecUnitCode, 杈呭姪璁¢噺鍗曚綅 HSecUnitName,鎹㈢畻鐜� HSecUnitRate,
                                                   HUnitID, 璁¢噺鍗曚綅浠g爜 HUnitCode, 璁¢噺鍗曚綅 HUnitName,
-                                                  璁捐瀵垮懡 HDesignLife, 鍘熷墿浣欏鍛� HLeaveLife, 鏂板墿浣欏鍛� HNewLife,琛ㄤ綋澶囨敞 HRemark 
+                                                  璁捐瀵垮懡 HDesignLife, 鍘熷墿浣欏鍛� HLeaveLife, 鏂板墿浣欏鍛� HNewLeaveLife,琛ㄤ綋澶囨敞 HRemark 
 	                                              FROM h_v_Sc_MouldLifeChangeBillList_Edit where 1 = 1 ");
                     string sql = sql1 + sqlWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldLifeChangeBillList_Edit");
@@ -5367,12 +5916,22 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
+            string msg4 = sArray[2].ToString();
 
 
             string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldLifeChangeBill_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 DLL.ClsSc_MouldLifeChangeBill oBill = new DLL.ClsSc_MouldLifeChangeBill();
                 List<Model.ClsSc_MouldLifeChangeBillMain> lsmain = new List<Model.ClsSc_MouldLifeChangeBillMain>();
                 msg2 = msg2.Replace("\\", "");
@@ -5494,17 +6053,17 @@
         /// <returns></returns>
         [Route("Sc_MouldLifeChangeBill/DeltetMouldLifeChangeBill")]
         [HttpGet]
-        public object DeltetMouldLifeChangeBill(string HInterID)
+        public object DeltetMouldLifeChangeBill(string HInterID,string user)
         {
             //缂栬緫鏉冮檺
-            //if (!DBUtility.ClsPub.Security_Log("Sc_MouldLifeChangeBill_Delete", 1, false, DBUtility.ClsPub.CurUserName))
-            //{
-            //    objJsonResult.code = "0";
-            //    objJsonResult.count = 0;
-            //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-            //    objJsonResult.data = null;
-            //    return objJsonResult;
-            //}
+            if (!DBUtility.ClsPub.Security_Log("Sc_MouldLifeChangeBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
 
             Int64 lngBillKey = 0;

--
Gitblit v1.9.1