From 1739eb7838984e9a55fbbb5d4705f55908749375 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期五, 01 九月 2023 09:00:06 +0800
Subject: [PATCH] 器具主档:增加制造厂商字段HMadeSupID,计算 保养/校正日期

---
 WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs |  128 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 114 insertions(+), 14 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs b/WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs
index c3041de..f2747a8 100644
--- a/WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs
+++ b/WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -29,6 +30,7 @@
         {
             try
             {
+                List<object> columnNameList = new List<object>();
                 //缂栬緫鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log_second("Gy_WorkCenter_Query", 1, false, user))
                 {
@@ -49,10 +51,19 @@
                     ds = oCN.RunProcReturn(sql, "h_v_IF_ORGANIZATIONSList");
                 }
 
+                //娣诲姞鍒楀悕
+                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)
@@ -64,6 +75,48 @@
                 return objJsonResult;
             }
         }
+
+        /// <summary>
+        /// 鏍规嵁鍩虹璧勬枡ID 鏌ユ壘璁板綍
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_ORGANIZATIONS/cx")]
+        [HttpGet]
+        public object cx(long HInterID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select * from h_v_IF_ORGANIZATIONSList where HitemID=" + HInterID, "h_v_IF_ORGANIZATIONSList");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "false锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    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;
+            }
+        }
+
+
         /// <summary>
         /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
         ///鍙傛暟锛歴tring sql銆�
@@ -150,6 +203,8 @@
                 string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                 string msg2 = sArray[0].ToString();
                 string msg3 = sArray[1].ToString();
+                string AddOrEdit = sArray[2].ToString(); //1鏂板3缂栬緫
+                //int ItemID = Convert.ToInt32(sArray[2]);
                 //string msg4 = sArray[2].ToString();
                 //string msg5 = sArray[3].ToString();
                 //鍙嶅簭鍒楀寲
@@ -164,7 +219,12 @@
 
                 string HRemark = list[0].HRemark;
                 bool HStopflag = list[0].HStopflag;
+                int ChangeHStopflag = 0;
 
+                if (HStopflag)
+                {
+                    ChangeHStopflag = 1;
+                }
                 //鍒ゆ柇鏉冮檺
                 if (!ClsPub.Security_Log("Gy_WorkCenter_Edit", 1, false, msg3))
                 {
@@ -194,31 +254,40 @@
                 //}
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
-                if (HItemID == 0)
+                if (AddOrEdit == "1")
                 {
                     oCN.BeginTran();
                     oCN.RunProc("Insert into Xt_ORGANIZATIONS " +
                     " (HNumber,HName,HParentID" +
-                   ",HStopflag,HMakeTime" +
+                   ",HStopflag,HMakeTime,HItemID" +
                    ",HRemark) " +
-                   " Values('" + HNumber + "','" + HName + "'," + HParentID.ToString() +
-                   "," + HStopflag + "getdate()" +
+                   " Values('" + HNumber + "','" + HName + "','" + HParentID.ToString() +
+                   "','" + ChangeHStopflag + "'," + "getdate()" + ",'" + HItemID + "'" +
                    ",'" + HRemark + "')", ref DBUtility.ClsPub.sExeReturnInfo);
 
                     //淇敼涓婄骇涓洪潪鏈骇浠g爜
-                    //oCN.RunProc("Update Xt_ORGANIZATIONS set HStopflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
+                    oCN.RunProc("Update Xt_ORGANIZATIONS set HStopflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                     oCN.Commit();
                 }
-                else
+                else if(AddOrEdit == "3")
                 {
+                    int Stopflag;
+                    if (HStopflag)
+                    {
+                        Stopflag = 1;
+                    }
+                    else
+                    {
+                        Stopflag = 0;
+                    }
                     //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
                     oCN.BeginTran();
                     oCN.RunProc("Update Xt_ORGANIZATIONS set " +
                                " HNumber='" + HNumber + "'" +
                                  ",HName='" + HName + "'" +
-                                  ",HParentID=" + HParentID +
-                                  ",HMakeTime=" + HMakeTime +
-                                 ",HStopflag='" + HStopflag + "'" +
+                                  ",HParentID='" + HParentID + "'" +
+                                  ",HMakeTime='" + HMakeTime + "'" +
+                                 ",HStopflag='" + Stopflag + "'" +
                                  ",HRemark= '" + HRemark + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                     oCN.RunProc("Update Xt_ORGANIZATIONS set HStopflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                     oCN.Commit();
@@ -232,7 +301,7 @@
             }
             catch (Exception e)
             {
-                oCN.RollBack();
+                //oCN.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "Exception锛�" + e.Message;
@@ -241,7 +310,38 @@
             }
         }
         /// <summary>
-        /// 鑱屽憳璁剧疆鍒犻櫎鍔熻兘
+        /// 鑾峰彇鏈�澶ItemID
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_ORGANIZATIONS/GetMaxHItemID")]
+        [HttpGet]
+        public object GetMaxHItemID()
+        {
+            try
+            {
+               
+                ds = oCN.RunProcReturn("select MAX(HItemID) from Xt_ORGANIZATIONS ", "Xt_ORGANIZATIONS");
+               
+
+              
+                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;
+            }
+        }
+        /// <summary>
+        /// 缁勭粐璁剧疆鍒犻櫎鍔熻兘
         /// </summary>
         /// <returns></returns>
         [Route("DeltetXt_ORGANIZATIONSList")]
@@ -273,7 +373,7 @@
                     return objJsonResult;
                 }
                 oCN.BeginTran();//寮�濮嬩簨鍔�
-                ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONSList where HItemID=" + HItemID, "Xt_ORGANIZATIONSList");
+                ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HItemID=" + HItemID, "Xt_ORGANIZATIONS");
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
@@ -293,7 +393,7 @@
                     return objJsonResult;
                 }
 
-                oCN.RunProc("update Xt_ORGANIZATIONSList set HStopflag=1 where HItemID=" + HItemID);
+                oCN.RunProc("delete from Xt_ORGANIZATIONS where HItemID=" + HItemID);
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;

--
Gitblit v1.9.1