From e35094276bca79b8cdb39f30c4752f2e200ff3ce Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 15 三月 2024 15:51:12 +0800
Subject: [PATCH] 上模单 下模单   单据 /列表 上模单pda 下模单  pda 单据 /列表

---
 Model/器具管理/ClsSc_MouldUpperBillMain.cs                 |   16 
 WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs | 1231 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 Model/器具管理/ClsSc_MouldLowerBillSub.cs                  |   26 +
 Model/Model.csproj                                     |    4 
 Model/器具管理/ClsSc_MouldUpperBillSub.cs                  |   26 +
 WebAPI/WebAPI.csproj                                   |    2 
 Model/器具管理/ClsSc_MouldLowerBillMain.cs                 |   16 
 7 files changed, 1,321 insertions(+), 0 deletions(-)

diff --git a/Model/Model.csproj b/Model/Model.csproj
index 055a172..193d72b 100644
--- a/Model/Model.csproj
+++ b/Model/Model.csproj
@@ -300,6 +300,10 @@
     <Compile Include="淇℃伅骞冲彴\ClsOA_MeetNotifyBillSub.cs" />
     <Compile Include="淇℃伅骞冲彴\ClsOA_NewMain.cs" />
     <Compile Include="淇℃伅骞冲彴\ClsOA_NewSub.cs" />
+    <Compile Include="鍣ㄥ叿绠$悊\ClsSc_MouldLowerBillMain.cs" />
+    <Compile Include="鍣ㄥ叿绠$悊\ClsSc_MouldLowerBillSub.cs" />
+    <Compile Include="鍣ㄥ叿绠$悊\ClsSc_MouldUpperBillSub.cs" />
+    <Compile Include="鍣ㄥ叿绠$悊\ClsSc_MouldUpperBillMain.cs" />
     <Compile Include="鍩虹璧勬枡\K3鍩虹璧勬枡\ClsK3_Customer_Model.cs" />
     <Compile Include="鍩虹璧勬枡\K3鍩虹璧勬枡\ClsK3_Department_Model.cs" />
     <Compile Include="鍩虹璧勬枡\K3鍩虹璧勬枡\ClsK3_Employee_Model.cs" />
diff --git "a/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldLowerBillMain.cs" "b/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldLowerBillMain.cs"
new file mode 100644
index 0000000..bbddaf8
--- /dev/null
+++ "b/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldLowerBillMain.cs"
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Model
+{
+    public class ClsSc_MouldLowerBillMain : DBUtility.ClsXt_BaseBillMain
+    {
+        
+        public Int64 HDeptID;//		int		--部门ID
+        public Int64 HEmpID;//		int		--操作员
+        public Int64 HMangerID;//		int		--负责人
+        public int HOrgID;//		int		--组织
+        
+    }
+}
diff --git "a/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldLowerBillSub.cs" "b/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldLowerBillSub.cs"
new file mode 100644
index 0000000..63604d1
--- /dev/null
+++ "b/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldLowerBillSub.cs"
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Model
+{
+    public class ClsSc_MouldLowerBillSub : DBUtility.ClsXt_BaseBillMain
+    {
+        
+        public Int64 HMouldID;		 
+        public Int64 HUnitID;		 
+        public Int64 HQty;		 
+        public Int64 HSourceID;	 
+        public Int64 HEquipID;	 
+        public Int64 HICMOInterID;	 
+        public Int64 HICMOEntryID;	 
+        public string HICMOBillNo;
+        public Int64 HProcExchInterID;
+        public Int64 HProcExchEntryID;
+        public string HProcExchBillNo;
+        public string HScanDate;
+        public string HBarCode;
+        public string HMouldNumber;
+
+    }
+}
diff --git "a/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldUpperBillMain.cs" "b/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldUpperBillMain.cs"
new file mode 100644
index 0000000..89dd80a
--- /dev/null
+++ "b/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldUpperBillMain.cs"
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Model
+{
+    public class ClsSc_MouldUpperBillMain : DBUtility.ClsXt_BaseBillMain
+    {
+        
+        public Int64 HDeptID;//		int		--部门ID
+        public Int64 HEmpID;//		int		--操作员
+        public Int64 HMangerID;//		int		--负责人
+        public int HOrgID;//		int		--组织
+        
+    }
+}
diff --git "a/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldUpperBillSub.cs" "b/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldUpperBillSub.cs"
new file mode 100644
index 0000000..c7de990
--- /dev/null
+++ "b/Model/\345\231\250\345\205\267\347\256\241\347\220\206/ClsSc_MouldUpperBillSub.cs"
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Model
+{
+    public class ClsSc_MouldUpperBillSub : DBUtility.ClsXt_BaseBillMain
+    {
+        
+        public Int64 HMouldID;		 
+        public Int64 HUnitID;		 
+        public Int64 HQty;		 
+        public Int64 HSourceID;	 
+        public Int64 HEquipID;	 
+        public Int64 HICMOInterID;	 
+        public Int64 HICMOEntryID;	 
+        public string HICMOBillNo;
+        public Int64 HProcExchInterID;
+        public Int64 HProcExchEntryID;
+        public string HProcExchBillNo;
+        public string HScanDate;
+        public string HBarCode;
+        public string HMouldNumber;
+
+    }
+}
diff --git a/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs b/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs
new file mode 100644
index 0000000..9ba9e13
--- /dev/null
+++ b/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs
@@ -0,0 +1,1231 @@
+锘縰sing Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+using System.Web.Http;
+using WebAPI.Models;
+using Newtonsoft.Json;
+using Model;
+using DBUtility;
+
+namespace WebAPI.Controllers.MJGL
+{
+    public class Sc_MouldUpperBillController : ApiController
+    {
+        private json objJsonResult = new json();
+        public DataSet ds = new DataSet();
+        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
+
+        #region 涓婃ā鍗� 鍒楄〃鏌ヨ
+        [Route("Sc_MouldUpperBill/Sc_MouldUpperBillList")]
+        [HttpGet]
+        public object Sc_MouldUpperBillList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ds = oCN.RunProcReturn("select * from  h_v_Qj_Sc_MouldUpperBillList where 1=1" + sWhere + "order by hmainid desc ", "h_v_Qj_Sc_MouldUpperBillList");
+
+                //娣诲姞鍒楀悕
+                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 e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 涓婃ā鍗� 鏂板
+        /// <summary>
+        /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Sc_MouldUpperBill/AddSc_MouldUpperBill")]
+        [HttpPost]
+        public object AddSc_MouldUpperBill([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 = ds.Tables[0];
+            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淇敼 2 澶嶅埗 
+            string user = sArray[3].ToString();//鐢ㄦ埛鍚�
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愮紪杈�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsSc_MouldUpperBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillMain>>(msg2);
+                string HBillType = "3846";
+                long HInterID = mainList[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = mainList[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                DateTime HDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));//鏃ユ湡
+                int HYear = DateTime.Now.Year;
+                double HPeriod = DateTime.Now.Month;
+                string HRemark = mainList[0].HRemark;//澶囨敞
+                string HMaker = mainList[0].HMaker;//鍒跺崟浜�
+                int HOrgID = mainList[0].HOrgID;  //缁勭粐
+                Int64 HDeptID = mainList[0].HDeptID;
+                Int64 HEmpID = mainList[0].HEmpID;
+                Int64 HMangerID = mainList[0].HMangerID;
+
+                ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldUpperBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_Qj_Sc_MouldUpperBillList");
+
+                if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //涓昏〃
+                    oCN.RunProc(@"Insert Into Sc_MouldUpperBillMain   
+                   (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate
+                   , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID
+                   , HDeptID, HEmpID, HMangerID)" +
+                    " values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
+                    "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," +  HOrgID + 
+                    ","+ HDeptID + ","+ HEmpID + ","+ HMangerID + ") ");
+
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                { //淇敼
+                    oCN.RunProc("update Sc_MouldUpperBillMain  set " +
+                       "HDate='" + HDate +
+                       "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker +
+                       "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'");
+
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddBillSub(msg3, HInterID, HBillNo);
+                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,string HBillNo)
+        {
+            List<ClsSc_MouldUpperBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillSub>>(msg3);
+            int i = 0;
+            foreach (ClsSc_MouldUpperBillSub oSub in DetailColl)
+            {
+                i++;
+
+                oCN.RunProc(@"Insert Into Sc_MouldUpperBillSub   
+                   (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty
+                   , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo)
+                    values("
+                     + HInterID + ",'"+ HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty 
+                     + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString()+",'"+ oSub.HICMOBillNo.ToString() +
+                     "') ");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        #endregion
+
+        #region 涓婃ā鍗曞垹闄ゅ姛鑳�
+        [Route("Sc_MouldUpperBill/DeltetSc_MouldUpperBill")]
+        [HttpGet]
+        public object DeltetSc_MouldUpperBill(string HInterID, int HPRDORGID, string user)
+        {
+
+            //缂栬緫鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            string[] HInterIDs = HInterID.Split(',');
+            string[] HBillNos = new string[HInterIDs.Length];
+
+            for (int i = 0; i < HInterIDs.Length; i++)
+            {
+                oCN.BeginTran();
+                string hmainid = HInterIDs[i].Split('_')[0];
+                string hsubid = HInterIDs[i].Split('_')[1];
+
+                ds = oCN.RunProcReturn(@"select HMaker,HBillNo,HBillStatus,HChecker from Sc_MouldUpperBillMain a
+                                    inner join Sc_MouldUpperBillSub b on a.HInterID = b.HInterID
+                                    where a.HInterID = " + hmainid , "Sc_MouldUpperBillMain");
+
+                if (ds.Tables[0].Rows.Count != 0)
+                {
+                    HBillNos[i] = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+                    string sReturn = "";
+                    if (oSystemParameter.ShowBill(ref sReturn))
+                    {
+                        if (oSystemParameter.omodel.Sc_ProcessExchangeBill_DeleterAndMakerMustSame == "Y")
+                        {
+                            if (ds.Tables[0].Rows[0]["HMaker"].ToString() != user && (user != "admin" && user != "Admin"))
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鍗曟嵁鍙�:" + HBillNos[i] + "鍙兘鍒犻櫎鏈汉鐨勫崟鎹紒";
+                                objJsonResult.data = null;
+                                oCN.RollBack();
+                                return objJsonResult;
+                            }
+                        }
+                    }
+
+                    if (int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鍙�:" + HBillNos[i] + "鍗曟嵁褰撳墠澶勪簬涓嶈兘鍒犻櫎鐘舵��,涓嶈兘鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HChecker"].ToString()  != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鍙�:" + HBillNos[i] + "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows.Count == 1) {
+                        oCN.RunProc("delete from Sc_MouldUpperBillMain where HInterID=" + hmainid);
+                    }
+
+                    oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID=" + hmainid + " and HEntryID=" + hsubid);
+
+                    oCN.Commit();
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鏈壘鍒�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = "鍒犻櫎鎴愬姛!";
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+        #endregion
+
+        #region 涓婃ā鍗曞鏍�/鍙嶅鏍稿姛鑳�
+        [Route("Sc_MouldUpperBill/CheckSc_MouldUpperBill")]
+        [HttpGet]
+        public object CheckSc_MouldUpperBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Sub_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "Sc_MouldUpperBillMain";
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 瀹℃牳  2  鍙嶅鏍�
+                if (Type == 1)
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶉渶瑕佸啀瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //瀹℃牳鍗曟嵁
+                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+
+                }
+                else
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍�
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插弽瀹℃牳!涓嶉渶瑕佸啀鍙嶅鏍�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //鍙嶅鏍稿崟鎹�
+                        if (BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
+        #region 涓嬫ā鍗� 鍒楄〃鏌ヨ
+        [Route("Sc_MouldUpperBill/Sc_MouldLowerBillList")]
+        [HttpGet]
+        public object Sc_MouldLowerBillList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ds = oCN.RunProcReturn("select * from  h_v_Qj_Sc_MouldLowerBillList where 1=1" + sWhere + "order by hmainid desc ", "h_v_Qj_Sc_MouldLowerBillList");
+
+                //娣诲姞鍒楀悕
+                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 e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 涓嬫ā鍗� 鏂板
+        /// <summary>
+        /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Sc_MouldUpperBill/AddSc_MouldLowerBill")]
+        [HttpPost]
+        public object AddSc_MouldLowerBill([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            oCN.BeginTran();
+            //淇濆瓨涓昏〃
+            objJsonResult = AddMouldLowerBill(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 = ds.Tables[0];
+            return objJsonResult;
+        }
+
+        public json AddMouldLowerBill(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淇敼 2 澶嶅埗 
+            string user = sArray[3].ToString();//鐢ㄦ埛鍚�
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愮紪杈�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsSc_MouldLowerBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillMain>>(msg2);
+                string HBillType = "3847";
+                long HInterID = mainList[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = mainList[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                DateTime HDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));//鏃ユ湡
+                int HYear = DateTime.Now.Year;
+                double HPeriod = DateTime.Now.Month;
+                string HRemark = mainList[0].HRemark;//澶囨敞
+                string HMaker = mainList[0].HMaker;//鍒跺崟浜�
+                int HOrgID = mainList[0].HOrgID;  //缁勭粐
+                Int64 HDeptID = mainList[0].HDeptID;
+                Int64 HEmpID = mainList[0].HEmpID;
+                Int64 HMangerID = mainList[0].HMangerID;
+
+                ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldLowerBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_Qj_Sc_MouldLowerBillList");
+
+                if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //涓昏〃
+                    oCN.RunProc(@"Insert Into Sc_MouldLowerBillMain   
+                   (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate
+                   , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID
+                   , HDeptID, HEmpID, HMangerID)" +
+                    " values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
+                    "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," + HOrgID +
+                    "," + HDeptID + "," + HEmpID + "," + HMangerID + ") ");
+
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                { //淇敼
+                    oCN.RunProc("update Sc_MouldLowerBillMain  set " +
+                       "HDate='" + HDate +
+                       "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker +
+                       "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'");
+
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddMouldLowerBill(msg3, HInterID, HBillNo);
+                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 AddMouldLowerBill(string msg3, long HInterID, string HBillNo)
+        {
+            List<ClsSc_MouldLowerBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillSub>>(msg3);
+            int i = 0;
+            foreach (ClsSc_MouldLowerBillSub oSub in DetailColl)
+            {
+                i++;
+
+                oCN.RunProc(@"Insert Into Sc_MouldLowerBillSub   
+                   (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty
+                   , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo)
+                    values("
+                     + HInterID + ",'" + HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty
+                     + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo.ToString() +
+                     "') ");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        #endregion
+
+        #region 涓嬫ā鍗曞垹闄ゅ姛鑳�
+        [Route("Sc_MouldUpperBill/DeltetSc_MouldLowerBill")]
+        [HttpGet]
+        public object DeltetSc_MouldLowerBill(string HInterID, int HPRDORGID, string user)
+        {
+
+            //缂栬緫鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            string[] HInterIDs = HInterID.Split(',');
+            string[] HBillNos = new string[HInterIDs.Length];
+
+            for (int i = 0; i < HInterIDs.Length; i++)
+            {
+                oCN.BeginTran();
+                string hmainid = HInterIDs[i].Split('_')[0];
+                string hsubid = HInterIDs[i].Split('_')[1];
+
+                ds = oCN.RunProcReturn(@"select HMaker,HBillNo,HBillStatus,HChecker from Sc_MouldLowerBillMain a
+                                    inner join Sc_MouldLowerBillSub b on a.HInterID = b.HInterID
+                                    where a.HInterID = " + hmainid, "Sc_MouldLowerBillMain");
+
+                if (ds.Tables[0].Rows.Count != 0)
+                {
+                    HBillNos[i] = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+                    string sReturn = "";
+                    if (oSystemParameter.ShowBill(ref sReturn))
+                    {
+                        if (oSystemParameter.omodel.Sc_ProcessExchangeBill_DeleterAndMakerMustSame == "Y")
+                        {
+                            if (ds.Tables[0].Rows[0]["HMaker"].ToString() != user && (user != "admin" && user != "Admin"))
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鍗曟嵁鍙�:" + HBillNos[i] + "鍙兘鍒犻櫎鏈汉鐨勫崟鎹紒";
+                                objJsonResult.data = null;
+                                oCN.RollBack();
+                                return objJsonResult;
+                            }
+                        }
+                    }
+
+                    if (int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鍙�:" + HBillNos[i] + "鍗曟嵁褰撳墠澶勪簬涓嶈兘鍒犻櫎鐘舵��,涓嶈兘鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鍙�:" + HBillNos[i] + "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows.Count == 1)
+                    {
+                        oCN.RunProc("delete from Sc_MouldLowerBillMain where HInterID=" + hmainid);
+                    }
+
+                    oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID=" + hmainid + " and HEntryID=" + hsubid);
+
+                    oCN.Commit();
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鏈壘鍒�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = "鍒犻櫎鎴愬姛!";
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+        #endregion
+
+        #region 涓嬫ā鍗曞鏍�/鍙嶅鏍稿姛鑳�
+        [Route("Sc_MouldUpperBill/CheckSc_MouldLowerBill")]
+        [HttpGet]
+        public object CheckSc_MouldLowerBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Sub_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "Sc_MouldLowerBillMain";
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 瀹℃牳  2  鍙嶅鏍�
+                if (Type == 1)
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶉渶瑕佸啀瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //瀹℃牳鍗曟嵁
+                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    else {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍�
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插弽瀹℃牳!涓嶉渶瑕佸啀鍙嶅鏍�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //鍙嶅鏍稿崟鎹�
+                        if (BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        {
+
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
+        #region 涓�/涓嬫ā鍗曡幏鍙栨潯鐮佷俊鎭�
+        [Route("Sc_MouldUpperBill/txtHBarCode_KeyDown")]
+        [HttpGet]
+        public object txtHBarCode_KeyDown(string HBarCode, string UserID, string HBillType)
+        {
+            try
+            {
+                if (HBarCode == null || HBarCode.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绌虹櫧鐮�,鏉″舰鐮佷笉鑳戒负绌猴紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鎷嗗垎鏉″舰鐮�
+                string sBillBarCode = HBarCode.Trim();
+
+              
+                //鎴彇鏉$爜绫诲瀷2 鍓嶄袱浣�
+                string BillNoType2 = sBillBarCode.Substring(0, Math.Min(2, sBillBarCode.Length));
+                //鎴彇鏉$爜绫诲瀷 鍓嶄笁浣�
+                string BillNoType3 = sBillBarCode.Substring(0, Math.Min(3, sBillBarCode.Length));
+                //鎴彇鏉$爜绫诲瀷3 鍓嶅洓浣�
+                string BillNoType4 = sBillBarCode.Substring(0, Math.Min(4, sBillBarCode.Length));
+
+
+                switch (BillNoType2)
+                {
+                    //鐢熶骇璧勬簮
+                    case "BM":
+                    case "SS":
+                        ds = oCN.RunProcReturn("select HItemID,HName,HNumber from Gy_Source where HNumber = '" + HBarCode + "'", "Gy_Source");
+                        break;
+                    case "MO":
+                        ds = oCN.RunProcReturn("select 鍗曟嵁鍙�,hmainid,HEntryID from h_v_IF_ICMOBillList where 鍗曟嵁鍙� = '" + HBarCode + "'", "h_v_IF_ICMOBillList");
+                        break;
+                    default:
+                        break;
+                }
+
+                switch (BillNoType3)
+                {
+                    //鍣ㄥ叿妗f
+                    case "MJD":
+                    case "PAK":
+                        ds = oCN.RunProcReturn("select * from h_v_Gy_MouldFileList where 鍗曟嵁鍙� = '" + HBarCode + "'", "h_v_Gy_MouldFileList");
+                        break;
+                    default:
+                        break;
+                }
+
+                switch (BillNoType4)
+                {
+                    //娴佽浆鍗�
+                    case "GXLX":
+                        ds = oCN.RunProcReturn("select 浠诲姟鍗曞彿,hicmointerid,HICMOEntryID,鍗曟嵁鍙�,hmainid,HEntryID from h_v_Sc_ProcessExchangeBillQuerySub where 鍗曟嵁鍙� = '" + HBarCode + "'", "h_v_Sc_ProcessExchangeBillQuerySub");
+                        break;
+                    default:
+                        break;
+                }
+
+                if (ds == null || ds .Tables.Count== 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏌ユ棤鏁版嵁锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                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 涓婃ā鍗� PDA鏂板
+        /// <summary>
+        /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Sc_MouldUpperBill/AddSc_MouldUpperBill_PDA")]
+        [HttpPost]
+        public object AddSc_MouldUpperBill_PDA([FromBody] JObject oMain)
+        {
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            oCN.BeginTran();
+            //淇濆瓨涓昏〃
+            objJsonResult = AddBillMain_PDA(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 = ds.Tables[0];
+            return objJsonResult;
+        }
+
+        public json AddBillMain_PDA(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();//鐢ㄦ埛鍚�
+            int OperationType = int.Parse(sArray[2].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗 
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愮紪杈�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsSc_MouldUpperBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillMain>>(msg2);
+                string HBillType = "3846";
+                long HInterID = mainList[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = mainList[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                DateTime HDate = mainList[0].HDate;//鏃ユ湡
+                int HYear = DateTime.Now.Year;
+                double HPeriod = DateTime.Now.Month;
+                string HRemark = mainList[0].HRemark;//澶囨敞
+                string HMaker = mainList[0].HMaker;//鍒跺崟浜�
+                int HOrgID = mainList[0].HOrgID;  //缁勭粐
+                Int64 HDeptID = mainList[0].HDeptID;
+                Int64 HEmpID = mainList[0].HEmpID;
+                Int64 HMangerID = mainList[0].HMangerID;
+
+                ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldUpperBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_Qj_Sc_MouldUpperBillList");
+
+                if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //涓昏〃
+                    oCN.RunProc(@"Insert Into Sc_MouldUpperBillMain   
+                   (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate
+                   , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID
+                   , HDeptID, HEmpID, HMangerID)" +
+                    " values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
+                    "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," + HOrgID +
+                    "," + HDeptID + "," + HEmpID + "," + HMangerID + ") ");
+
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                { //淇敼
+                    oCN.RunProc("update Sc_MouldUpperBillMain  set " +
+                       "HDate='" + HDate +
+                       "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker +
+                       "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'");
+
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddBillSub_PDA(msg2, HInterID, HBillNo);
+                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_PDA(string msg2, long HInterID, string HBillNo)
+        {
+            List<ClsSc_MouldUpperBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillSub>>(msg2);
+            int i = 0;
+            foreach (ClsSc_MouldUpperBillSub oSub in DetailColl)
+            {
+                i++;
+
+                oCN.RunProc(@"Insert Into Sc_MouldUpperBillSub   
+                   (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty
+                   , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo
+                    ,HProcExchBillNo,HProcExchInterID,HProcExchEntryID
+                    ,HScanDate,HBarCode)
+                    values("
+                     + HInterID + ",'" + HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty
+                     + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo.ToString()
+                     + "','" + oSub.HProcExchBillNo.ToString() + "'," + oSub.HProcExchInterID.ToString() + "," + oSub.HProcExchEntryID.ToString()
+                     + ",'" + oSub.HScanDate.ToString() + "','" + oSub.HMouldNumber.ToString() + "') ");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        #endregion
+
+        #region 涓嬫ā鍗� PDA鏂板
+        /// <summary>
+        /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Sc_MouldUpperBill/AddSc_MouldLowerBill_PDA")]
+        [HttpPost]
+        public object AddSc_MouldLowerBill_PDA([FromBody] JObject oMain)
+        {
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            oCN.BeginTran();
+            //淇濆瓨涓昏〃
+            objJsonResult = AddSc_MouldLowerBillMain_PDA(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 = ds.Tables[0];
+            return objJsonResult;
+        }
+
+        public json AddSc_MouldLowerBillMain_PDA(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();//鐢ㄦ埛鍚�
+            int OperationType = int.Parse(sArray[2].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗 
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愮紪杈�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsSc_MouldLowerBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillMain>>(msg2);
+                string HBillType = "3847";
+                long HInterID = mainList[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = mainList[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                DateTime HDate = mainList[0].HDate;//鏃ユ湡
+                int HYear = DateTime.Now.Year;
+                double HPeriod = DateTime.Now.Month;
+                string HRemark = mainList[0].HRemark;//澶囨敞
+                string HMaker = mainList[0].HMaker;//鍒跺崟浜�
+                int HOrgID = mainList[0].HOrgID;  //缁勭粐
+                Int64 HDeptID = mainList[0].HDeptID;
+                Int64 HEmpID = mainList[0].HEmpID;
+                Int64 HMangerID = mainList[0].HMangerID;
+
+                ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldLowerBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_Qj_Sc_MouldLowerBillList");
+
+                if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //涓昏〃
+                    oCN.RunProc(@"Insert Into Sc_MouldLowerBillMain   
+                   (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate
+                   , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID
+                   , HDeptID, HEmpID, HMangerID)" +
+                    " values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
+                    "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," + HOrgID +
+                    "," + HDeptID + "," + HEmpID + "," + HMangerID + ") ");
+
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                { //淇敼
+                    oCN.RunProc("update Sc_MouldLowerBillMain  set " +
+                       "HDate='" + HDate +
+                       "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker +
+                       "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'");
+
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddSc_MouldLowerBillSub_PDA(msg2, HInterID, HBillNo);
+                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 AddSc_MouldLowerBillSub_PDA(string msg2, long HInterID, string HBillNo)
+        {
+            List<ClsSc_MouldLowerBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillSub>>(msg2);
+            int i = 0;
+            foreach (ClsSc_MouldLowerBillSub oSub in DetailColl)
+            {
+                i++;
+
+                oCN.RunProc(@"Insert Into Sc_MouldLowerBillSub   
+                   (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty
+                   , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo
+                    ,HProcExchBillNo,HProcExchInterID,HProcExchEntryID
+                    ,HScanDate,HBarCode)
+                    values("
+                     + HInterID + ",'" + HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty
+                     + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo.ToString()
+                     + "','" + oSub.HProcExchBillNo.ToString() + "'," + oSub.HProcExchInterID.ToString() + "," + oSub.HProcExchEntryID.ToString()
+                     + ",'" + oSub.HScanDate.ToString() + "','" + oSub.HMouldNumber.ToString() + "') ");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        #endregion
+    }
+}
\ No newline at end of file
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index a433cfb..78d2d48 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -415,6 +415,7 @@
     <Compile Include="Controllers\MJGL\Sc_MouldLifeUseBillController.cs" />
     <Compile Include="Controllers\MJGL\Sc_MouldScrapRequestBillController.cs" />
     <Compile Include="Controllers\MJGL\Sc_MouldStatusChangeBillController.cs" />
+    <Compile Include="Controllers\MJGL\Sc_MouldUpperBillController.cs" />
     <Compile Include="Controllers\Pay_ReportController.cs" />
     <Compile Include="Controllers\SBGL\Sb_EquipConkBookBillController.cs" />
     <Compile Include="Controllers\SBGL\Sb_EquipSparepartsBillController.cs" />
@@ -1073,6 +1074,7 @@
     <Folder Include="Views\Sc_MouldRepairSendWorkBill\" />
     <Folder Include="Views\Sc_MouldScrapRequestBill\" />
     <Folder Include="Views\Sc_MouldStatusChangeBill\" />
+    <Folder Include="Views\Sc_MouldUpperBill\" />
     <Folder Include="Views\Sc_ProcessExchangeIssueBill\" />
     <Folder Include="Views\Sc_ProcessSendWork\" />
     <Folder Include="Views\Sc_ProcExchRecordBackBill\" />

--
Gitblit v1.9.1