From bc1dda419b3cef845ed90f6c31c6bda82743e19a Mon Sep 17 00:00:00 2001 From: yangle <admin@YINMOU> Date: 星期四, 07 三月 2024 10:19:16 +0800 Subject: [PATCH] 器具档案列表 增加 左边树形 器具分类,点击分类,根据分类来过滤,方便选择 器具档案里,增加字段 HMouldClass varchar(50) 器具类型 下拉框 (模具、工装、夹具、刀具、检具、周转器具、其他) --- WebAPI/Controllers/BaseSet/Gy_CustomerController.cs | 646 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 628 insertions(+), 18 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs index 5f65cea..0d13801 100644 --- a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs +++ b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs @@ -1,4 +1,5 @@ -锘縰sing Newtonsoft.Json.Linq; +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections; @@ -11,6 +12,8 @@ { public class Gy_CustomerController : ApiController { + //鑾峰彇绯荤粺鍙傛暟 + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); public DBUtility.ClsPub.Enum_BillStatus BillStatus; private json objJsonResult = new json(); @@ -25,10 +28,11 @@ /// </summary> [Route("Gy_Customer/list")] [HttpGet] - public object list(string sWhere,string user, string Organization) + public object list(string sWhere, string user, string Organization) { try { + List<object> columnNameList = new List<object>(); //缂栬緫鏉冮檺 if (!DBUtility.ClsPub.Security_Log_second("Crm_CustomerFileList", 1, false, user)) { @@ -38,7 +42,22 @@ objJsonResult.data = null; return objJsonResult; } - string sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 缁勭粐鍚嶇О='" + Organization + "'"); + string sql1 = ""; + //瀹㈡埛鍒跺畾 + string sErr = ""; + if (oSystemParameter.ShowBill(ref sErr)) + { + if (oSystemParameter.omodel.WMS_CampanyName == "涔斾竴") + { + sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 1=1"); + } + else + { + sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 缁勭粐鍚嶇О='" + Organization + "'"); + } + } + + if (sWhere == null || sWhere.Equals("")) { ds = oCN.RunProcReturn(sql1 + sWhere + " order by 瀹㈡埛浠g爜 ", "h_v_Gy_CustomerList"); @@ -49,10 +68,19 @@ ds = oCN.RunProcReturn(sql, "h_v_Gy_CustomerList"); } + //娣诲姞鍒楀悕 + 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 +92,49 @@ return objJsonResult; } } + + #region 瀹㈡埛瀛愯〃[鍏宠仈鐢ㄦ埛] 鏌ヨ + /// <summary> + /// 杩斿洖瀹㈡埛瀛愯〃[鍏宠仈鐢ㄦ埛]鍒楄〃 + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Gy_Customer/RelationUserlist")] + [HttpGet] + public object RelationUserlist(Int64 HCusID) + { + try + { + List<object> columnNameList = new List<object>(); + + string sql = "select * from h_v_Gy_Customer_RelationUsers_Query where HCusID = " + HCusID + " order by 鐢ㄦ埛缂栫爜 asc"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_Customer_RelationUsers_Query"); + + //娣诲姞鍒楀悕 + 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; + } + } + #endregion /// <summary> /// 瀹㈡埛鍒楄〃淇敼鎸夐挳鏂规硶 @@ -102,6 +173,45 @@ return objJsonResult; } } + + + #region 鑾峰彇褰撳墠鏈�澶х殑瀹㈡埛浠g爜 + [Route("Gy_Customer/getMaxCusNumber")] + [HttpGet] + public object getMaxCusNumber() + { + try + { + string sql = "select top(1) * from Gy_Customer order by HNumber desc"; + ds = oCN.RunProcReturn(sql, "Gy_Customer"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "灏氭湭瀛樺湪瀹㈡埛锛岃鑷富缁存姢瀹㈡埛浠g爜!"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + 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; + } + } + #endregion /// <summary> /// 鑾峰彇鏈�澶у熀纭�璧勬枡ID @@ -272,9 +382,9 @@ ",HEmpID,HCreditDate,HCreditRatingDate,HMaxCreditRatingDate" + ",HMonthUseQty,HForecastCreditRating,HCreditLevelID,HCountAccrualRating" + ",HSubsidyAccrualRating,HCreditRating,HMaxCreditRating" + - ",HCusTypeID) " + + ",HCusTypeID,HCREATEORGID,HUSEORGID) " + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID + - ", " + HLevel + ",0,'" + HStopflag + "','" + HRemark + "'" + + ", " + HLevel + ",1,'" + HStopflag + "','" + HRemark + "'" + ",'" + HShortName + "','" + HAddress + "','" + HLinkMan + "','" + HLinkPhone + "','" + HMobilePhone + "'" + ",'" + HFax + "','" + HPostalCode + "','" + HEmail + "','" + HBank + "','" + HBankAccount + "'" + ",'" + HTaxNum + "'," + HTaxRate + ",'" + HCountry + "','" + HCorMan + "','" + HEnglishName + "'" + @@ -282,9 +392,25 @@ "," + HEmpID + "," + HCreditDate + "," + HCreditRatingDate + "," + HMaxCredRatingDate + "," + HMonthUseQty + "," + HForecastCreditRating + "," + HCreditLevelID + "," + HCountAccrualRating + "," + HSubsidyAccrualRating + "," + HCreditRating + "," + HMaxCreditRating + - ", " + HCusTypeID + ")"); + ", " + HCusTypeID + ","+ HCreateOrgID + ","+ HUseOrgID + ")"); //淇敼涓婄骇涓洪潪鏈骇浠g爜 oCN.RunProc("Update Gy_Customer set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); + + //淇濆瓨鍚庢帶鍒� + string sql = "select * from Gy_Customer where HNumber = '" + HNumber + "' and HName = '" + HName + "' and HUSEORGID = " + HUseOrgID; + ds = oCN.RunProcReturn(sql, "Gy_Customer"); + HItemID = Int64.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString()); + ds = oCN.RunProcReturn("exec h_p_Gy_Customer_AfterSaveCtrl " + HItemID, "h_p_Gy_Customer_AfterSaveCtrl"); + if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); + objJsonResult.data = null; + return objJsonResult; + } + oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; @@ -302,6 +428,110 @@ return objJsonResult; } } + + + + [Route("Gy_Customer/SaveGy_CustomerListApi")] + [HttpPost] + public object SaveGy_CustomerListApi([FromBody] JObject oMain) + { + try + { + var model = oMain["model"].ToString(); + var custLocationModel = oMain["model"]["HCustLocationEntry"].ToString(); + var custContactModel = oMain["model"]["HCustContactEntry"].ToString(); + //鍙嶅簭鍒楀寲 + model = "[" + model + "]"; + List<Customer> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Customer>>(model); + List<Model.ClsGy_CustLocation_Model> custLocationls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_CustLocation_Model>>(custLocationModel); + List<Model.ClsGy_COMMONCONTACT_Model> custContactls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_COMMONCONTACT_Model>>(custContactModel); + string sql = string.Empty; + oCN.BeginTran(); + sql = $"delete gy_Customer where HItemID = {lsmain[0].HItemID}"; + oCN.RunProc(sql); + sql = "set identity_insert gy_Customer on"; + oCN.RunProc(sql); + //涓昏〃_瀹㈡埛 + oCN.RunProc("Insert into Gy_Customer " + + " (HItemID,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,HCusStatus" + + ",HEmpID,HCreditDate,HCreditRatingDate,HMaxCreditRatingDate" + + ",HMonthUseQty,HForecastCreditRating,HCreditLevelID,HCountAccrualRating" + + ",HSubsidyAccrualRating,HCreditRating,HMaxCreditRating" + + ",HCusTypeID) " + + " Values('" + lsmain[0].HItemID + "','" + lsmain[0].HNumber + "','" + lsmain[0].HName + "','" + lsmain[0].HHelpCode + "','" + lsmain[0].HShortNumber + "'," + lsmain[0].HParentID + + ", " + lsmain[0].HLevel + ",0,'" + lsmain[0].HStopFlag + "','" + lsmain[0].HRemark + "'" + + ",'" + lsmain[0].HShortName + "','" + lsmain[0].HAddress + "','" + lsmain[0].HLinkMan + "','" + lsmain[0].HLinkPhone + "','" + lsmain[0].HMobilePhone + "'" + + ",'" + lsmain[0].HFax + "','" + lsmain[0].HPostalCode + "','" + lsmain[0].HEmail + "','" + lsmain[0].HBank + "','" + lsmain[0].HBankAccount + "'" + + ",'" + lsmain[0].HTaxNum + "'," + lsmain[0].HTaxRate + ",'" + lsmain[0].HCountry + "','" + lsmain[0].HCorMan + "','" + lsmain[0].HEnglishName + "'" + + ",'" + lsmain[0].HEnglishAddress + "'," + lsmain[0].HCurID + "," + lsmain[0].HSSID + "," + lsmain[0].HAreaID + ",'" + lsmain[0].HCusStatus + "'" + + "," + lsmain[0].HEmpID + "," + lsmain[0].HCreditDate + "," + lsmain[0].HCreditRatingDate + "," + lsmain[0].HMaxCreditRatingDate + + "," + lsmain[0].HMonthUseQty + "," + lsmain[0].HForecastCreditRating + "," + lsmain[0].HCreditLevelID + "," + lsmain[0].HCountAccrualRating + + "," + lsmain[0].HSubsidyAccrualRating + "," + lsmain[0].HCreditRating + "," + lsmain[0].HMaxCreditRating + + ", " + lsmain[0].HCusTypeID + ")"); + sql = "set identity_insert gy_Customer off"; + oCN.RunProc(sql); + //瀹㈡埛_浜よ揣鍦扮偣 + sql = $"delete Gy_CustLocation where HItemID = {lsmain[0].HItemID}"; + oCN.RunProc(sql); + sql = "set identity_insert Gy_CustLocation on"; + oCN.RunProc(sql); + foreach (var item in custLocationls) + { + sql = $@"insert into Gy_CustLocation(HItemID,HEntryID,HNumber,HName ,HShortNumber,HParentID ,HLevel + ,HEndFlag,HStopflag,HRemark ,HHelpCode ,HUseFlag + ,HMakeTime ,HMakeEmp ,HCheckEmp ,HCheckTime ,HModifyEmp + ,HModifyTime ,HStopEmp ,HStopTime ,HUSEORGID,HCREATEORGID) + values({item.HItemID},{item.HENTRYID},'{item.HNumber}','{item.HName}','{item.HShortNumber}',{item.HParentID},{item.HLevel} + ,{Convert.ToString(item.HEndFlag ? 1 : 0)},{Convert.ToString(item.HStopflag ? 1 : 0) },'{item.HRemark}','{item.HHelpCode}','{item.HUseFlag}' + ,'{item.HMakeTime}','{item.HMakeEmp}','{item.HCheckEmp}','{item.HCheckTime}','{item.HModifyEmp}' + ,'{item.HModifyTime}','{item.HStopEmp}',null,{item.HUSEORGID},{item.HCREATEORGID})"; + oCN.RunProc(sql); + } + sql = "set identity_insert Gy_CustLocation off"; + oCN.RunProc(sql); + + //瀹㈡埛_鏀惰揣鏂硅仈绯讳汉 + sql = $"delete Gy_COMMONCONTACT where HCUSTID = {lsmain[0].HItemID}"; + oCN.RunProc(sql); + sql = "set identity_insert Gy_COMMONCONTACT on"; + oCN.RunProc(sql); + foreach (var item in custContactls) + { + sql = $@"insert into Gy_COMMONCONTACT(HItemID,HCUSTID,HNumber,HName,HShortNumber,HParentID,HLevel,HEndFlag,HStopflag, + HRemark,HHelpCode,HUseFlag,HMakeTime,HMakeEmp,HCheckEmp,HCheckTime,HModifyEmp,HModifyTime,HStopEmp,HStopTime, + HUSEORGID,HCREATEORGID) + values({item.HItemID},{item.HCUSTID},'{item.HNumber}','{item.HName}','{item.HShortNumber}',{item.HParentID},{item.HLevel} + ,{Convert.ToString(item.HEndFlag ? 1 : 0)},{Convert.ToString(item.HStopflag ? 1 : 0) },'{item.HRemark}','{item.HHelpCode}','{item.HUseFlag}' + ,'{item.HMakeTime}','{item.HMakeEmp}','{item.HCheckEmp}','{item.HCheckTime}','{item.HModifyEmp}' + ,'{item.HModifyTime}','{item.HStopEmp}','{item.HStopTime}',{item.HUSEORGID},{item.HCREATEORGID})"; + oCN.RunProc(sql); + } + sql = "set identity_insert Gy_COMMONCONTACT off"; + oCN.RunProc(sql); + + oCN.Commit(); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鏂板鍩虹璧勬枡鎴愬姛锛�"; + //objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.Message; + objJsonResult.data = null; + return objJsonResult; + } + } + /// <summary> @@ -441,6 +671,21 @@ //灏嗕笂绾� 涓洪潪鏈骇 oCN.RunProc("Update Gy_Customer set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); // + + //淇濆瓨鍚庢帶鍒� + ds = oCN.RunProcReturn("exec h_p_Gy_Customer_AfterSaveCtrl " + HItemID, "h_p_Gy_Customer_AfterSaveCtrl"); + if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); + objJsonResult.data = null; + return objJsonResult; + } + + + oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; @@ -502,25 +747,37 @@ return objJsonResult; } // - if (oDept.DeleteByID(HItemID)) + try { - //鍐欏叆鏃ュ織 - ClsPub.Add_Log("", "鍒犻櫎椤圭洰锛屼唬鐮侊細" + oDeptHlp.omodel.HNumber + ",鍚嶇О锛�" + oDeptHlp.omodel.HName, ClsPub.CurUserName); - //鏇存柊涓婄骇涓� 鏈骇 - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = "鍒犻櫎鎴愬姛"; - objJsonResult.data = null; - return objJsonResult; + if (oDept.DeleteByID(HItemID)) + { + //鍐欏叆鏃ュ織 + ClsPub.Add_Log("", "鍒犻櫎椤圭洰锛屼唬鐮侊細" + oDeptHlp.omodel.HNumber + ",鍚嶇О锛�" + oDeptHlp.omodel.HName, ClsPub.CurUserName); + //鏇存柊涓婄骇涓� 鏈骇 + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触"; + objJsonResult.data = null; + return objJsonResult; + } } - else + catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍒犻櫎澶辫触"; + objJsonResult.Message = "鍒犻櫎澶辫触锛岃瀹㈡埛瀛樺湪鍏宠仈鐨勯攢鍞鍗曘�侀攢鍞嚭搴撳崟銆佺敓浜ц鍗曪紝鎴栫▼搴忛敊璇��"; objJsonResult.data = null; return objJsonResult; } + } //ds = oCN.RunProcReturn("delete from Gy_Department where HItemID = " + HItemID, "Gy_Department"); @@ -540,6 +797,359 @@ } } - // + + #region 瀹㈡埛瀹℃牳銆佸弽瀹℃牳 + /// <summary> + /// + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Gy_Customer/AuditGy_Customer")] + [HttpGet] + public object AuditGy_Customer(int HInterID, int IsAudit, string CurUserName) + { + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Customer_Check", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + var ds = oCN.RunProcReturn("select * from Gy_Customer where HItemID=" + HInterID, "Gy_Customer"); + 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_Customer 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_Customer 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_Customer/StopGy_Customer")] + [HttpGet] + public object StopGy_Customer(int HInterID, int IsStop, string CurUserName) + { + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Customer_Stop", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + var ds = oCN.RunProcReturn("select * from Gy_Customer where HItemID=" + HInterID, "Gy_Material"); + 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_Customer 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_Customer 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_Customer/Gy_CustomerViewApi")] + [HttpGet] + public json Gy_CustomerViewApi(string Number, string Type) + { + string sql = string.Empty; + string sReturn = ""; + if (oSystemParameter.ShowBill(ref sReturn) == true) + { + //绯荤粺鍙傛暟鏄惁涓虹鏈変簯妯″紡,N涓哄叕鏈変簯妯″紡锛孻涓虹鏈変簯妯″紡 + if (oSystemParameter.omodel.WMS_CloudMode == "Y") + { + #region [绉佹湁浜戞ā寮忥紝鐩存帴璋冪敤鏁版嵁搴撳瓨鍌ㄨ繃绋嬫洿鏂癩 + try + { + oCN.BeginTran(); + SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); + DataSet DS = oCn.RunProcReturn("exec h_p_WMS_ERPBasicInfoToLocal '" + Number + "','" + Type + "'", "h_p_WMS_ERPBasicInfoToLocal"); + if (DS == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍩虹璧勬枡鍚屾澶辫触"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBack"]) == "2") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "ERP涓笉瀛樺湪璇ヤ唬鐮�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "1"; + 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 + } + else + { + #region [鍏湁浜戞ā寮忥紝璋冪敤WEBAPI鐨勬柟寮忚繘琛屾洿鏂癩 + var json = new + { + CreateOrgId = 0, + Number = Number, + Id = "" + }; + #region [閲戣澏閮ㄥ垎] + //鐧诲綍閲戣澏 + var loginRet = InvokeHelper.Login(); + var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + //鍒ゆ柇鏄惁鐧诲綍鎴愬姛 + if (isSuccess < 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = loginRet; + objJsonResult.data = null; + return objJsonResult; + } + //鏌ョ湅 鑾峰彇鏁版嵁 + var _result = InvokeHelper.View("BD_Customer", JsonConvert.SerializeObject(json)); + var _saveObj = JObject.Parse(_result); + //鍒ゆ柇鏁版嵁鏄惁鑾峰彇鎴愬姛 + if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "閲戣澏瀹㈡埛鍚屾澶辫触jsonRoot锛�" + _result; + objJsonResult.data = null; + return objJsonResult; + } + + #endregion + //鑾峰彇鏁版嵁 + DataSet Ds; + Ds = oCN.RunProcReturn("select * from Gy_Customer where HNumber = '" + Number + "'", "Gy_Customer"); + if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"].ToString()) != 0) + { + + } + + #region [琛ㄦ暟鎹祴鍊糫 + var jsonData = new + { + HItemID = _saveObj["Result"]["Result"]["Id"], + HERPItemID = _saveObj["Result"]["Result"]["Id"], + HNumber = _saveObj["Result"]["Result"]["Number"], + HName = _saveObj["Result"]["Result"]["Name"][0]["Value"], + HShortNumber = _saveObj["Result"]["Result"]["Number"], + HParentID = 0, + HLevel = 1, + HEndFlag = 1, + HStopflag = _saveObj["Result"]["Result"]["ForbidStatus"].ToString() == "A" ? 0 : 1, + HRemark = "CLD-ERP瀵煎叆", + HUseFlag = "宸蹭娇鐢�", + HMakeTime = _saveObj["Result"]["Result"]["CreateDate"], + HCREATEORGID = _saveObj["Result"]["Result"]["CreateOrgId_Id"], + HUSEORGID = _saveObj["Result"]["Result"]["UseOrgId_Id"], + }; + #endregion + // 鍒犻櫎涓昏〃瀵瑰簲鏁版嵁 + sql = $"delete from Gy_Customer where HItemID = " + jsonData.HItemID + " and HNumber = '" + Number + "'"; + oCN.RunProc(sql); + + sql = "set identity_insert Gy_Customer on"; + oCN.RunProc(sql); + + //鎻掑叆琛� + sql = $@" + insert into Gy_Customer + (HItemID,HERPItemID,HNumber,HName,HShortNumber,HParentID + ,HLevel,HEndFlag,HStopflag,HRemark,HUseFlag,HMakeTime,HCREATEORGID,HUSEORGID + ) + values + ({jsonData.HItemID},{jsonData.HERPItemID},'{jsonData.HNumber}','{jsonData.HName}', + '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}','{jsonData.HUseFlag}','{jsonData.HMakeTime}',{jsonData.HCREATEORGID},{jsonData.HUSEORGID})"; + + oCN.RunProc(sql); + + sql = "set identity_insert Gy_Customer off"; + oCN.RunProc(sql); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹㈡埛鍚屾鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; + + #endregion + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍩虹璧勬枡璇诲彇澶辫触锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + } } \ No newline at end of file -- Gitblit v1.9.1