From 19d0afadbe1c90e227b852db0a97ae413e90691f Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期日, 29 九月 2024 19:13:25 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/BaseSet/Gy_PropertyController.cs |  337 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 334 insertions(+), 3 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_PropertyController.cs b/WebAPI/Controllers/BaseSet/Gy_PropertyController.cs
index b6b2402..9da9f99 100644
--- a/WebAPI/Controllers/BaseSet/Gy_PropertyController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_PropertyController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -25,10 +26,11 @@
         /// </summary>
         [Route("Gy_Property/list")]
         [HttpGet]
-        public object list(string sWhere,string user)
+        public object list(string sWhere,string user, string Organization)
         {
             try
             {
+                List<object> columnNameList = new List<object>();
                 //缂栬緫鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log_second("Gy_Property", 1, false, user))
                 {
@@ -49,12 +51,21 @@
                     ds = oCN.RunProcReturn(sql, "h_v_IF_PropertyList");
                 }
 
+                //娣诲姞鍒楀悕
+                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鍒楀璞$殑鍒楀悕
+                }
+
                 //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                 //{
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "Sucess锛�";
                 objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
                 return objJsonResult;
                 //}
                 //else
@@ -76,8 +87,328 @@
             }
         }
 
+        #region  杈呭姪灞炴�� 缂栬緫
+        [Route("Gy_Property/PropertyEdit")]
+        [HttpPost]
+        public object PropertyEdit([FromBody] JObject msg)
+        {
+            DataSet ds;
+            var _value = msg["msg"].ToString();
+            string msg3 = _value.ToString();
+            string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg1 = sArray[0].ToString();
+            string msg2 = sArray[1].ToString();
+            //string msg_HUSEORGID = sArray[2].ToString();
+            Int64 HItemID = 0;
+            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+            //缂栬緫鏉冮檺
+            //if (!DBUtility.ClsPub.Security_Log_second("Gy_TaxRate_Edit", 1, false, msg2))
+            //{
+            //    objJsonResult.code = "0";
+            //    objJsonResult.count = 0;
+            //    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+            //    objJsonResult.data = null;
+            //    return objJsonResult;
+            //}
+
+            //鑾峰彇鏈�澶D鍊艰祴鍊�
+            //DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Gy_TaxRate ", "Gy_TaxRate");
+            //if (Maxds != null || Maxds.Tables[0].Rows.Count > 0)
+            //{
+            //    //HItemID= Maxds.Tables[0].Rows[0]["HItemID"]
+            //    var maxid = Convert.ToInt32((Maxds.Tables[0].Rows[0]["HItemID"].ToString()==""?0: Maxds.Tables[0].Rows[0]["HItemID"]));
+            //    maxid += 1;
+            //    HItemID = maxid;
+            //}
+            ListModels oListModels = new ListModels();
+
+            try
+            {
+                DAL.ClsGy_Property_Ctl oBill = new DAL.ClsGy_Property_Ctl();
+                List<Model.ClsGy_Property_Model> lsmain = new List<Model.ClsGy_Property_Model>();
+                msg1 = msg1.Replace("\\", "");
+                msg1 = msg1.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Gy_Property(msg1);
+                foreach (Model.ClsGy_Property_Model oItem in lsmain)
+                {
+                    if (oItem.HNumber.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷笉鑳戒负绌猴紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    if (oItem.HName.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佸悕绉颁笉鑳戒负绌猴紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+
+                    //鏌ヨ鏁版嵁涓槸鍚﹀瓨鍦ㄩ噸澶嶄唬鐮�
+                    ds = oCN.RunProcReturn("select * from  Gy_Property where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_Property");
+                    if (oItem.HItemID == 0)
+                    {
+                        if (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.Count > 0)
+                        {
+                            if (ds.Tables[0].Rows[0]["HItemID"].ToString() != oItem.HItemID.ToString())
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
+                    }
 
 
-        //
+                    //鏂板鏃跺垽鏂�
+                    #region 鐖剁骇鏍¢獙鏂规硶锛坅pi璋冪敤鍏堟敞閲婃帀锛岋級
+                    /*
+                    if (oItem.HItemID == 0)
+                    {
+                        if (ds == null || ds.Tables[0].Rows.Count > 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦�
+                        string sParent;
+                        sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
+                        if (sParent.Trim() == "")
+                        {
+                            oBill.oModel.HParentID = 0;
+                        }
+                        else
+                        {
+                            if (oBill.HavParentCode(sParent.Trim(), HItemID))
+                            {
+                                oBill.oModel.HParentID = oBill.oModel.HItemID;
+                            }
+                            else
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�";
+                                objJsonResult.data = 1;
+                                return objJsonResult;
+                            }
+                        }
+                    }
+                    else//缂栬緫鏃跺垽鏂�
+                    {
+                        //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦�
+                        string sParent;
+                        sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
+                        if (sParent.Trim() == "")
+                        {
+                            oBill.oModel.HParentID = 0;
+                        }
+                        else
+                        {
+                            if (oBill.HavParentCode(sParent.Trim(), oItem.HItemID))
+                            {
+                                oBill.oModel.HParentID = oBill.oModel.HItemID;
+                            }
+                            else
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�";
+                                objJsonResult.data = 1;
+                                return objJsonResult;
+                            }
+                        }
+                    }
+                    */
+                    #endregion
+                    //寰楀埌鐭唬鐮�
+                    string sShortNumber;
+                    sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim());
+                    if (sShortNumber.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    //oItem.HUSEORGID = Convert.ToInt32(msg_HUSEORGID); //缁勭粐id
+                    oItem.HShortNumber = sShortNumber;//鐭唬鐮�
+                    oItem.HEndFlag = true;//鏈骇鏍囧織
+                    oItem.HLevel = 1; //绛夌骇 DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim())
+                    oBill.oModel = oItem;
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.oModel.HItemID == 0)
+                {
+                    bResult = oBill.AddNew();
+                }
+                else
+                {
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region  杈呭姪灞炴�� 鍒犻櫎
+        [Route("Gy_Property/Delete")]
+        [HttpGet]
+        public object Delete(string HItemID, string user)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                //鍒犻櫎鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Gy_TaxRate_Drop", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄�";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+                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_Property where HItemID=" + HItemID, "Gy_Property");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
+                if (HStopflag)
+                {
+                    oCN.RollBack();//鍥炴粴浜嬪姟
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏁版嵁宸茬鐢ㄦ棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.RunProc("delete from Gy_Property where HItemID=" + HItemID);
+                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("Gy_Property/SaveGy_PropertyListApi")]
+        //[HttpPost]
+        //public object SaveGy_PropertyListApi([FromBody] JObject msg)
+        //{
+        //    try
+        //    {
+        //        var _value = msg["model"].ToString();
+        //        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        //        ListModels oListModels = new ListModels();
+        //        List<Model.ClsGy_Property_Model> lsmain = new List<Model.ClsGy_Property_Model>();
+        //        lsmain = oListModels.getObjectByJson_Gy_Property(_value);
+        //        string sql = string.Empty;
+        //        //淇濆瓨
+        //        oCN.BeginTran();
+        //        sql = $"delete Gy_Property where HItemID = {lsmain[0].HItemID}";
+        //        oCN.RunProc(sql);
+        //        sql = "set identity_insert Gy_Property on";
+        //        oCN.RunProc(sql);
+
+        //        oCN.RunProc($@"insert into Gy_Property(HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID
+        //            ,HLevel,HEndFlag,HStopflag,HRemark,HPropertyTypeID,HUseFlag,HERPItemID,HMakeTime)
+        //          values({lsmain[0].HItemID},'{lsmain[0].HNumber}','{lsmain[0].HName}','{lsmain[0].HHelpCode}','{lsmain[0].HShortNumber}',{lsmain[0].HParentID},{lsmain[0].HLevel}
+        //   ,{Convert.ToString(lsmain[0].HEndFlag ? 1 : 0)},{Convert.ToString(lsmain[0].HStopflag ? 1 : 0) },'{lsmain[0].HRemark}',{lsmain[0].HPropertyTypeID},'{lsmain[0].HUseFlag}',{lsmain[0].HERPItemID},'{lsmain[0].HMakeTime}')", ref DBUtility.ClsPub.sExeReturnInfo);
+        //        //淇敼涓婄骇涓洪潪鏈骇浠g爜
+        //        sql = "set identity_insert Gy_Property off";
+        //        oCN.RunProc(sql);
+        //        oCN.Commit();
+
+        //        objJsonResult.code = "1";
+        //        objJsonResult.count = 1;
+        //        objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+        //        objJsonResult.data = 1;
+        //        return objJsonResult;
+        //    }
+        //    catch (Exception e)
+        //    {
+        //        objJsonResult.code = "0";
+        //        objJsonResult.count = 0;
+        //        objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+        //        objJsonResult.data = 1;
+        //        return objJsonResult;
+        //    }
+        //}
+        //#endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1