From a1c3a3d1b0b0b8c28a19e99177e4cee5a64949b7 Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期二, 25 二月 2025 11:20:17 +0800
Subject: [PATCH] 增加斯莫尔  性能检测散点图报表

---
 WebAPI/Controllers/BaseSet/Gy_SupplierController.cs |  612 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 597 insertions(+), 15 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs
index 348db1d..240b2f4 100644
--- a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs
@@ -8,6 +8,12 @@
 using System.Data.SqlClient;
 using System.Web.Http;
 using WebAPI.Models;
+using System.Text.RegularExpressions;
+using SyntacticSugar.constant;
+using System.Web;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.IO;
+using SyntacticSugar.constant;
 namespace WebAPI.Controllers
 {
     public class Gy_SupplierController : ApiController
@@ -78,7 +84,61 @@
             }
         }
 
+        #region 渚涘簲鍟嗗垎椤靛垪琛�
+        [Route("Gy_Supplier/page")]
+        [HttpGet]
+        public json Gy_SupplierPage(string sWhere, string user, int page, int size, string Organization)
+        {
+            DataSet ds;
+            json res = new json();
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere += ("and 缁勭粐鍚嶇О = '" + Organization + "'");
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Gy_SupplierList " + page + "," + size + ",''", "h_p_Gy_SupplierList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Gy_SupplierList " + page + "," + size + ",'" + sWhere + "'", "h_p_Gy_SupplierList");
+                }
 
+                //娣诲姞鍒楀悕
+                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鍒楀璞$殑鍒楀悕
+                }
+
+                res.code = CodeConstant.SUCCEED;
+                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                res.Message = "Sucess锛�";
+                res.list = columnNameList;
+                res.data = ds.Tables[0];
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = CodeConstant.FAIL;
+                res.count = CountConstant.FAIL;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
+            }
+        }
+        #endregion
 
 
         /// <summary>
@@ -110,6 +170,83 @@
             }
         }
 
+        #region 瀹㈡埛鏍规嵁鍒嗙被鑾峰彇鏈�澶у鎴风紪鐮�
+        [Route("Gy_Supplier/getMaxNum")]
+        [HttpGet]
+        public object getMaxNum(int HSupTypeID, string user, string Organization)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (HSupTypeID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁閫夋嫨鍏蜂綋鍒嗙被锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn(@"select * from h_v_Gy_SupplierList where 缁勭粐鍚嶇О='" + Organization + "'" + "and HSupTypeID = '" + HSupTypeID + "'" + " order by 渚涘簲鍟嗕唬鐮� desc", "h_v_Gy_SupplierList");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "娌℃湁鎵惧埌璇ュ垎绫荤殑瀹㈡埛缂栫爜璇蜂娇鐢ㄦ櫘閫氭柊澧�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    string HNumber = ds.Tables[0].Rows[0]["渚涘簲鍟嗕唬鐮�"].ToString();
+                    // 浣跨敤姝e垯琛ㄨ揪寮忔壘鍒版暟瀛楅儴鍒�  (?<=\D)鏄竴涓浂瀹芥柇瑷�锛岃〃绀哄墠闈㈢殑瀛楃涓嶆槸鏁板瓧 (\d+)$琛ㄧず鍚庨潰璺熺潃涓�杩炰覆瀛楃涓茬煡閬撴湯灏�
+                    Match match = Regex.Match(HNumber, @"(?<=\D)(\d+)$");
+                    if (match.Success)
+                    {
+                        string prefix = HNumber.Substring(0, HNumber.Length - match.Length); // 鎻愬彇鍓嶇紑  
+                        int number = int.Parse(match.Value); // 瑙f瀽鏁板瓧  
+                        // 鏁板瓧+1  
+                        number++;
+                        // 鏍煎紡鍖栨暟瀛楋紝淇濇寔鍘熼暱搴�  
+                        string formattedNumber = number.ToString().PadLeft(match.Length, '0');
+                        // 閲嶆柊缁勫悎瀛楃涓�  
+                        string result = prefix + formattedNumber;
+
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "success";
+                        objJsonResult.data = result;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "姝ゅ垎绫讳緵搴斿晢缂栫爜鏍煎紡鏈夎";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         /// <summary>
         /// 渚涘簲鍟嗗垪琛ㄤ慨鏀规寜閽柟娉�
         ///鍙傛暟锛歴tring sql銆�
@@ -121,19 +258,8 @@
         {
             try
             {
-                string sql = string.Format(@"select  s.HItemID,s.HUSEORGID,o.Hname 浣跨敤缁勭粐,s.HCREATEORGID ,d.Hname 鍒涘缓缁勭粐,s.HNumber 缂栫爜,s.HName 鍚嶇О,s.HHelpCode  鍔╄鐮�,s.HShortName 绠�绉�,s.HAddress 鍦板潃,s.HLinkMan 鑱旂郴浜�,s.HLinkPhone 鑱旂郴鐢佃瘽
-                                            ,s.HMobilePhone 鎵嬫満,s.HFax 浼犵湡,s.HPostalCode 閭紪,s.HEmail 鐢靛瓙閭欢,s.HCorMan 娉曚汉浠h〃,s.HBank 寮�鎴烽摱琛�,s.HBankAccount 閾惰璐﹀彿,s.HPSStyleID 閲囪喘鏂瑰紡ID,f.HName 閲囪喘鏂瑰紡鍚嶇О,
-                                           s.HTaxNum 绋庡姟鐧昏鍙�,s.HEnglishName 鑻辨枃鍚嶇О,s.HEngLishAddress 鑻辨枃鍦板潃,s.HCountry 鍥藉,s.HStopflag 绂佺敤鏍囧織
-                                           ,s.HRemark 澶囨敞,s.HAreaID 鍦板尯ID,a.HName 鍦板尯鍚嶇О,s.HTaxRate 澧炲�肩◣鐜�,s.HCurID 榛樿璐у竵ID,r.HName 榛樿璐у竵,
-                                           s.HSSID 缁撶畻鏂瑰紡ID,e.HName 缁撶畻鏂瑰紡,s.HMaterClass 渚涜揣鏉愭枡绫诲埆  from Gy_Supplier s
-                                           left join Gy_AreaSet a on s.HAreaID=a.HItemID
-                                           left join Gy_Currency r on s.HCurID=r.HItemID 
-                                           left  join Gy_SettleStyle e on s.HSSID=e.HItemID
-                                           left join Xt_ORGANIZATIONS o on s.HUSEORGID=o.HItemID
-										   left join Xt_ORGANIZATIONS d on s.HCREATEORGID=d.HItemID
-										   left join Gy_PoStockStyle f on s.HPSStyleID=f.HItemID
-                                           where s.HItemID='" + HInterID + "'");
-                ds = oCN.RunProcReturn(sql, "Gy_Supplier");
+                string sql = string.Format(@"select  * from h_v_Gy_SupplierEdit where HItemID='" + HInterID + "'");
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_SupplierEdit");
                 DataSet cs = oCN.RunProcReturn("select * from Gy_Supplier_PayPlan where HSupID = '"+ HInterID + "'", "Gy_Supplier_PayPlan");
                 List<Object> list = new List<object>();
                 list.Add(cs);
@@ -215,6 +341,7 @@
                 string HRemark = list[0].HRemark;
                 string HMaterClass = list[0].HMaterClass;
                 long HPSStyleID = list[0].HPSStyleID;
+                long HSupTypeID = list[0].HSupTypeID;
 
                 if (!DBUtility.ClsPub.AllowNumber(HNumber))
                 {
@@ -233,13 +360,13 @@
                     ",HShortName,HAddress,HLinkMan,HLinkPhone,HMobilePhone" +
                     ",HFax,HPostalCode,HEmail,HBank,HBankAccount" +
                     ",HTaxNum,HTaxRate,HCountry,HCorMan,HEnglishName" +
-                    ",HEnglishAddress,HCurID,HSSID,HAreaID,HMaterClass,HUSEORGID,HCREATEORGID,HPSStyleID) " +
+                    ",HEnglishAddress,HCurID,HSSID,HAreaID,HMaterClass,HUSEORGID,HCREATEORGID,HPSStyleID,HSupTypeID) " +
                 " values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "','" + HParentID + "'" +
                 "," + HLevel + ",1,'" + HStopflag + "','" + HRemark + "'" +
                 ",'" + HShortName + "','" + HAddress + "','" + HLinkMan + "','" + HLinkPhone + "','" + HMobilePhone + "'" +
                 ",'" + HFax + "','" + HPostalCode + "','" + HEmail + "','" + HBank + "','" + HBankAccount + "'" +
                 ",'" + HTaxNum + "','" + HTaxRate + "','" + HCountry + "','" + HCorMan + "','" + HEnglishName + "'" +
-                ",'" + HEnglishAddress + "'," + HCurID + "," + HSSID + "," + HAreaID +" ,'" + HMaterClass + " ','" + HUseOrgID + "' ,'" + HCreateOrgID + "' ,'" + HPSStyleID +
+                ",'" + HEnglishAddress + "'," + HCurID + "," + HSSID + "," + HAreaID +" ,'" + HMaterClass + " ','" + HUseOrgID + "' ,'" + HCreateOrgID + "' ,'" + HPSStyleID+ "' ,'" + HSupTypeID +
               "') ");
                 //淇敼涓婄骇涓洪潪鏈骇浠g爜
                 oCN.RunProc("Update Gy_Supplier set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
@@ -336,6 +463,7 @@
         ///鍙傛暟锛歴tring sql銆�
         ///杩斿洖鍊硷細object銆�
         /// </summary>
+        
         [Route("Gy_Supplier/AddBill1")]
         [HttpPost]
         public object AddBill1([FromBody] JObject oMain)
@@ -394,6 +522,7 @@
                 string HRemark = list[0].HRemark;
                 string HMaterClass = list[0].HMaterClass;
                 long HPSStyleID = list[0].HPSStyleID;
+                long HSupTypeID = list[0].HSupTypeID;
 
                 //鍒ゆ柇鏉冮檺
                 if (!ClsPub.Security_Log(msg6, 1, false, msg5))
@@ -447,6 +576,7 @@
                    ",HSSID=" + HSSID.ToString() +
                    ",HMaterClass='" + HMaterClass +
                    "',HPSStyleID='"+ HPSStyleID.ToString() +
+                   "',HSupTypeID='" + HSupTypeID.ToString() +
                    "',HUSEORGID='" + HUseOrgID.ToString() +
                    "',HCREATEORGID='" + HCreateOrgID.ToString() +
                    "',HAreaID=" + HAreaID.ToString() + "Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
@@ -1041,5 +1171,457 @@
         }
 
         #endregion
+
+        #region 渚涘簲鍟� 鏂囦欢瀵煎叆淇濆瓨
+        #region 渚涘簲鍟� 鏂囦欢涓婁紶
+        [Route("Gy_Supplier/Gy_Supplier_Excel")]
+        [HttpPost]
+        public object Gy_Supplier_Excel()
+        {
+            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 tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("HOrgID", typeof(Int32));//缁勭粐ID
+                tb2.Columns.Add("HCurID", typeof(Int32));//甯佸埆ID
+                tb2.Columns.Add("HSSID", typeof(Int32));//缁撶畻鏂瑰紡ID
+                tb2.Columns.Add("HAreaID", typeof(Int32));//鍦板尯ID
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    tb2.Rows.Add(row);
+                }
+
+
+                var error = "";
+
+                //鏌ヨ娌℃湁鐨勫垪
+                if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("渚涘簲鍟嗕唬鐮�"))
+                    error += "娌℃湁鎵惧埌銆愪緵搴斿晢浠g爜銆戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("渚涘簲鍟嗗悕绉�"))
+                    error += "娌℃湁鎵惧埌銆愪緵搴斿晢銆戠殑鏍囬,";
+
+
+                if (!tb2.Columns.Contains("绠�绉�"))
+                    error += "娌℃湁鎵惧埌銆愮畝绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("甯佸埆浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愬竵鍒唬鐮併�戠殑鏍囬,";
+
+
+                if (!tb2.Columns.Contains("甯佸埆"))
+                    error += "娌℃湁鎵惧埌銆愬竵鍒�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("缁撶畻鏂瑰紡浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮粨绠楁柟寮忎唬鐮併�戠殑鏍囬,";
+
+
+                if (!tb2.Columns.Contains("缁撶畻鏂瑰紡"))
+                    error += "娌℃湁鎵惧埌銆愮粨绠楁柟寮忋�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鍦板尯浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愬湴鍖轰唬鐮併�戠殑鏍囬,";
+
+
+                if (!tb2.Columns.Contains("鎵�灞炲湴鍖�"))
+                    error += "娌℃湁鎵惧埌銆愭墍灞炲湴鍖恒�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鍦板潃"))
+                    error += "娌℃湁鎵惧埌銆愬湴鍧�銆戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鐢靛瓙閭"))
+                    error += "娌℃湁鎵惧埌銆愮數瀛愰偖绠便�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("閾惰"))
+                    error += "娌℃湁鎵惧埌銆愰摱琛屻�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("閾惰璐︽埛"))
+                    error += "娌℃湁鎵惧埌銆愰摱琛岃处鎴枫�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("绋庡姟鐧昏鍙�"))
+                    error += "娌℃湁鎵惧埌銆愮◣鍔$櫥璁板彿銆戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("閭紪"))
+                    error += "娌℃湁鎵惧埌銆愰偖缂栥�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鍥藉"))
+                    error += "娌℃湁鎵惧埌銆愬浗瀹躲�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("娉曚汉浠h〃"))
+                    error += "娌℃湁鎵惧埌銆愭硶浜轰唬琛ㄣ�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鑻辨枃鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愯嫳鏂囧悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鑻辨枃鍦板潃"))
+                    error += "娌℃湁鎵惧埌銆愯嫳鏂囧湴鍧�銆戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鍔╄鐮�"))
+                    error += "娌℃湁鎵惧埌銆愬姪璁扮爜銆戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("澶囨敞"))
+                    error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = CodeConstant.FAIL;
+                    objJsonResult.count = CountConstant.FAIL;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+                {
+                    string HName = "";
+                    string HNum = "";
+                    string HORGNumber = "";
+                    string HORGName = "";
+                    string HCurNumber = "";
+                    string HCurName = "";
+                    string HSSNumber = "";
+                    string HSSName = "";
+                    string HAreaNumber = "";
+                    string HAreaName = "";
+
+                    HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗗悕绉�"].ToString());
+                    HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString());
+                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+                    HCurNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["甯佸埆浠g爜"].ToString());
+                    HCurName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["甯佸埆"].ToString());
+                    HSSNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁撶畻鏂瑰紡浠g爜"].ToString());
+                    HSSName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁撶畻鏂瑰紡"].ToString());
+                    HAreaNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍦板尯浠g爜"].ToString());
+                    HAreaName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鎵�灞炲湴鍖�"].ToString());
+
+                    //妫�鏌ョ墿鏂�
+                    int index = i + 1;
+
+                    if (HORGNumber != "")
+                    {
+
+                        //鏌ヨ缁勭粐
+                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = CodeConstant.FAIL;
+                            objJsonResult.count = CountConstant.FAIL;
+                            objJsonResult.Message = "绗�" + index + "琛�,缁勭粐涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+
+                        if (HCurNumber != "")
+                        {
+                            //鏌ヨ甯佸埆
+                            ds = oCN.RunProcReturn("select * from Gy_Currency where  HNumber='" + HCurNumber + "' and Hname='" + HCurName + "'", "Gy_Currency");
+
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = CodeConstant.FAIL;
+                                objJsonResult.count = CountConstant.FAIL;
+                                objJsonResult.Message = "绗�" + index + "琛�,甯佸埆涓嶅瓨鍦紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                tb2.Rows[i]["HCurID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                            }
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HCurID"] = 0;
+                        }
+
+                        if (HSSNumber != "")
+                        {
+                            //鏌ヨ缁撶畻鏂瑰紡
+                            ds = oCN.RunProcReturn("select * from Gy_SettleStyle where  HNumber='" + HSSNumber + "' and Hname='" + HSSName + "'", "Gy_SettleStyle");
+
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = CodeConstant.FAIL;
+                                objJsonResult.count = CountConstant.FAIL;
+                                objJsonResult.Message = "绗�" + index + "琛�,甯佸埆涓嶅瓨鍦紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                tb2.Rows[i]["HSSID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                            }
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HSSID"] = 0;
+                        }
+                        if (HAreaNumber != "")
+                        {
+                            //鏌ヨ鍦板尯
+                            ds = oCN.RunProcReturn("select * from Gy_AreaSet where  HNumber='" + HAreaNumber + "' and Hname='" + HAreaName + "'", "Gy_AreaSet");
+
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = CodeConstant.FAIL;
+                                objJsonResult.count = CountConstant.FAIL;
+                                objJsonResult.Message = "绗�" + index + "琛�,鍦板尯涓嶅瓨鍦紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                tb2.Rows[i]["HAreaID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                            }
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HAreaID"] = 0;
+                        }
+
+                        //渚涘簲鍟嗗悕绉�
+                        if (HName == "")
+                        {
+                            objJsonResult.code = CodeConstant.FAIL;
+                            objJsonResult.count = CountConstant.FAIL;
+                            objJsonResult.Message = "绗�" + index + "琛�,渚涘簲鍟嗗悕绉颁笉鑳戒负绌猴紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //渚涘簲鍟嗕唬鐮�
+                        if (HNum == "")
+                        {
+                            objJsonResult.code = CodeConstant.FAIL;
+                            objJsonResult.count = CountConstant.FAIL;
+                            objJsonResult.Message = "绗�" + index + "琛�,渚涘簲鍟嗕唬鐮佷笉鑳戒负绌猴紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    else
+                    {
+                        objJsonResult.code = CodeConstant.FAIL;
+                        objJsonResult.count = CountConstant.FAIL;
+                        objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                objJsonResult.code = CodeConstant.SUCCEED;
+                objJsonResult.count = CountConstant.SUCCEED;
+                objJsonResult.Message = error;
+                objJsonResult.data = tb2;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = CodeConstant.FAIL;
+                objJsonResult.count = CountConstant.FAIL;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 渚涘簲鍟嗛」鐩� 瀵煎叆(淇濆瓨)
+        [Route("Gy_Supplier/Gy_Supplier_btnSave")]
+        [HttpPost]
+        public object Gy_Supplier_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_Supplier_Edit", 1, false, user))
+                {
+                    objJsonResult.code = CodeConstant.FAIL;
+                    objJsonResult.count = CountConstant.FAIL;
+                    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 HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+                    string HCurID = item["HCurID"].ToString();//甯佸埆ID
+                    string HSSID = item["HSSID"].ToString();//缁撶畻鏂瑰紡ID
+                    string HAreaID = item["HAreaID"].ToString();//鍦板尯ID
+                    string HName = item["渚涘簲鍟嗗悕绉�"].ToString();
+                    string HNumber = item["渚涘簲鍟嗕唬鐮�"].ToString();
+                    string HRemark = item["澶囨敞"].ToString();
+                    string HHelpCode = item["鍔╄鐮�"].ToString();
+                    string HShortNumber;
+                    HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮�
+                    if (HShortNumber.Trim() == "")
+                    {
+                        objJsonResult.code = CodeConstant.FAIL;
+                        objJsonResult.count = CountConstant.FAIL;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //绛夌骇
+                    int HParentID = 0;//鐖秈d
+                    int HStopflag = 0;//绂佺敤鏍囪
+                    string HShortName = item["绠�绉�"].ToString();
+                    string HAddress = item["鍦板潃"].ToString();
+                    string HLinkMan = "";//鑱旂郴浜�
+                    string HLinkPhone = "";//鑱旂郴鐢佃瘽
+                    string HMobilePhone = "";//鎵嬫満
+                    string HFax = "";//浼犵湡
+                    string HPostalCode = item["閭紪"].ToString();
+                    string HEmail = item["鐢靛瓙閭"].ToString();
+                    string HBank = item["閾惰"].ToString();
+                    string HBankAccount = item["閾惰璐︽埛"].ToString();
+                    string HTaxNum = item["绋庡姟鐧昏鍙�"].ToString();
+                    string HCountry = item["鍥藉"].ToString();
+                    string HCorMan = item["娉曚汉浠h〃"].ToString();
+                    string HEnglishName = item["鑻辨枃鍚嶇О"].ToString();
+                    string HEnglishAddress = item["鑻辨枃鍦板潃"].ToString();
+                    int HTaxRate = 13;//澧炲�肩◣鐜�
+                    if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
+                    {
+                        objJsonResult.code = CodeConstant.FAIL;
+                        objJsonResult.count = CountConstant.FAIL;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+
+                    ds = oCN.RunProcReturn("select * from Gy_Supplier where HNumber='" + HNumber + "'", "Gy_Supplier");
+
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        oCN.RunProc("Insert Into Gy_Supplier " +
+                        "(HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+                            ",HLevel,HEndFlag,HStopflag,HRemark" +
+                            ",HShortName,HAddress,HLinkMan,HLinkPhone,HMobilePhone" +
+                            ",HFax,HPostalCode,HEmail,HBank,HBankAccount" +
+                            ",HTaxNum,HTaxRate,HCountry,HCorMan,HEnglishName" +
+                            ",HEnglishAddress,HCurID,HSSID,HAreaID,HMaterClass,HUSEORGID,HCREATEORGID,HPSStyleID,HSupTypeID) " +
+                        " values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "','" + HParentID + "'" +
+                        "," + HLevel + ",1,'" + HStopflag + "','" + HRemark + "'" +
+                        ",'" + HShortName + "','" + HAddress + "','" + HLinkMan + "','" + HLinkPhone + "','" + HMobilePhone + "'" +
+                        ",'" + HFax + "','" + HPostalCode + "','" + HEmail + "','" + HBank + "','" + HBankAccount + "'" +
+                        ",'" + HTaxNum + "','" + HTaxRate + "','" + HCountry + "','" + HCorMan + "','" + HEnglishName + "'" +
+                        ",'" + HEnglishAddress + "'," + HCurID + "," + HSSID + "," + HAreaID + " ,'" + 0 + " ','" + HOrgID + "' ,'" + HOrgID + "' ,'" + 0 + "' ,'" + 0 +
+                      "') ");
+                    }
+                    else
+                    {
+                        //涓昏〃
+                        oCN.RunProc("Update Gy_Supplier set " +
+                           "HName='" + HName + "'" +
+                           ",HShortNumber='" + HShortNumber + "'" +
+                           ",HParentID=" + HParentID.ToString() +
+                           ",HLevel=" + HLevel.ToString() +
+                           ",HStopflag ='" + HStopflag + "'" +
+                           ",HRemark= '" + HRemark + "'" +
+                           ",HHelpCode='" + HHelpCode + "'" +
+                           ",HShortName='" + HShortName + "'" +
+                           ",HAddress='" + HAddress + "'" +
+                           ",HLinkMan='" + HLinkMan + "'" +
+                           ",HLinkPhone='" + HLinkPhone + "'" +
+                           ",HMobilePhone='" + HMobilePhone + "'" +
+                           ",HFax='" + HFax + "'" +
+                           ",HPostalCode='" + HPostalCode + "'" +
+                           ",HEmail='" + HEmail + "'" +
+                           ",HBank='" + HBank + "'" +
+                           ",HBankAccount='" + HBankAccount + "'" +
+                           ",HTaxNum='" + HTaxNum + "'" +
+                           ",HTaxRate=" + HTaxRate.ToString() +
+                           ",HCountry='" + HCountry + "'" +
+                           ",HCorMan='" + HCorMan + "'" +
+                           ",HEnglishName='" + HEnglishName + "'" +
+                           ",HEnglishAddress='" + HEnglishAddress + "'" +
+                           ",HCurID=" + HCurID.ToString() +
+                           ",HSSID=" + HSSID.ToString() +
+                           ",HAreaID=" + HAreaID.ToString() + "Where HNumber='" + HNumber + "'", ref DBUtility.ClsPub.sExeReturnInfo);
+                    }
+
+                    i++;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = CodeConstant.SUCCEED;
+                objJsonResult.count = CountConstant.SUCCEED;
+                objJsonResult.Message = "瀵煎叆鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                objJsonResult.code = CodeConstant.FAIL;
+                objJsonResult.count = CountConstant.FAIL;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1