From 720ad806c65ac92647730e64dd90ee62da627d1e Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期四, 17 十一月 2022 16:07:06 +0800
Subject: [PATCH] 生产订单编辑功能 用户 完善 角色 编辑 删除

---
 WebAPI/Controllers/SCGL/日计划管理/JIT_DayPlanPlatFormBillController.cs |    3 
 Model/生产管理/ClsSc_ICMOBillSub.cs                                    |   10 +
 WebAPI/Controllers/BLL/Xt_UserController.cs                        |   35 ++++
 Model/生产管理/设备管理/ClsSc_ICMOBillMain.cs                              |    2 
 WebAPI/Controllers/BLL/Xt_UserGroupController.cs                   |  201 ++++++++++++++++++++++---
 WebAPI/Controllers/生产管理/生产任务单/Sc_ICMOBillController.cs             |  207 +++++++++++++++++++++++++
 6 files changed, 429 insertions(+), 29 deletions(-)

diff --git "a/Model/\347\224\237\344\272\247\347\256\241\347\220\206/ClsSc_ICMOBillSub.cs" "b/Model/\347\224\237\344\272\247\347\256\241\347\220\206/ClsSc_ICMOBillSub.cs"
index 77ee232..190dc6b 100644
--- "a/Model/\347\224\237\344\272\247\347\256\241\347\220\206/ClsSc_ICMOBillSub.cs"
+++ "b/Model/\347\224\237\344\272\247\347\256\241\347\220\206/ClsSc_ICMOBillSub.cs"
@@ -5,8 +5,16 @@
 namespace Model
 {
     public class ClsSc_ICMOBillSub:DBUtility.ClsXt_BaseBillSub
-    { 
+    {
         //============
         //public string HRemark;
+        public Int64 HMaterID;
+        public Int64 HSourceID;
+        public Int64 HDeptID;
+        public Int64 HUnitID;
+        public double? HQty;
+        public int HSTATUS;
+        public DateTime? HPlanBeginDate= DateTime.Parse(DateTime.Now.ToString("F"));
+        public DateTime? HPlanEndDate;
     }
 }
diff --git "a/Model/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\276\345\244\207\347\256\241\347\220\206/ClsSc_ICMOBillMain.cs" "b/Model/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\276\345\244\207\347\256\241\347\220\206/ClsSc_ICMOBillMain.cs"
index a5fae6c..a0a7293 100644
--- "a/Model/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\276\345\244\207\347\256\241\347\220\206/ClsSc_ICMOBillMain.cs"
+++ "b/Model/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\276\345\244\207\347\256\241\347\220\206/ClsSc_ICMOBillMain.cs"
@@ -30,7 +30,7 @@
         public DateTime HEndDate;      // --最迟完工日期		 
         public int HLevNum;       //       --优先级			 
         public double HReadyQty;     //      --齐套数量		 
-        public double HPlanQty;        //计划生产数量
+        public double? HPlanQty;        //计划生产数量
         public string HRemark;
 
         public double HRelationQty;
diff --git a/WebAPI/Controllers/BLL/Xt_UserController.cs b/WebAPI/Controllers/BLL/Xt_UserController.cs
index 2ffba78..a00f4c3 100644
--- a/WebAPI/Controllers/BLL/Xt_UserController.cs
+++ b/WebAPI/Controllers/BLL/Xt_UserController.cs
@@ -154,6 +154,7 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
+            string msg4 = sArray[2].ToString();
 
             ListModels oListModels = new ListModels();
             try
@@ -162,6 +163,8 @@
                 msg2 = msg2.Replace("\\", "");
                 msg2 = msg2.Replace("\n", "");  //\n
                 lsmain = oListModels.getObjectByJson_Gy_Gy_User(msg2);
+
+                var num = msg4.Split(',');
 
                 //淇濆瓨
                 if (msg3=="Add") //鏂板
@@ -198,6 +201,28 @@
                     "," + lsmain[0].HWhID.ToString() + ",'" + lsmain[0].HWHName.ToString() + "'," + lsmain[0].HSupID.ToString() + ",'" + lsmain[0].HSupName.ToString() + "'" +
                     "," + lsmain[0].HSCWHID.ToString() + ",'" + lsmain[0].HSCWHName.ToString() + "'" + 
                     ",'" + lsmain[0].HCloudUserName.ToString() + "','" + lsmain[0].HCloudUserPsd.ToString() + "',"+ lsmain[0].HOrgID.ToString() + ")");
+
+                    //鏂板鍚庢煡璇�  纭繚鏁版嵁娣诲姞鎴愬姛
+                    ds = oCN.RunProcReturn("Select * from  Gy_Czygl where Czybm='" + lsmain[0].Czybm.ToString() + "'", "Gy_Czygl");
+
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瑙掕壊鏂板澶辫触锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                 
+                    oCN.RunProc("delete from  System_UserGroupInfo where UserId='" + lsmain[0].Czybm.ToString() + "'");
+
+                    if (num[0] != "-1")
+                    {
+                        for (int i = 0; i < num.Length; i++)
+                        {
+                            oCN.RunProc("insert into  System_UserGroupInfo (GroupId,UserId) values (" + num[i] + ",'" + lsmain[0].Czybm.ToString() + "')");
+                        }
+                    }
                 }
                 else //淇敼
                 {
@@ -254,6 +279,16 @@
                            "  where  Czybm='" + lsmain[0].Czybm.ToString() + "'");
                     }
 
+                    oCN.RunProc("delete from  System_UserGroupInfo where UserId='" + lsmain[0].Czybm.ToString()+"'");
+
+                    if (num[0] != "-1")
+                    {
+                        for (int i = 0; i < num.Length; i++)
+                        {
+                            oCN.RunProc("insert into  System_UserGroupInfo (GroupId,UserId) values (" + num[i] + ",'" + lsmain[0].Czybm.ToString() + "')");
+                        }
+                    }
+
                 }
 
                 objJsonResult.code = "1";
diff --git a/WebAPI/Controllers/BLL/Xt_UserGroupController.cs b/WebAPI/Controllers/BLL/Xt_UserGroupController.cs
index dba8bcb..64d2d52 100644
--- a/WebAPI/Controllers/BLL/Xt_UserGroupController.cs
+++ b/WebAPI/Controllers/BLL/Xt_UserGroupController.cs
@@ -17,7 +17,7 @@
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
 
-
+        #region 瑙掕壊鍒楄〃
         /// <summary>
         /// 杩斿洖鐢ㄦ埛瑙掕壊鍒楄〃
         ///鍙傛暟锛歴tring sql銆�
@@ -29,33 +29,13 @@
         {
             try
             {
-                if (sWhere == null || sWhere.Equals(""))
-                {
-                    ds = oCN.RunProcReturn("select * from h_v_System_UserGroup " + sWhere, "h_v_System_UserGroup");
-                }
-                else
-                {
-                    string sql1 = "select * from h_v_System_UserGroup where 1 = 1 ";
-                    string sql = sql1 + sWhere;
-                    ds = oCN.RunProcReturn(sql, "h_v_System_UserGroup");
-                }
+                ds = oCN.RunProcReturn("select * from h_v_System_UserGroup   where 1 = 1 " + sWhere, "h_v_System_UserGroup");
 
-                //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 e)
             {
@@ -66,9 +46,182 @@
                 return objJsonResult;
             }
         }
+        #endregion
+
+        #region 瑙掕壊缁戝畾鐢ㄦ埛鏁版嵁
+        [Route("Xt_UserGroup/UserGroupInfoList")]
+        [HttpGet]
+        public object UserGroupInfoList(string sWhere)
+        {
+            try
+            {
+                string sql = "select * from System_UserGroupInfo where 1=1 " + sWhere;
+                ds = oCN.RunProcReturn(sql, "System_UserGroupInfo");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瑙掕壊鍒楄〃  娣诲姞/淇敼
+        public class Xt_UserGroup
+        {
+            public int HGroupID;
+            public string GroupName { get; set; }
+            public string HLev { get; set; }
+            public string Explain { get; set; }
+        }
+        [Route("Xt_UserGroup/UserGroupInfoEdit")]
+        [HttpPost]
+        public object UserGroupInfoEdit([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            oCN.BeginTran();
+            //淇濆瓨涓昏〃
+            objJsonResult = AddBillMain(msg1);
+            if (objJsonResult.code == "0")
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = objJsonResult.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            oCN.Commit();
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = "鎴愬姛锛�";
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        public json AddBillMain(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+            int OperationType = int.Parse(sArray[2].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+            string user = sArray[3].ToString();
+            try
+            {
+                Xt_UserGroup omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Xt_UserGroup>(msg2);
+
+                var num = msg3.Split(',');
+
+                if (OperationType == 1)//鏂板
+                {
+                    //涓昏〃
+                    oCN.RunProc("insert into  System_UserGroup (GroupName,HLev,Explain)values" +
+                        $"('{omdelMian.GroupName}','{omdelMian.HLev}','{omdelMian.Explain}')");
+
+                    //鏂板鍚庢煡璇�  纭繚鏁版嵁娣诲姞鎴愬姛
+                    ds = oCN.RunProcReturn("Select * from  System_UserGroup where GroupName='" + omdelMian.GroupName + "'", "System_UserGroup");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鐢ㄦ埛鏂板澶辫触锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    var HGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["GroupID"]);
+                    oCN.RunProc("delete from  System_UserGroupInfo where GroupId=" + HGroupID.ToString());
+
+                    if (num[0] != "-1")
+                    {
+                        for (int i = 0; i < num.Length; i++)
+                        {
+                            oCN.RunProc("insert into  System_UserGroupInfo (GroupId,UserId) values (" + HGroupID.ToString() + ",'" + num[i] + "')");
+                        }
+                    }
+                  
+                }
+                else if (OperationType == 3)
+                {
+                    oCN.RunProc("update  System_UserGroup set GroupName='" + omdelMian.GroupName + "',HLev='" + omdelMian.HLev + "',Explain='" + omdelMian.Explain + "'"
+                    + " where GroupId=" + omdelMian.HGroupID);
+
+                    oCN.RunProc("delete from  System_UserGroupInfo where GroupId=" + omdelMian.HGroupID);
+                    for (int i = 0; i < num.Length; i++)
+                    {
+                        oCN.RunProc("insert into  System_UserGroupInfo (GroupId,UserId) values (" + omdelMian.HGroupID + ",'" + num[i] + "')");
+                    }
+                }
+              
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = null;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瑙掕壊鍒楄〃 鍒犻櫎
+        [Route("Xt_UserGroup/DelXt_UserGroupList")]
+        [HttpGet]
+        public object DelXt_UserGroupList(string HInterID,string User)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("select * from h_v_System_UserGroup where 1=1 and HGroupID=" + HInterID, "h_v_System_UserGroup");
+
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    oCN.BeginTran();//寮�鍚簨鍔�
+
+                    oCN.RunProc($"delete from h_v_System_UserGroup where HGroupID={HInterID}");
+
+                    oCN.Commit();//缁撴潫浜嬪姟
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "褰撳墠鍗曟嵁涓嶅瓨鍦�,鏃犳硶鍒犻櫎锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();//鍥炴粴浜嬪姟
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
 
 
-
-        //
     }
 }
\ No newline at end of file
diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs"
index 563f79c..8733e1a 100644
--- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs"
+++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs"
@@ -1222,8 +1222,7 @@
             try
             {
                 DataSet dt = new DataSet();
-                oCN.RunProc("exec h_p_ICMOBillList_PrimarySubTable");
-                ds = oCN.RunProcReturn($"select * from  ##ICMOBillList where 婧愬崟涓诲唴鐮� in({hmainid}) and  婧愬崟瀛愬唴鐮� in({HEntryID})", "##ICMOBillList");
+                ds = oCN.RunProcReturn($"exec h_p_ICMOBillList_PrimarySubTable '{hmainid}','{HEntryID}'", "h_p_ICMOBillList_PrimarySubTable");
 
                 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                 {
diff --git "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs" "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
index 0e031b3..48d3d4c 100644
--- "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
+++ "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
@@ -1,4 +1,6 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Model;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -19,6 +21,208 @@
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
+
+        #region 鐢熶骇浠诲姟鍗� 淇濆瓨/缂栬緫鍔熻兘
+        [Route("Sc_ICMOBill/ICMOBillEdit")]
+        [HttpPost]
+        public object ICMOBillEdit([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                var _value = sMainSub["sMainSub"].ToString();
+                string msg1 = _value.ToString();
+                oCN.BeginTran();
+                //淇濆瓨涓昏〃
+                objJsonResult = AddBillMain(msg1);
+                if (objJsonResult.code == "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                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 = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillMain(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString(); //涓昏〃鏁版嵁
+            string msg3 = sArray[1].ToString(); //瀛愯〃鏁版嵁
+            int OperationType = int.Parse(sArray[2].ToString()); // 鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+            string user = sArray[3].ToString();
+
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsSc_ICMOBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_ICMOBillMain>>(msg2);
+
+                long HInterID = mainList[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = mainList[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                long HPRDORGID = mainList[0].HPRDORGID;//缁勭粐
+                DateTime HDate = mainList[0].HDate;//鏃ユ湡
+                string HRemark = mainList[0].HRemark;//澶囨敞
+                string HSeOrderBillNo = mainList[0].HSeOrderBillNo;//閿�鍞鍗曞彿
+                long HSeOrderInterID = mainList[0].HSeOrderInterID;//閿�鍞涓籭d
+                long HSeOrderEntryID = mainList[0].HSeOrderEntryID;//閿�鍞瀛恑d
+                long HEmpID = mainList[0].HEmpID;//涓氬姟鍛�
+                long HCusID = mainList[0].HCusID;//瀹㈡埛
+                long HCenterID = mainList[0].HCenterID;//宸ヤ綔涓績
+                double? HPlanQty = mainList[0].HPlanQty==null?0: mainList[0].HPlanQty;//璁″垝鏁伴噺
+                string HMaker = user;//鍒跺崟浜�
+
+                ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_IF_ICMOBillList");
+
+                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //涓昏〃
+                    oCN.RunProc(@"Insert Into Sc_ICMOBillMain   
+                        (HBillType,HInterID,HBillNo,HDate,HPRDORGID
+                        ,HYear,HPeriod,HRemark,HMaker,HMakeDate
+                        ,HSeOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HEmpID,HCusID
+                        ,HCenterID,HPlanQty,HDeptID,HMaterID,HUnitID,HBomID,HPlanBeginDate,HPlanEndDate)
+                        values('3710'," + HInterID + ",'" + HBillNo + "','" + HDate + "',"+ HPRDORGID +
+                    "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()"+
+                    ",'"+ HSeOrderBillNo+"',"+ HSeOrderInterID + "," + HSeOrderEntryID + "," + HEmpID + "," + HCusID+
+                    ","+ HCenterID+ "," + HPlanQty+ ",0,0,0,0,'','') ");
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                { //淇敼
+                    oCN.RunProc("update Sc_ICMOBillMain  set " +
+                                "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" +
+                                ", HSeOrderBillNo='" + HSeOrderBillNo + "', HSeOrderInterID=" + HSeOrderInterID + ", HSeOrderEntryID=" + HSeOrderEntryID + ", HEmpID=" + HEmpID + ", HCusID=" + HCusID + "" +
+                                ", HCenterID=" + HCenterID + ", HPlanQty=" + HPlanQty + " where HInterID="+ HInterID);
+
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("delete from Sc_ICMOBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddBillSub(msg3, HInterID, OperationType);
+
+                if (objJsonResult.code == "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = null;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillSub(string msg3, long HInterID, int OperationType)
+        {
+            List<ClsSc_ICMOBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_ICMOBillSub>>(msg3);
+            int i = 0;
+            foreach (ClsSc_ICMOBillSub oSub in DetailColl)
+            {
+                i++;
+                if (oSub.HQty <= 0||oSub.HQty==null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝鏁伴噺涓嶈兘涓�0鎴栬�呭皬浜�0";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (oSub.HMaterID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝鐗╂枡涓嶈兘涓虹┖";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //if (oSub.HSourceID == 0)
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "绗�" + i + "琛岋紝鐢熶骇璧勬簮涓嶈兘涓虹┖";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                if (oSub.HDeptID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛�,鐢熶骇杞﹂棿涓嶈兘涓虹┖";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (oSub.HUnitID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绗�" + i + "琛岋紝璁¢噺鍗曚綅涓嶈兘涓虹┖";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.RunProc($@"Insert into Sc_ICMOBillSub 
+                (HInterID,HENTRYID,HQty
+                ,HPlanBeginDate,HPlanEndDate
+	            ,HBeginDate,HEndDate
+                ,HMaterID,HUnitID,HRemark,HSourceID,HDeptID,HSTATUS
+				,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney) 
+                 values({HInterID},{i},{(oSub.HQty==null?0:oSub.HQty)}
+                ,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
+                ,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
+                ,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HDeptID},{oSub.HSTATUS}
+	                    ,0,0,'','',0,0)");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+        #endregion
 
         #region 鐢熶骇浠诲姟鍗曞垹闄ゅ姛鑳�
         [Route("Sc_ICMOBill/DeltetSc_ICMOReportBill")]
@@ -56,6 +260,7 @@
                     return objJsonResult; ;
                 }
                 oCN.RunProc("delete from Sc_ICMOBillMain  where HInterID=" + HInterID);
+                oCN.RunProc("delete from Sc_ICMOBillSub  where HInterID=" + HInterID);
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;

--
Gitblit v1.9.1