From d1b14d00d9ee4ff4a1b271e6b4fe094f5049a55f Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 17 三月 2025 09:23:16 +0800
Subject: [PATCH] 采购入库单:下推采购退料单

---
 WebAPI/Controllers/BaseSet/Gy_GroupController.cs |  580 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 561 insertions(+), 19 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_GroupController.cs b/WebAPI/Controllers/BaseSet/Gy_GroupController.cs
index 26c7b7f..621dab5 100644
--- a/WebAPI/Controllers/BaseSet/Gy_GroupController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_GroupController.cs
@@ -1,11 +1,17 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
+using SyntacticSugar.constant;
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Data;
 using System.Data.SqlClient;
+using System.IO;
+using System.Threading.Tasks;
+using System.Web;
 using System.Web.Http;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
 using WebAPI.Models;
 namespace WebAPI.Controllers
 {
@@ -30,7 +36,8 @@
         {
             try
             {
-                //鏌ョ湅鏉冮檺
+                List<object> columnNameList = new List<object>();
+                ////鏌ョ湅鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log("Gy_Group_Query", 1, false, user))
                 {
                     objJsonResult.code = "0";
@@ -39,6 +46,10 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+                //鏍规嵁鐢ㄦ埛瀵瑰簲鐝粍鐨勫叧绯伙紝杩囨护鏉′欢涓鍔犲彧鏄剧ず瀵瑰簲鐨勭彮缁�
+                DataSet dsHitemID = oCN.RunProcReturn("exec h_p_Gy_GetSQLGroupByUser '" + user + "'", "h_p_Gy_GetSQLGroupByUser");
+                sWhere = sWhere + DBUtility.ClsPub.isStrNull(dsHitemID.Tables[0].Rows[0]["HBack"]);
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
@@ -50,22 +61,33 @@
                     string sql = sql1 + sWhere+ " order by 鐝粍浠g爜 ";
                     ds = oCN.RunProcReturn(sql, "h_v_GroupList");
                 }
-                if (ds == null || ds.Tables[0].Rows.Count == 0)
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "false锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "Sucess锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+
+
+                //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
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception e)
             {
@@ -285,6 +307,9 @@
                 var HBarCodeForBase = list[0].HBarCodeForBase;
                 var HDeptID = list[0].HDeptID;
                 long HProcID = list[0].HProcID;
+                int HUSEORGID = list[0].HUSEORGID;
+                string HCompName = list[0].HCompName;
+                string HPayMentType = list[0].HPayMentType;
                 var HDeptNumber = "";
                 //var HEndFlag = 0;
                 long HLevel = 1;
@@ -325,10 +350,10 @@
                     oCN.RunProc("Insert into Gy_Group " +
                     " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                     ",HEmpQty,HDeptID,HDeptNumber,HProcID" +
-                    ",HLevel,HEndFlag,HStopflag,HRemark,HBarCodeForBase) " +
+                    ",HLevel,HEndFlag,HStopflag,HRemark,HBarCodeForBase,HUSEORGID,HCompName,HPayMentType,HMakeEmp,HMakeTime) " +
                     " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID.ToString() +
                     "," + HEmpQty.ToString() + "," + HDeptID.ToString() + ",'" + HDeptNumber + "'," + HProcID.ToString() +
-                    "," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "','" + HBarCodeForBase + "')", ref DBUtility.ClsPub.sExeReturnInfo);
+                    "," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "','" + HBarCodeForBase + "',"+ HUSEORGID + ",'" + HCompName +"','"+ HPayMentType + "','" + user + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo);
                     //淇敼涓婄骇涓洪潪鏈骇浠g爜
                     oCN.RunProc("Update Gy_Group set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                     oCN.Commit();
@@ -345,9 +370,13 @@
                                  ",HParentID=" + HParentID +
                                  ",HStopflag='" + HStopflag + "'" +
                                  ",HRemark= '" + HRemark + "'" +
+                                 ",HModifyEmp= '" + user + "'" +
+                                 ",HModifyTime= getdate()" +
                                  ",HDeptID=" + HDeptID +
                                  ",HEmpQty=" + HEmpQty +
-                                 ",HBarCodeForBase='" + HBarCodeForBase + "' " +
+                                 ",HCompName='"+ HCompName+"'"+
+                                 ",HPayMentType='" + HPayMentType +
+                                 "',HBarCodeForBase='" + HBarCodeForBase + "' " +
                                  ", HProcID = '" + HProcID + "'  Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                     oCN.RunProc("Update Gy_Group set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                     oCN.Commit();
@@ -505,6 +534,14 @@
                     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; ;
+                }
                 //var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
                 //if (HStopflag)
                 //{
@@ -553,6 +590,511 @@
                 return objJsonResult;
             }
         }
+
+        #region 鐢熶骇鐝粍瀹℃牳銆佸弽瀹℃牳
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_Group/AuditGy_Group")]
+        [HttpGet]
+        public object AuditGy_Group(int HInterID, int IsAudit, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Group_Check", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_Group where HItemID=" + HInterID, "Gy_Group");
+                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)  //瀹℃牳鍒ゆ柇
+                {
+                    oCN.RunProc("update Gy_Group set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                {
+                    oCN.RunProc("update Gy_Group set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID);
+
+                    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
+
+        #region 鐢熶骇鐝粍绂佺敤銆佸弽绂佺敤
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsStop">绂佺敤(0),鍙嶇鐢�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_Group/StopGy_Group")]
+        [HttpGet]
+        public object StopGy_Group(int HInterID, int IsStop, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Group_Stop", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_Group where HItemID=" + HInterID, "Gy_Group");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsStop == 0)  //绂佺敤鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸茬鐢�!涓嶈兘鍐嶆绂佺敤锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].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 (IsStop == 0)  //绂佺敤鍒ゆ柇
+                {
+                    oCN.RunProc("update Gy_Group set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "绂佺敤鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                {
+                    oCN.RunProc("update Gy_Group set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID);
+
+                    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
+
+        #region 鐢熶骇鐝粍 鏂囦欢涓婁紶
+        [Route("Gy_Group/Gy_Process_Excel")]
+        [HttpPost]
+        public json Gy_Process_Excel()
+        {
+            json res = new json();
+            try
+            {
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable provisional = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    provisional.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                provisional.Columns.Add("HOrgID", typeof(Int32));//缁勭粐ID
+                provisional.Columns.Add("HDeptID", typeof(Int32));//閮ㄩ棬ID
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = provisional.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    provisional.Rows.Add(row);
+                }
+
+                //鍒ゆ柇鍒�
+                string error = JudgmentColumns(provisional);
+                if (error.Length > 0)
+                {
+                    res.code = "0";
+                    res.count = 0;
+                    res.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    res.data = null;
+                    return res;
+                }
+
+                for (int i = 0; i <= provisional.Rows.Count - 1; i++)
+                {
+                    string HNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鐝粍浠g爜"].ToString());
+                    string HUSEORGID = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["缁勭粐浠g爜"].ToString());
+                    string HName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鐝粍"].ToString());
+                    string HORGName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["缁勭粐鍚嶇О"].ToString());
+                    string HDeptID = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["閮ㄩ棬浠g爜"].ToString());
+                    string HDeptNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鎵�灞為儴闂�"].ToString());
+                    string HEmpQty = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鐝粍鎬讳汉鏁�"].ToString());
+                    string HHelpCode = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鍔╄鐮�"]);
+                    string HCompName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鍔冲姟鍗曚綅"]).ToString();
+                    string HProcID = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["宸ュ簭"].ToString());
+                    string HProcName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["宸ュ簭鍚嶇О"].ToString());
+                    string HBarCode = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鏉″舰鐮�"].ToString());
+                    string HRemark = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["澶囨敞"].ToString());
+
+                    //鑾峰彇鐪熷疄琛屾暟
+                    int line = i + 1;
+
+                    if (HUSEORGID != "")
+                    {
+                        //鏌ヨ缁勭粐
+                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HUSEORGID + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            res.code = "0";
+                            res.count = 0;
+                            res.Message = "绗�" + line + "琛�,缁勭粐涓嶅瓨鍦紒";
+                            res.data = null;
+                            return res;
+                        }
+                        else
+                        {
+                            provisional.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
+
+                        if(String.IsNullOrEmpty(HProcID) || String.IsNullOrEmpty(HProcName))
+                        {
+                            res.code = "0";
+                            res.count = 0;
+                            res.Message = "绗�" + line + "琛�,宸ュ簭鍚嶇О涓嶈兘涓虹┖锛�";
+                            res.data = null;
+                            return res;
+                        }
+
+                        //閮ㄩ棬鏌ヨ
+                        //鏌ヨ閮ㄩ棬
+                        ds = oCN.RunProcReturn("select * from Gy_Department where  HNumber='" + HDeptID + "'  and HUSEORGID=" + HORGid + "", "Gy_Department");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            res.code = "0";
+                            res.count = 0;
+                            res.Message = "绗�" + line + "琛�,璇�" + HORGName + "缁勭粐,閮ㄩ棬:" + HDeptNumber + ",涓嶅瓨鍦紒";
+                            res.data = null;
+                        }
+                        else
+                        {
+                            provisional.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+
+                        //宸ュ簭鏌ヨ
+                        //鏌ヨ宸ュ簭鏄惁瀛樺湪
+                        ds = oCN.RunProcReturn("select * from Gy_Process where HNumber ='" + HProcID + "' and HUSEORGID=" + HORGid + "", "Gy_Process");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            res.code = "0";
+                            res.count = 0;
+                            res.Message = "绗�" + line + "琛�,璇�" + HORGName + "缁勭粐,宸ュ簭:" + HProcName + ",涓嶅瓨鍦紒";
+                            res.data = null;
+                        }
+                        else
+                        {
+                            provisional.Rows[i]["HProcID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+
+                    }
+                    else
+                    {
+                        res.code = CodeConstant.FAIL;
+                        res.count = CountConstant.FAIL;
+                        res.Message = "绗�" + line + "琛�,缁勭粐浠g爜涓虹┖";
+                        res.data = null;
+                        return res;
+                    }
+                }
+
+                res.code = "1";
+                res.count = 1;
+                res.Message = error;
+                res.data = provisional;
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = "0";
+                res.count = 0;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
+            }
+        }
+
+        /// <summary>
+        /// 鍒ゆ柇鍒�
+        /// </summary>
+        /// <param name="provisional"></param>
+        /// <returns></returns>
+        private static string JudgmentColumns(DataTable provisional)
+        {
+            var error = "";
+
+            //鏌ヨ宸ヨ壓璺嚎娌℃湁鐨勫垪
+            if (!provisional.Columns.Contains("缁勭粐浠g爜"))
+                error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("鐝粍浠g爜"))
+                error += "娌℃湁鎵惧埌銆愮彮缁勪唬鐮併�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("鐝粍"))
+                error += "娌℃湁鎵惧埌銆愮彮缁勩�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("閮ㄩ棬浠g爜"))
+                error += "娌℃湁鎵惧埌銆愰儴闂ㄤ唬鐮併�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("鎵�灞為儴闂�"))
+                error += "娌℃湁鎵惧埌銆愭墍灞為儴闂ㄣ�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("鐝粍鎬讳汉鏁�"))
+                error += "娌℃湁鎵惧埌銆愮彮缁勬�讳汉鏁般�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("宸ュ簭"))
+                error += "娌℃湁鎵惧埌銆愬伐搴忋�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("宸ュ簭"))
+                error += "娌℃湁鎵惧埌銆愬伐搴忋�戠殑鏍囬,";
+            
+            if (!provisional.Columns.Contains("鍔冲姟鍗曚綅"))
+                error += "娌℃湁鎵惧埌銆愬姵鍔″崟浣嶃�戠殑鏍囬,";
+            return error;
+        }
+        #endregion
+
+        #region 宸ュ簭椤圭洰 瀵煎叆(淇濆瓨)
+        [Route("Gy_Group/Gy_Process_btnSave")]
+        [HttpPost]
+        public object Gy_Group_btnSave([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Gy_Group_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                oCN.BeginTran();
+                int i = 1;
+                foreach (Dictionary<string, string> item in list)
+                {
+                    string HNumber = item["鐝粍浠g爜"].ToString();
+                    string HUSEORGID = item["缁勭粐浠g爜"].ToString();
+                    string HName = item["鐝粍"].ToString();
+                    string HORGName = item["缁勭粐鍚嶇О"].ToString();
+                    string HDeptID = item["閮ㄩ棬浠g爜"].ToString();
+                    string HDeptNumber = item["鎵�灞為儴闂�"].ToString();
+                    string HEmpQty = item["鐝粍鎬讳汉鏁�"].ToString();
+                    string HHelpCode = item["鍔╄鐮�"];
+                    string HCompName = item["鍔冲姟鍗曚綅"].ToString();
+                    string HProcID = item["宸ュ簭"].ToString();
+                    string HProcName = item["宸ュ簭鍚嶇О"].ToString();
+                    string HRemark = item["澶囨敞"].ToString();
+                    string HBarCodeForBase = item["鏉″舰鐮�"].ToString();
+                    
+                    string sShortNumber;
+                    sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮�
+                    if (sShortNumber.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    int HEndFlag = 1;//鏈骇鏍囧織
+                    int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //绛夌骇
+
+
+                    if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+
+                    ds = oCN.RunProcReturn("select * from Gy_Group where HNumber='" + HNumber + "'", "Gy_Group");
+
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+
+                        string sql = "insert into Gy_Group(HName,HNumber,HDeptID,HUSEORGID,HCREATEORGID,HEmpQty,HShortNumber,HBarCodeForBase,HCompName,HProcID,HLevel,HHelpCode,HParentID,HStopflag,HRemark)" +
+                            $"values('{HName}', '{HNumber}',{HDeptID}, {HUSEORGID}, {HUSEORGID}, {HEmpQty}, '{sShortNumber}','{HBarCodeForBase}','{HCompName}',{HProcID},{HLevel},'',0,0,'{HRemark}')";
+                        oCN.RunProc(sql);
+                    }
+                    else
+                    {
+                        oCN.RunProc("update  Gy_Group set HBarCodeForBase='" + HBarCodeForBase + "',HDeptID=" + HDeptID + ",HName='" + HName + "', HHelpCode='" + HHelpCode + "'  where HNumber='" + HNumber + "'");
+                    }
+
+                    i++;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "瀵煎叆鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         /// <summary>
         /// 缁翠慨鍒楄〃淇敼鎸夐挳鏂规硶
         ///鍙傛暟锛歴tring sql銆�

--
Gitblit v1.9.1