From 1bb2a53375ae3f3b54cc6b5a47f11027b0bb8b97 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 25 十一月 2022 17:15:14 +0800
Subject: [PATCH] 生产订单新增 无列表

---
 Model/生产管理/ClsSc_ICMOBillSub.cs                        |    6 +
 WebAPI/Controllers/生产管理/生产任务单/Sc_ICMOBillController.cs |  201 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 206 insertions(+), 1 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 190dc6b..ec51d91 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"
@@ -14,7 +14,11 @@
         public Int64 HUnitID;
         public double? HQty;
         public int HSTATUS;
-        public DateTime? HPlanBeginDate= DateTime.Parse(DateTime.Now.ToString("F"));
+        public DateTime? HPlanBeginDate;
         public DateTime? HPlanEndDate;
+        public DateTime? HBeginDate;
+        public DateTime? HEndDate;
+        public Int64 HBomID;
+        public Int64 HCusID;
     }
 }
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 48d3d4c..1b1ef33 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"
@@ -224,6 +224,207 @@
         }
         #endregion
 
+        #region 鐢熶骇浠诲姟鍗�(鏃犲垪琛�) 淇濆瓨/缂栬緫鍔熻兘
+        [Route("Sc_ICMOBill/ICMOBillEdit_NoTable")]
+        [HttpPost]
+        public object ICMOBillEdit_NoTable([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                var _value = sMainSub["sMainSub"].ToString();
+                string msg1 = _value.ToString();
+                oCN.BeginTran();
+                //淇濆瓨涓昏〃
+                objJsonResult = AddBillMain_NoTable(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_NoTable(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString(); //涓昏〃鏁版嵁
+            int OperationType = int.Parse(sArray[1].ToString()); // 鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+            string user = sArray[2].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;
+                }
+
+                var msg3 = msg2.ToString();
+                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;//宸ヤ綔涓績
+                long HBomID = mainList[0].HBomID;//bom
+                //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 + ",0,0,0,0,"+ HBomID + ",'','') ");
+                }
+                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 + ",HBomID="+ HBomID + " where HInterID=" + HInterID);
+
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("delete from Sc_ICMOBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddBillSub_NoTable(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_NoTable(string msg3, long HInterID, int OperationType)
+        {
+            ClsSc_ICMOBillSub oSub = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsSc_ICMOBillSub>(msg3);
+            if (oSub.HQty <= 0 || oSub.HQty == null)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏁伴噺涓嶈兘涓�0鎴栬�呭皬浜�0";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            if (oSub.HMaterID == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鐗╂枡涓嶈兘涓虹┖";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            if (oSub.HDeptID == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鐢熶骇杞﹂棿涓嶈兘涓虹┖";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            if (oSub.HUnitID == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "璁¢噺鍗曚綅涓嶈兘涓虹┖";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            if (oSub.HBomID == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "BOM涓嶈兘涓虹┖";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            oCN.RunProc($@"Insert into Sc_ICMOBillSub 
+                (HInterID,HENTRYID,HQty
+                ,HPlanBeginDate,HPlanEndDate
+	            ,HBeginDate,HEndDate
+                ,HMaterID,HUnitID,HRemark,HSourceID,HDeptID,HSTATUS
+                ,HBomID,HEntryCusID
+				,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney) 
+                 values({HInterID},1,{(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.HBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HBeginDate.ToString())}','{(oSub.HEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HEndDate.ToString())}'
+                ,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HDeptID},{oSub.HSTATUS}
+                 ,{oSub.HBomID}  ,{oSub.HCusID} 
+	                    ,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")]
         [HttpGet]

--
Gitblit v1.9.1