From 1c90213ebd42e2d00324a71a67a60d07e4c8a7da Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期二, 28 四月 2026 09:08:39 +0800
Subject: [PATCH] 修复接口签名,新增抽样方案

---
 WebAPI/Controllers/BaseSet/Gy_SampleSchemeController.cs |  715 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 714 insertions(+), 1 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_SampleSchemeController.cs b/WebAPI/Controllers/BaseSet/Gy_SampleSchemeController.cs
index 04778d4..b90fbec 100644
--- a/WebAPI/Controllers/BaseSet/Gy_SampleSchemeController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_SampleSchemeController.cs
@@ -33,7 +33,7 @@
             {
                 List<object> columnNameList = new List<object>();
                 //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Gy_WorkCenter_Query", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log("Gy_SampleScheme_Query", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -68,5 +68,718 @@
                 return objJsonResult;
             }
         }
+
+        /// <summary>
+        /// 淇濆瓨鎸夐挳
+        /// </summary>
+        [Route("Gy_SampleScheme/ModifyByID")]
+        [HttpPost]
+        public object ModifyByID([FromBody] JObject oMain)
+        {
+            try
+            {
+
+                var _value = oMain["oMain"].ToString();
+                string msg1 = _value.ToString();
+                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+                string msg2 = sArray[0].ToString();
+                string msg3 = sArray[1].ToString();
+                string msg4 = sArray[2].ToString();
+
+                //鍒ゆ柇鏉冮檺
+                if (!ClsPub.Security_Log("Gy_SampleScheme_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+
+                //鍙嶅簭鍒楀寲
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsGy_SampleScheme_Model> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_SampleScheme_Model>>(msg2);
+                List<ClsGy_SampleSchemeSub_Model> list1 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_SampleSchemeSub_Model>>(msg3);
+                long HItemID = list[0].HItemID;
+                string HNumber = list[0].HNumber;
+                string HName = list[0].HName;
+                string HShortNumber = list[0].HShortNumber;
+                long HParentID = list[0].HParentID;
+                long HLevel = list[0].HLevel;
+                bool HEndFlag = list[0].HEndFlag;
+                bool HStopflag = list[0].HStopflag;
+                string HRemark = list[0].HRemark;
+                string HHelpCode = list[0].HHelpCode;
+                string HUseFlag = list[0].HUseFlag;
+                string HMakeTime = list[0].HMakeTime;
+                string HMakeEmp = msg4;
+                long HUSEORGID = list[0].HUSEORGID;
+                long HCREATEORGID = list[0].HCREATEORGID;
+                long HUnitID = list[0].HUnitID;
+
+
+                if (!DBUtility.ClsPub.AllowNumber(HNumber))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                if (HItemID == 0)
+                {
+                    oCN.BeginTran();
+                    //淇濆瓨鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_SampleScheme_BeforeSaveCtrl " + HMakeEmp + ",'" + 1 + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_SampleScheme_BeforeSaveCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:淇濆瓨鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    string _sql = "select HItemID from Gy_SampleScheme where HNumber = N'" + HNumber + "'";
+                    DataSet _ds = oCN.RunProcReturn(_sql, "Gy_SampleScheme");
+                    if (_ds.Tables[0].Rows.Count > 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触: 浠g爜閲嶅!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+
+                    string sql = $@"INSERT INTO [Gy_SampleScheme] ([HName], [HShortNumber], [HParentID], [HLevel], [HEndFlag], [HStopflag], [HRemark], [HHelpCode], [HUseFlag], [HMakeTime], [HMakeEmp], [HCheckEmp], [HCheckTime], [HModifyEmp], [HModifyTime], [HStopEmp], [HStopTime], [HUSEORGID], [HCREATEORGID], [HInterID], [HSampleTimes], [HSampleType], [HSampleLevel], [HStrictLevel], [HAQL], [HEffectDate], [HExpireDate], [HIsSystemSet], [HERPItemID], [HNumber]) 
+                VALUES (
+                '{list[0].HName}', '{list[0].HShortNumber}',  '{list[0].HParentID}',  '{list[0].HLevel}',  '{list[0].HEndFlag}',  '{list[0].HStopflag}',  '{list[0].HRemark}',  '{list[0].HHelpCode}',  '{list[0].HUseFlag}',  '{list[0].HMakeTime}',  '{HMakeEmp}',  '{list[0].HCheckEmp}','{list[0].HCheckTime}','{list[0].HModifyEmp}',  '{list[0].HModifyTime}',  '{list[0].HStopEmp}','{list[0].HStopTime}','{list[0].HUSEORGID}','{list[0].HCREATEORGID}','{list[0].HInterID}','{list[0].HSampleTimes}','{list[0].HSampleType}','{list[0].HSampleLevel}','{list[0].HStrictLevel}','{list[0].HAQL}','{list[0].HEffectDate}','{list[0].HExpireDate}','{list[0].HIsSystemSet}','{0}','{list[0].HNumber}'
+                ); ";
+                    oCN.RunProc(sql);
+                    //淇敼涓婄骇涓洪潪鏈骇浠g爜
+                    oCN.RunProc("Update Gy_SampleScheme set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
+
+                    // 鎵ц鏌ヨ鑾峰彇HItemID
+                    DataSet temp_ds = oCN.RunProcReturn("select top 1 HItemID from Gy_SampleScheme where HNumber = N'" + HNumber + "'", "Gy_SampleScheme");
+
+                    if (temp_ds.Tables[0].Rows.Count < 1)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜锛氭彃鍏ヤ富琛ㄦ暟鎹け璐�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    int itemID = int.Parse(temp_ds.Tables[0].Rows[0]["HItemID"].ToString());
+                    string sql3 = "";
+
+                    // 鏀逛负for寰幆锛孒EntryID浠�1寮�濮嬮�掑
+                    for (int i = 0; i < list1.Count; i++)
+                    {
+                        // 鑾峰彇褰撳墠寰幆鐨勫疄浣撳璞�
+                        ClsGy_SampleSchemeSub_Model listOne = list1[i];
+                        int entryID = i + 1;
+
+                        sql3 = $@"INSERT INTO [Gy_SampleSchemeSub] ([HInterID], [HEntryID], [HBatch], [HSampleCode], [HSampleRate], [HExpression], [HRejectQty], [HAcceptQty], [HSampleQty], [HSampleLow], [HSampleUp]) VALUES(
+                        '{itemID}', '{entryID}',  '{listOne.HBatch}',  '{listOne.HSampleCode}',  '{listOne.HSampleRate}',  '{listOne.HExpression}',  '{listOne.HRejectQty}',  '{listOne.HAcceptQty}',  '{listOne.HSampleQty}',  '{listOne.HSampleLow}',  '{listOne.HSampleUp}'
+                        ); ";
+                        oCN.RunProc(sql3);
+                    }
+
+
+
+                    //淇濆瓨鍚庢帶鍒�=========================================      
+                    string sql2 = "exec h_p_Gy_SampleScheme_AfterSaveCtrl " + HMakeEmp + ",'" + 1 + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_SampleScheme_AfterSaveCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜锛氫繚瀛樺悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================                                       
+
+                    oCN.Commit();
+                }
+                else
+                {
+                    //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                    oCN.BeginTran();
+
+                    //淇濆瓨鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_SampleScheme_BeforeSaveCtrl " + HMakeEmp + ",'" + 2 + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_SampleScheme_BeforeSaveCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:淇濆瓨鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+                    //涓昏〃
+                    oCN.RunProc("Update Gy_SampleScheme" + " set " +
+                " HName='" + list[0].HName + "'" +
+                ",HShortNumber='" + list[0].HShortNumber + "'" +
+                ",HParentID=" + list[0].HParentID +
+                ",HLevel=" + list[0].HLevel +
+                ",HEndFlag=" + Convert.ToString(list[0].HEndFlag ? 1 : 0) +
+                ",HStopflag=" + Convert.ToString(list[0].HStopflag ? 1 : 0) +
+                ",HRemark='" + list[0].HRemark + "'" +
+                ",HHelpCode='" + list[0].HHelpCode + "'" +
+                ",HUseFlag='" + list[0].HUseFlag + "'" +
+                ",HMakeTime='" + list[0].HMakeTime + "'" +
+                ",HMakeEmp='" + HMakeEmp + "'" +
+                ",HCheckEmp='" + list[0].HCheckEmp + "'" +
+                ",HCheckTime='" + list[0].HCheckTime + "'" +
+                ",HModifyEmp='" + list[0].HModifyEmp + "'" +
+                ",HModifyTime='" + list[0].HModifyTime + "'" +
+                ",HStopEmp='" + list[0].HStopEmp + "'" +
+                ",HStopTime='" + list[0].HStopTime + "'" +
+                ",HUSEORGID=" + list[0].HUSEORGID +
+                ",HCREATEORGID=" + list[0].HCREATEORGID +
+                ",HInterID=" + list[0].HInterID +
+                ",HSampleTimes='" + list[0].HSampleTimes + "'" +
+                ",HSampleType='" + list[0].HSampleType + "'" +
+                ",HSampleLevel='" + list[0].HSampleLevel + "'" +
+                ",HStrictLevel='" + list[0].HStrictLevel +"'"+
+                ",HAQL=" + list[0].HAQL +
+                ",HEffectDate='" + list[0].HEffectDate + "'" +
+                ",HExpireDate='" + list[0].HExpireDate + "'" +
+                ",HIsSystemSet=" + Convert.ToString(list[0].HIsSystemSet ? 1 : 0) +
+                ",HERPItemID=" + 0 +
+                ",HNumber='" + list[0].HNumber + "'" +
+                " Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
+                    //淇敼瀛愰」鐩唬鐮�
+                    //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_Warehouse,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
+                    //灏嗕笂绾� 涓洪潪鏈骇
+                    oCN.RunProc("Update Gy_SampleScheme set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
+
+                    oCN.RunProcReturn("delete from Gy_SampleSchemeSub where HInterID = " + HItemID, "Gy_SampleSchemeSub");
+
+                    string sql3 = "";
+
+                    // 鏀逛负for寰幆锛孒EntryID浠�1寮�濮嬮�掑
+                    for (int i = 0; i < list1.Count; i++)
+                    {
+                        // 鑾峰彇褰撳墠寰幆鐨勫疄浣撳璞�
+                        ClsGy_SampleSchemeSub_Model listOne = list1[i];
+                        int entryID = i + 1;
+
+                        sql3 = $@"INSERT INTO [Gy_SampleSchemeSub] ([HInterID], [HEntryID], [HBatch], [HSampleCode], [HSampleRate], [HExpression], [HRejectQty], [HAcceptQty], [HSampleQty], [HSampleLow], [HSampleUp]) VALUES(
+                        '{HItemID}', '{entryID}',  '{listOne.HBatch}',  '{listOne.HSampleCode}',  '{listOne.HSampleRate}',  '{listOne.HExpression}',  '{listOne.HRejectQty}',  '{listOne.HAcceptQty}',  '{listOne.HSampleQty}',  '{listOne.HSampleLow}',  '{listOne.HSampleUp}'
+                        ); ";
+                        oCN.RunProc(sql3);
+                    }
+
+
+                    //淇濆瓨鍚庢帶鍒�=========================================      
+                    string sql2 = "exec h_p_Gy_SampleScheme_AfterSaveCtrl " + HMakeEmp + ",'" + 2 + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_SampleScheme_AfterSaveCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜锛氫繚瀛樺悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================   
+
+                    oCN.Commit();
+                }
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                //oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+        /// <summary>
+        /// 淇敼鎸夐挳鏂规硶
+        /// </summary>
+        [Route("Gy_SampleScheme/xg")]
+        [HttpGet]
+        public object xg(long HInterID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("select * from Gy_SampleScheme where HItemID=" + HInterID, "Gy_SampleScheme");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "";
+                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;
+            }
+        }
+
+
+        /// <summary>
+        /// 鏌ヨ瀛愯〃鏂规硶
+        /// </summary>
+        [Route("Gy_SampleScheme/listSub")]
+        [HttpGet]
+        public object listSub(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_SampleScheme_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ds = oCN.RunProcReturn("select * from Gy_SampleSchemeSub where 1 = 1 " + sWhere  , "Gy_SampleSchemeSub");
+
+                //娣诲姞鍒楀悕
+                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;
+            }
+
+
+        }
+
+
+        /// <summary>
+        /// 鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("Gy_SampleScheme/deletesam")]
+        [HttpGet]
+        public object deletesam(string HItemID, string user)
+        {
+            DataSet ds;
+            DataSet ds1;
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_SampleScheme_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (string.IsNullOrWhiteSpace(HItemID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HItemID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+                ds = oCN.RunProcReturn("select * from Gy_SampleScheme where HItemID=" + HItemID, "Gy_SampleScheme");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                else if (ds.Tables[0].Rows[0]["HCheckEmp"] != null && ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "宸茬粡瀹℃牳涓嶈兘鍒犻櫎锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                ds1 = oCN.RunProcReturn("Select HItemID from  Gy_SampleScheme  Where HParentID='" + HItemID + "'", " Gy_SampleScheme");
+                if (ds1.Tables[0].Rows.Count != 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ら」鐩瓨鍦ㄥ瓙椤圭洰锛屼笉鑳藉垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string HUseFlag = Convert.ToString(ds.Tables[0].Rows[0]["HUseFlag"]);
+                if (HUseFlag == "宸蹭娇鐢�")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ら」鐩凡浣跨敤锛屼笉鑳藉垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_SampleScheme_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_SampleScheme_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+
+                oCN.RunProc("delete from Gy_SampleScheme  where HItemID=" + HItemID);
+                oCN.RunProc("delete from Gy_SampleSchemeSub  where HInterID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_SampleScheme_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_SampleScheme_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    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;
+            }
+        }
+
+
+        #region 瀹℃牳銆佸弽瀹℃牳
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_SampleScheme/AuditGy_SampleScheme")]
+        [HttpGet]
+        public object AuditGy_SampleScheme(int HInterID, int IsAudit, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_SampleScheme_Check", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_SampleScheme where HItemID=" + HInterID, "Gy_SampleScheme");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                {
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_SampleScheme_BeforeCheckCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_SampleScheme_BeforeCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+
+                    oCN.RunProc("update Gy_SampleScheme set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID);
+
+
+                    //瀹℃牳鍚庢帶鍒�=========================================      
+                    string sql2 = "exec h_p_Gy_SampleScheme_AfterCheckCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_SampleScheme_AfterCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                {
+
+                    //鍙嶅鏍稿墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_Gy_SampleScheme_BeforeUnCheckCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_SampleScheme_BeforeUnCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+
+
+                    oCN.RunProc("update Gy_SampleScheme set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID);
+
+
+                    //鍙嶅鏍稿悗鎺у埗=========================================      
+                    string sql2 = "exec h_p_Gy_SampleScheme_AfterUnCheckCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_SampleScheme_AfterUnCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                    objJsonResult.data = null;
+                }
+                oCN.Commit();
+
+                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

--
Gitblit v1.9.1