From 862c0d13dc63efbe73f379580d50a5d36e97a64e Mon Sep 17 00:00:00 2001 From: zrg <z18737863051@163.com> Date: 星期三, 12 三月 2025 14:38:16 +0800 Subject: [PATCH] 计划管理:工艺路线,产品工艺参数 车间管理:岗位技能清单,员工技能清单,设备启动点检清单列表,产品防错验证清单列表 质量管理:检验方案,安灯逐级呼叫规则,环境检测方案 --- WebAPI/Controllers/WebAPIController.cs | 2810 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 2,582 insertions(+), 228 deletions(-) diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs index a81e782..5a164c4 100644 --- a/WebAPI/Controllers/WebAPIController.cs +++ b/WebAPI/Controllers/WebAPIController.cs @@ -18,9 +18,6 @@ using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; using WebAPI.Models; using WebAPI.Service; -using System.Web; -using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; -using System.IO; using SyntacticSugar.constant; namespace WebAPI.Controllers @@ -40,7 +37,7 @@ string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; /// <summary> - /// 閫佽揣鍗曡〃澶翠俊鎭� + /// 鑾峰彇鍗曟嵁鍙蜂笌鍗曟嵁鍐呯爜 /// </summary> /// <param name="sMsg"></param> /// <returns></returns> @@ -355,6 +352,16 @@ objjson.code = "0"; objjson.count = 0; objjson.Message = "瀵嗙爜閿欒锛�"; + objjson.data = null; + return objjson; + } + //鍒ゆ柇鐢ㄦ埛鏁版槸鍚﹀ぇ浜庡鎴疯处鍙锋暟 + DataSet ds1 = oCN.RunProcReturn("Exec h_p_Xt_BaseInfo ", "h_p_Xt_BaseInfo"); + if (DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HBack"]) != "0") + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = ds1.Tables[0].Rows[0]["HBackRemark"].ToString(); objjson.data = null; return objjson; } @@ -2607,7 +2614,6 @@ DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Gy_BadReason ", "Gy_BadReason"); 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"]); maxid += 1; HItemID = maxid; @@ -2734,7 +2740,7 @@ oItem.HShortNumber = sShortNumber;//鐭唬鐮� oItem.HEndFlag = true;//鏈骇鏍囧織 oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇 - + oItem.HMakeEmp = msg2; oBill.oModel = oItem; } @@ -2743,19 +2749,17 @@ bool bResult; if (oBill.oModel.HItemID == 0) { - // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; - objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; - //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�"); + objJsonResult.Message = "淇濆瓨鎴愬姛锛�";; objJsonResult.data = 1; return objJsonResult; } @@ -2778,6 +2782,480 @@ } } + /// <summary> + /// 涓嶈壇鍘熷洜鑾峰彇淇℃伅 + /// </summary> + /// <returns></returns> + [Route("GetGy_BadReasonDetail")] + [HttpGet] + public ApiResult<DataSet> GetGy_BadReasonDetail(string HID) + { + var model = LuBaoSevice.GetGy_BadReasonBillDetail(HID); + return model; + } + + /// <summary> + /// 涓嶈壇鍘熷洜鍒犻櫎鍔熻兘 + /// </summary> + /// <returns></returns> + [Route("DeltetGy_BadReason")] + [HttpGet] + public object DeltetGy_BadReason(string HItemID, string user) + { + DataSet ds; + //string ModRightNameCheck = "Sc_ProcessReport_check"; + try + { + //鍒犻櫎鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Gy_BadReason_Delete", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + 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_BadReason where HItemID=" + HItemID, "Gy_BadReason"); + 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; + //} + + + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_BadReason_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_BadReason_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + + oCN.RunProc("delete Gy_BadReason where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_BadReason_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_BadReason_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + + 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; + } + } + + #region 涓嶈壇鍘熷洜 鏂囦欢瀵煎叆淇濆瓨 + #region 涓嶈壇鍘熷洜 鏂囦欢涓婁紶 + [Route("Gy_BadReason/Gy_BadReason_Excel")] + [HttpPost] + public object Gy_BadReason_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("HDeptID", typeof(Int32));//閮ㄩ棬ID + tb2.Columns.Add("HProcID", 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("涓嶈壇鍘熷洜浠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 (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 HDeptNumber = ""; + string HDeptName = ""; + string HProcNumber = ""; + string HProcName = ""; + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇鍘熷洜"].ToString()); + HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇鍘熷洜浠g爜"].ToString()); + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString()); + HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString()); + HDeptNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿閮ㄩ棬浠g爜"].ToString()); + HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿閮ㄩ棬"].ToString()); + HProcNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿宸ュ簭浠g爜"].ToString()); + HProcName = 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 (HDeptNumber != "") + { + //鏌ヨ閮ㄩ棬 + ds = oCN.RunProcReturn("select * from Gy_Department where HNumber='" + HDeptNumber + "' and Hname='" + HDeptName + "'", "Gy_Department"); + + 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]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + } + else + { + tb2.Rows[i]["HDeptID"] = 0; + } + if (HProcNumber != "") + { + //鏌ヨ閮ㄩ棬 + ds = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HProcNumber + "' and Hname='" + HProcName + "'", "Gy_Process"); + + 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]["HProcID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + } + else + { + tb2.Rows[i]["HProcID"] = 0; + } + + //涓嶈壇鍘熷洜鍚嶇О + if (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇鍘熷洜鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //涓嶈壇鍘熷洜浠g爜 + if (HNum == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇鍘熷洜浠g爜涓嶈兘涓虹┖锛�"; + 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_BadReason/Gy_BadReason_btnSave")] + [HttpPost] + public object Gy_BadReason_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_BadReason_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 HDeptID = item["HDeptID"].ToString();//閮ㄩ棬ID + string HProcID = item["HProcID"].ToString();//宸ュ簭ID + string HName = item["涓嶈壇鍘熷洜"].ToString(); + string HNumber = item["涓嶈壇鍘熷洜浠g爜"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + string HHelpCode = item["鍔╄鐮�"].ToString(); + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮� + if (sShortNumber.Trim() == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + 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 = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_BadReason where HNumber='" + HNumber + "'", "Gy_BadReason"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into " + "Gy_BadReason " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HDeptID,HProcID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HBadTypeID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HDeptID.ToString() + "," + HProcID.ToString() + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "'," + 0 + ")", ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + oCN.RunProc("Update Gy_BadReason"+ " set " + + "HName='" + HName + "'" + + ",HShortNumber='" + sShortNumber + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HLevel=" + HLevel.ToString() + + ",HDeptID=" + HDeptID.ToString() + + ",HProcID=" + HProcID.ToString() + + ",HRemark= '" + HRemark + "' 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 + + #endregion + + #region 涓嶈壇绫诲瀷 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 /// <summary> /// 淇濆瓨涓嶈壇绫诲瀷 @@ -2938,7 +3416,7 @@ oItem.HShortNumber = sShortNumber;//鐭唬鐮� oItem.HEndFlag = true;//鏈骇鏍囧織 oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇 - + oItem.HMakeEmp = msg2; oBill.oModel = oItem; } @@ -2947,19 +3425,17 @@ bool bResult; if (oBill.oModel.HItemID == 0) { - // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; - //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�"); objJsonResult.data = 1; return objJsonResult; } @@ -2982,6 +3458,452 @@ } } + /// <summary> + /// 涓嶈壇绫诲瀷鑾峰彇淇℃伅 + /// </summary> + /// <returns></returns> + [Route("GetGy_BadTypeDetail")] + [HttpGet] + public ApiResult<DataSet> GetGy_BadTypeDetail(string HID) + { + var dataSet = oCN.RunProcReturn("select top 1 * from h_v_gy_BadTypeList where HItemID= " + HID + " ", "h_v_gy_BadTypeList"); + if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) + return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄤ笉鑹被鍨嬫暟鎹�" }; + return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet }; + } + + /// <summary> + /// 涓嶈壇绫诲瀷鍒犻櫎鍔熻兘 + /// </summary> + /// <returns></returns> + [Route("DeltetGy_BadType")] + [HttpGet] + public object DeltetGy_BadType(string HItemID, string user) + { + DataSet ds; + //string ModRightNameCheck = "Sc_ProcessReport_check"; + try + { + //鍒犻櫎鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Gy_BadType_Drop", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + 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_BadType where HItemID=" + HItemID, "Gy_BadType"); + 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; + //} + + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_BadType_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_BadType_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + + oCN.RunProc("delete Gy_BadType where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_BadType_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_BadType_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + + 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; + } + } + + #region 涓嶈壇绫诲瀷 鏂囦欢瀵煎叆淇濆瓨 + #region 涓嶈壇绫诲瀷 鏂囦欢涓婁紶 + [Route("Gy_BadType/Gy_BadType_Excel")] + [HttpPost] + public object Gy_BadType_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("HGroupID", 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("涓嶈壇绫诲瀷浠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 (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 HGroupNumber = ""; + string HGroupName = ""; + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇绫诲瀷"].ToString()); + HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇绫诲瀷浠g爜"].ToString()); + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString()); + HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString()); + HGroupNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿鐝粍浠g爜"].ToString()); + HGroupName = 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(HGroupNumber != "") + { + //鏌ヨ鐝粍 + ds = oCN.RunProcReturn("select * from Gy_Group where HNumber='" + HGroupNumber + "' and Hname='" + HGroupName + "'", "Gy_Group"); + + 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]["HGroupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + } + else + { + tb2.Rows[i]["HGroupID"] = 0; + } + + + //涓嶈壇绫诲瀷鍚嶇О + if (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇绫诲瀷鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //涓嶈壇绫诲瀷浠g爜 + if (HNum == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇绫诲瀷浠g爜涓嶈兘涓虹┖锛�"; + 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_BadType/Gy_BadType_btnSave")] + [HttpPost] + public object Gy_BadType_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_BadType_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 HGroupID = item["HGroupID"].ToString();//鐝粍ID + string HName = item["涓嶈壇绫诲瀷"].ToString(); + string HNumber = item["涓嶈壇绫诲瀷浠g爜"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + string HHelpCode = item["鍔╄鐮�"].ToString(); + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮� + if (sShortNumber.Trim() == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + 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 = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_BadType where HNumber='" + HNumber + "'", "Gy_BadType"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into Gy_BadType" + " " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HGroupID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HUSEORGID,HCREATEORGID,HUseFlag,HMakeEmp,HMakeTime) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HGroupID.ToString() + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "'," + HOrgID + "," + HOrgID + ",'" + "鏈娴�" + "','" + user + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo); + + } + else + { + oCN.RunProc("Update " + "Gy_BadType " + " set " + + "HName='" + HName + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HGroupID= '" + HGroupID + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " where HNumber='" + HNumber + "'"); + } + + 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 + + #endregion + + #region 寮傚父绫诲瀷 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 /// <summary> /// 淇濆瓨寮傚父绫诲瀷 @@ -3622,175 +4544,6 @@ } #endregion #endregion - - /// <summary> - /// 涓嶈壇绫诲瀷鑾峰彇淇℃伅 - /// </summary> - /// <returns></returns> - [Route("GetGy_BadTypeDetail")] - [HttpGet] - public ApiResult<DataSet> GetGy_BadTypeDetail(string HID) - { - var dataSet = oCN.RunProcReturn("select top 1 * from h_v_gy_BadTypeList where HItemID= " + HID + " ", "h_v_gy_BadTypeList"); - if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) - return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄤ笉鑹被鍨嬫暟鎹�" }; - return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet }; - } - - /// <summary> - /// 涓嶈壇绫诲瀷鍒犻櫎鍔熻兘 - /// </summary> - /// <returns></returns> - [Route("DeltetGy_BadType")] - [HttpGet] - public object DeltetGy_BadType(string HItemID, string user) - { - DataSet ds; - //string ModRightNameCheck = "Sc_ProcessReport_check"; - try - { - //鍒犻櫎鏉冮檺 - if (!DBUtility.ClsPub.Security_Log("Gy_BadType_Drop", 1, false, user)) - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; - objJsonResult.data = null; - return objJsonResult; - } - - SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); - 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_BadType where HItemID=" + HItemID, "Gy_BadType"); - 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 Gy_BadType 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; - } - } - - /// <summary> - /// 涓嶈壇鍘熷洜鑾峰彇淇℃伅 - /// </summary> - /// <returns></returns> - [Route("GetGy_BadReasonDetail")] - [HttpGet] - public ApiResult<DataSet> GetGy_BadReasonDetail(string HID) - { - var model = LuBaoSevice.GetGy_BadReasonBillDetail(HID); - return model; - } - - /// <summary> - /// 涓嶈壇鍘熷洜鍒犻櫎鍔熻兘 - /// </summary> - /// <returns></returns> - [Route("DeltetGy_BadReason")] - [HttpGet] - public object DeltetGy_BadReason(string HItemID, string user) - { - DataSet ds; - //string ModRightNameCheck = "Sc_ProcessReport_check"; - try - { - //鍒犻櫎鏉冮檺 - if (!DBUtility.ClsPub.Security_Log("Gy_BadReason_Delete", 1, false, user)) - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; - objJsonResult.data = null; - return objJsonResult; - } - - SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); - 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_BadReason where HItemID=" + HItemID, "Gy_BadReason"); - 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 Gy_BadReason 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 @@ -3965,11 +4718,11 @@ if (oBill.oModel.HItemID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { @@ -4063,7 +4816,58 @@ // return objJsonResult; //} + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_BadResult_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_BadResult_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + oCN.RunProc("delete Gy_BadResult where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_BadResult_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_BadResult_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -4081,6 +4885,277 @@ return objJsonResult; } } + + #region 涓嶈壇鍚庢灉 鏂囦欢瀵煎叆淇濆瓨 + #region 涓嶈壇鍚庢灉 鏂囦欢涓婁紶 + [Route("Gy_BadResult/Gy_BadResult_Excel")] + [HttpPost] + public object Gy_BadResult_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 + + //娣诲姞鏁版嵁 + 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("涓嶈壇鍚庢灉浠g爜")) + 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 = ""; + + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇鍚庢灉"].ToString()); + HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇鍚庢灉浠g爜"].ToString()); + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString()); + HORGName = 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 (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇鍚庢灉鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //涓嶈壇鍚庢灉浠g爜 + if (HNum == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇鍚庢灉浠g爜涓嶈兘涓虹┖锛�"; + 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_BadResult/Gy_BadResult_btnSave")] + [HttpPost] + public object Gy_BadResult_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_BadResult_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 HName = item["涓嶈壇鍚庢灉"].ToString(); + string HNumber = item["涓嶈壇鍚庢灉浠g爜"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + string HHelpCode = item["鍔╄鐮�"].ToString(); + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮� + if (sShortNumber.Trim() == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + 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 = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_BadResult where HNumber='" + HNumber + "'", "Gy_BadResult"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into Gy_BadResult" + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HISsystemSet,HCREATEORGID,HERPItemID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + 0 + "','" + HOrgID + "','" + 0 + "')", ref DBUtility.ClsPub.sExeReturnInfo); + + } + else + { + oCN.RunProc("Update " + "Gy_BadResult " + " set " + + "HName='" + HName + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " where HNumber='" + HNumber + "'"); + } + + 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 + #endregion @@ -6084,19 +7159,17 @@ bool bResult; if (oBill.oModel.HItemID == 0) { - // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; - //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�"); objJsonResult.data = 1; return objJsonResult; } @@ -6139,8 +7212,7 @@ [HttpGet] public object DeltetGy_PostSkill(string HItemID, string user) { - DataSet ds; - //string ModRightNameCheck = "Sc_ProcessReport_check"; + DataSet ds; try { //鍒犻櫎鏉冮檺 @@ -6173,8 +7245,58 @@ return objJsonResult; ; } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_PostSkill_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_PostSkill_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.RunProc("delete Gy_PostSkill where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_PostSkill_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_PostSkill_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -6668,19 +7790,17 @@ bool bResult; if (oBill.oModel.HItemID == 0) { - // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; - //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�"); objJsonResult.data = 1; return objJsonResult; } @@ -6724,7 +7844,6 @@ public object DeltetGy_Post(string HItemID, string user) { DataSet ds; - //string ModRightNameCheck = "Sc_ProcessReport_check"; try { //鍒犻櫎鏉冮檺 @@ -6757,8 +7876,59 @@ return objJsonResult; ; } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_Post_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_Post_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.RunProc("delete Gy_Post where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_Post_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_Post_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -9009,6 +10179,278 @@ return objJsonResult; } } + + #region 渚涘簲鍟嗗垎绫� 鏂囦欢瀵煎叆淇濆瓨 + #region 渚涘簲鍟嗗垎绫� 鏂囦欢涓婁紶 + [Route("Gy_SupType/Gy_SupType_Excel")] + [HttpPost] + public object Gy_SupType_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 + + //娣诲姞鏁版嵁 + 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("鍔╄鐮�")) + 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 = ""; + + + 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()); + + //妫�鏌ョ墿鏂� + 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 (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_SupType/Gy_SupType_btnSave")] + [HttpPost] + public object Gy_SupType_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_SupType_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 HName = item["渚涘簲鍟嗗垎绫�"].ToString(); + string HNumber = item["渚涘簲鍟嗗垎绫讳唬鐮�"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + string HHelpCode = item["鍔╄鐮�"].ToString(); + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮� + if (sShortNumber.Trim() == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + 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 = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_SupType where HNumber='" + HNumber + "'", "Gy_SupType"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into " + "Gy_SupType " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + oCN.RunProc("Update " + "Gy_SupType " + " set " + + "HName='" + HName + "'" + + ",HShortNumber='" + sShortNumber + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " where HNumber='" + HNumber + "'"); + } + + 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 + + #endregion #region 宸ヨ壓鍙傛暟鍒嗙被 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 @@ -9181,19 +10623,17 @@ bool bResult; if (oBill.oModel.HItemID == 0) { - // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; - //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�"); objJsonResult.data = 1; return objJsonResult; } @@ -9225,7 +10665,6 @@ public object DeltetGy_TechnologyType(string HItemID, string user) { DataSet ds; - //string ModRightNameCheck = "Sc_ProcessReport_check"; try { //鍒犻櫎鏉冮檺 @@ -9258,8 +10697,59 @@ return objJsonResult; ; } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_TechnologyParameterClass_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_TechnologyParameterClass_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.RunProc("delete Gy_TechnologyParameterClass where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_TechnologyParameterClass_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_TechnologyParameterClass_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -9571,6 +11061,278 @@ return objJsonResult; } } + + + #region 瀹㈡埛鍒嗙被 鏂囦欢瀵煎叆淇濆瓨 + #region 瀹㈡埛鍒嗙被 鏂囦欢涓婁紶 + [Route("Gy_CusType/Gy_CusType_Excel")] + [HttpPost] + public object Gy_CusType_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 + + //娣诲姞鏁版嵁 + 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("瀹㈡埛鍒嗙被浠g爜")) + 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 = ""; + + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀹㈡埛鍒嗙被"].ToString()); + HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀹㈡埛鍒嗙被浠g爜"].ToString()); + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString()); + HORGName = 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 (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,瀹㈡埛鍒嗙被鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //瀹㈡埛鍒嗙被浠g爜 + if (HNum == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,瀹㈡埛鍒嗙被浠g爜涓嶈兘涓虹┖锛�"; + 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_CusType/Gy_CusType_btnSave")] + [HttpPost] + public object Gy_CusType_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_CusType_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 HName = item["瀹㈡埛鍒嗙被"].ToString(); + string HNumber = item["瀹㈡埛鍒嗙被浠g爜"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + string HHelpCode = item["鍔╄鐮�"].ToString(); + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮� + if (sShortNumber.Trim() == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + 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 = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_CusType where HNumber='" + HNumber + "'", "Gy_CusType"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into " + " Gy_CusType" + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + oCN.RunProc("Update " + "Gy_CusType " + " set " + + "HName='" + HName + "'" + + ",HShortNumber='" + sShortNumber + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " where HNumber='" + HNumber + "'"); + } + + 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 + #endregion #region 鐩樼偣鏂规 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 @@ -10883,11 +12645,11 @@ if (oBill.oModel.HItemID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID,ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { @@ -10991,8 +12753,59 @@ return objJsonResult; } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_BadPhenomena_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_BadPhenomena_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.RunProc("delete Gy_BadPhenomena where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_BadPhenomena_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_BadPhenomena_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -11010,6 +12823,279 @@ return objJsonResult; } } + + #region 涓嶈壇鐜拌薄 鏂囦欢瀵煎叆淇濆瓨 + #region 涓嶈壇鐜拌薄 鏂囦欢涓婁紶 + [Route("Gy_BadPhenomena/Gy_BadPhenomena_Excel")] + [HttpPost] + public object Gy_BadPhenomena_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 + + //娣诲姞鏁版嵁 + 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("涓嶈壇鐜拌薄浠g爜")) + 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 = ""; + + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇鐜拌薄"].ToString()); + HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇鐜拌薄浠g爜"].ToString()); + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString()); + HORGName = 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 (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇鐜拌薄鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //涓嶈壇鐜拌薄浠g爜 + if (HNum == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇鐜拌薄浠g爜涓嶈兘涓虹┖锛�"; + 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_BadPhenomena/Gy_BadPhenomena_btnSave")] + [HttpPost] + public object Gy_BadPhenomena_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_BadPhenomena_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 HName = item["涓嶈壇鐜拌薄"].ToString(); + string HNumber = item["涓嶈壇鐜拌薄浠g爜"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + string HHelpCode = item["鍔╄鐮�"].ToString(); + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮� + if (sShortNumber.Trim() == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + 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 = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_BadPhenomena where HNumber='" + HNumber + "'", "Gy_BadPhenomena"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into " + "Gy_BadPhenomena " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); + + } + else + { + oCN.RunProc("Update " + "Gy_BadPhenomena " + " set " + + "HName='" + HName + "'" + + ",HShortNumber='" + sShortNumber + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " where HNumber='" + HNumber + "'"); + } + + 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 + + #endregion #region 椤圭洰绫诲埆 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 @@ -12054,11 +14140,11 @@ if (oBill.oModel.HItemID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { @@ -12133,8 +14219,56 @@ } oCN.BeginTran();//寮�濮嬩簨鍔� + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_PreventErrMould_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_PreventErrMould_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== oCN.RunProc("delete Gy_PreventErrMould where HItemID=" + HItemID); + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_PreventErrMould_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_PreventErrMould_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -12187,7 +14321,6 @@ DataSet Maxds = oCN.RunProcReturn("select isNull(MAX(HItemID),0) HItemID from Gy_MaintainLev ", "Gy_MaintainLev"); 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"]); maxid += 1; HItemID = maxid; @@ -12326,18 +14459,17 @@ if (oBill.oModel.HItemID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; - //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�"); objJsonResult.data = 1; return objJsonResult; } @@ -12379,9 +14511,7 @@ [Route("DeltetGy_MaintainLev")] [HttpGet] public object DeltetGy_MaintainLev(string HItemID, string user) - { - DataSet ds; - //string ModRightNameCheck = "Sc_ProcessReport_check"; + { try { //鍒犻櫎鏉冮檺 @@ -12405,8 +14535,59 @@ } oCN.BeginTran();//寮�濮嬩簨鍔� + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_MaintainLev_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_MaintainLev_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.RunProc("delete Gy_MaintainLev where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_MaintainLev_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_MaintainLev_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -12596,11 +14777,11 @@ bool bResult; if (oBill.oModel.HItemID == 0) { - bResult = oBill.AddNew(); + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { @@ -12673,8 +14854,58 @@ } oCN.BeginTran();//寮�濮嬩簨鍔� + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_CheckNoteItem_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_CheckNoteItem_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.RunProc("delete Gy_CheckNoteItem where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_CheckNoteItem_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_CheckNoteItem_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -13330,9 +15561,9 @@ #endregion - #region 鐜妫�娴嬪崟 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 + #region 鐜妫�娴嬮」鐩� 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 /// <summary> - /// 淇濆瓨鐜妫�娴嬪崟 + /// 淇濆瓨鐜妫�娴嬮」鐩� /// </summary> /// <param name="msg"></param> /// <returns></returns> @@ -13363,7 +15594,6 @@ DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Gy_EnvironmentTestItem ", "Gy_EnvironmentTestItem"); 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"]); maxid += 1; HItemID = maxid; @@ -13499,12 +15729,12 @@ //淇濆瓨瀹屾瘯鍚庡鐞� bool bResult; if (oBill.oModel.HItemID == 0) - { - bResult = oBill.AddNew(); + { + bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo); } else { - bResult = oBill.ModifyByID(oBill.oModel.HItemID); + bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { @@ -13584,9 +15814,59 @@ objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒"; objJsonResult.data = null; return objJsonResult; ; - } + } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_EnvironmentTestItem_BeforeDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_EnvironmentTestItem_BeforeDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.RunProc("delete Gy_EnvironmentTestItem where HItemID=" + HItemID); + + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Gy_EnvironmentTestItem_AfterDelCtrl " + HItemID + ",'" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Gy_EnvironmentTestItem_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -15129,12 +17409,16 @@ /// <returns></returns> [Route("Web/GetCheckItemID")] [HttpGet] - public object GetCheckItemID(string HName,string HProName) + public object GetCheckItemID(string HName,string HProName,string HSourceID) { try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); - ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Main where 鐗╂枡鍚嶇О='"+HName+ "' and 宸ュ簭鍚嶇О='" + HProName + "' order by 鏃ユ湡 desc ", "h_v_Gy_QCCheckProjectList_Main"); + ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Main where 鐗╂枡鍚嶇О='"+HName+ "' and 宸ュ簭鍚嶇О='" + HProName + "' and HSourceID='" + HSourceID + "' order by 鏃ユ湡 desc ", "h_v_Gy_QCCheckProjectList_Main"); + if (ds == null || ds.Tables[0].Rows.Count <= 0) + { + ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Main where 鐗╂枡鍚嶇О='" + HName + "' and 宸ュ簭鍚嶇О='" + HProName + "' order by 鏃ユ湡 desc ", "h_v_Gy_QCCheckProjectList_Main"); + } if (ds == null || ds.Tables[0].Rows.Count <= 0) { objjson.code = "0"; @@ -16269,6 +18553,7 @@ public int HLevel { get; set; } public string Hurl { get; set; } public string HPicNum { get; set; } + public string HShowMode { get; set; } public List<MenuLoad> childMenus { get; set; } } @@ -16280,18 +18565,18 @@ { List<MenuLoad> mu = new List<MenuLoad>(); //浠ョ埗瀛愮骇缁撴瀯瀛樻斁鑿滃崟娓呭崟淇℃伅 SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //鏁版嵁搴撴搷浣滃伐鍏� - string sql = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum from Gy_MenuDefineSet where HMakeName = '" + HMakeName + "' and HType = '" + HType + "' order by HPosition"; + string sql = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum,HShowMode from Gy_MenuDefineSet where HMakeName = '" + HMakeName + "' and HType = '" + HType + "' order by HPosition"; ds = oCn.RunProcReturn(sql, "Gy_MenuDefineSet"); //鏌ヨ褰撳墠鐢ㄦ埛鐨勮嚜瀹氫箟鑿滃崟鏁版嵁 if (ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0) //鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁鏈夎缃繃鑷畾涔変俊鎭紝鑻ヨ褰曟暟涓�0锛屽垯娌℃湁璁剧疆杩囷紝鍔犺浇鎵�鏈夌殑鑿滃崟淇℃伅 { - string sql1 = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum from Gy_MenuDefineSet where HMakeName=" + + string sql1 = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum,HShowMode from Gy_MenuDefineSet where HMakeName=" + "(select top 1 c.GroupName from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId " + "left join System_UserGroup c on b.GroupId = c.GroupID where a.Czymc ='"+HMakeName+"' order by len(c.GroupName ))"; ds = oCn.RunProcReturn(sql1, "Gy_MenuDefineSet"); //鏌ヨ鐢ㄦ埛缁戝畾鐨勮鑹� 鏄惁璁剧疆鑿滃崟淇℃伅 鍙栬鑹插悕绉版渶鐭殑涓�涓� if ((ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0)) { sql = "Select * from Gy_Menu_1 where HType = '" + HType + "' Order by HPosition,len(HitemID),HitemID "; - ds = oCn.RunProcReturn(sql, "Gy_Menu"); + ds = oCn.RunProcReturn(sql, "Gy_Menu_1"); } } @@ -16306,6 +18591,7 @@ tbj.HPartentID = ds.Tables[0].Rows[i]["HPartentID"].ToString(); tbj.HLevel = int.Parse(ds.Tables[0].Rows[i]["HLevel"].ToString()); tbj.Hurl = ds.Tables[0].Rows[i]["Hurl"].ToString(); + tbj.HShowMode = ds.Tables[0].Rows[i]["HShowMode"].ToString(); if (ds.Tables[0].Rows[i]["HPicNum"] != null) { tbj.HPicNum = ds.Tables[0].Rows[i]["HPicNum"].ToString(); @@ -16348,6 +18634,7 @@ tbjson.HName = dt.Rows[i]["HName"].ToString(); tbjson.HLevel = tree[m].HLevel; tbjson.Hurl = dt.Rows[i]["Hurl"].ToString(); + tbjson.HShowMode = dt.Rows[i]["HShowMode"].ToString(); if (dt.Rows[i]["HPicNum"] != null) { tbjson.HPicNum = dt.Rows[i]["HPicNum"].ToString(); @@ -16735,6 +19022,12 @@ SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); string sql = "select a.HSubFuncID, a.HCaption,a.HPicNum,b.Hurl from Xt_UserFastMenu as a join Gy_Menu_1 as b on a.HSubFuncID = b.HItemID where a.HUserID = '" + HMakeName + "' and b.HType = '" + HType + "' Order by a.HItemID"; ds = oCn.RunProcReturn(sql, "Xt_UserFastMenu"); //鑾峰彇Xt_UserFastMenu涓鐢ㄦ埛璁剧疆鐨勮嚜瀹氫箟鑿滃崟淇℃伅锛岀敤浜庡湪鍓嶇鍔犺浇 + + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + sql = "select a.HSubFuncID, a.HCaption,a.HPicNum,b.Hurl from Xt_UserFastMenu as a join Gy_Menu_1 as b on a.HSubFuncID = b.HItemID where a.HUserID = 'admin' and b.HType = '" + HType + "' Order by a.HItemID"; + ds = oCn.RunProcReturn(sql, "Xt_UserFastMenu"); //鑾峰彇Xt_UserFastMenu涓鐢ㄦ埛璁剧疆鐨勮嚜瀹氫箟鑿滃崟淇℃伅锛岀敤浜庡湪鍓嶇鍔犺浇 + } objJsonResult.code = "1"; objJsonResult.count = 1; @@ -17206,6 +19499,67 @@ } } + + /// <summary> + /// 閲戝竻WMS鎺ュ彛 + /// </summary> + /// <returns></returns> + [Route("Web/WMSBarcodeQuery")] + [HttpGet] + public object WMSBarcodeQuery(DateTime dateTime, string UserName, string PassWord) + { + try + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + //鏉冮檺鍒ゅ畾 + DAL.ClsUser oUser = new DAL.ClsUser(); + DataSet DS; + DS = oCN.RunProcReturn("select * from Gy_Czygl where Czymc='" + UserName.Trim() + "' and Czmm='" + DBUtility.ClsPub.StrToPsd(PassWord.Trim()) + "' ", "Gy_Czygl"); + if (UserName == "" || UserName != "鍞悗鏉$爜鏌ヨ") + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鐢ㄦ埛涓嶅锛�"; + objjson.data = null; + return objjson; + } + if (DS == null || DS.Tables[0].Rows.Count == 0) + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "瀵嗙爜閿欒锛�"; + objjson.data = null; + return objjson; + } + ds = oCN.RunProcReturn("exec h_p_WMSBarcodeQuery '" + dateTime + "'", "h_p_WMSBarcodeQuery"); + + if (ds == null || ds.Tables[0].Rows.Count <= 0) + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鑾峰彇澶辫触" + DBUtility.ClsPub.sErrInfo; + objjson.data = null; + return objjson; + } + else + { + objjson.code = "1"; + objjson.count = 1; + objjson.Message = "鑾峰彇鎴愬姛!"; + objjson.data = ds.Tables[0]; + return objjson; + } + } + catch (Exception ex) + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鑾峰彇澶辫触" + ex.ToString(); + objjson.data = null; + return objjson; + } + } + } } -- Gitblit v1.9.1