From 380127b84c3fa9cfc8c9753d8ffed5b20e927720 Mon Sep 17 00:00:00 2001 From: duhe <226547893@qq.com> Date: 星期三, 16 十月 2024 15:49:00 +0800 Subject: [PATCH] 出门确认单 --- WebAPI/Controllers/BLL/Xt_UserController.cs | 914 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 892 insertions(+), 22 deletions(-) diff --git a/WebAPI/Controllers/BLL/Xt_UserController.cs b/WebAPI/Controllers/BLL/Xt_UserController.cs index 99b3bb0..04cbab1 100644 --- a/WebAPI/Controllers/BLL/Xt_UserController.cs +++ b/WebAPI/Controllers/BLL/Xt_UserController.cs @@ -1,6 +1,7 @@ 锘縰sing Newtonsoft.Json; using Newtonsoft.Json.Linq; using Pub_Class; +using SyntacticSugar.constant; using System; using System.Collections; using System.Collections.Generic; @@ -107,6 +108,26 @@ objJsonResult.data = null; return objJsonResult; } + + //鑾峰彇褰撳墠鐢ㄦ埛韬唤鍒楄〃 + string sql = "select HLev from System_UserGroupInfo u " + + " left join System_UserGroup r " + + "on u.GroupId = r.GroupID where u.UserId = '" + HCzybm + "'"; + + //鐢ㄦ埛韬唤鍒ゆ柇 + DataSet hLev = oCN.RunProcReturn(sql, "System_UserGroupInfo"); + foreach(DataRow dr in hLev.Tables[0].Rows) + { + if (!dr["HLev"].Equals(RoleConstant.EMPLOYEE)) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绠$悊鍛樿韩浠戒笉鍏佽鍒犻櫎锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + oCN.BeginTran(); //鍒犻櫎鐢ㄦ埛淇℃伅 oCN.RunProc("delete from Gy_Czygl where Czybm='" + HCzybm + "'"); @@ -206,14 +227,14 @@ ",HWhID,HWHName,HSupID,HSupName " + ",HSCWHID,HSCWHName " + ",HCloudUserName,HCloudUserPsd,HUSEORGID,HProcID" + - ",HGroupID,HSourceID) " + + ",HGroupID,HSourceID,HCheckEmpID,HWorkCenterID,HICNumber) " + "values ('" + lsmain[0].Czybm.ToString() + "','" + lsmain[0].Czymc.ToString() + "','" + ClsPub.StrToPsd(lsmain[0].Czmm.ToString()) + "','" + lsmain[0].Explain.ToString() + "','" + lsmain[0].HEmpID.ToString() + "',"+ lsmain[0].HK3UserID.ToString() + "" + ","+ lsmain[0].HKeeperID.ToString() + ",'"+ lsmain[0].HKeeper.ToString() + "',"+ lsmain[0].HSecManagerID.ToString() + ",'"+ lsmain[0].HSecManager.ToString() + "'" + "," + lsmain[0].HSellManID.ToString() + ",'" + lsmain[0].HSellMan.ToString() + "'," + lsmain[0].HDeptID.ToString() + ",'" + lsmain[0].HDept.ToString() + "'" + "," + lsmain[0].HWhID.ToString() + ",'" + lsmain[0].HWHName.ToString() + "'," + lsmain[0].HSupID.ToString() + ",'" + lsmain[0].HSupName.ToString() + "'" + "," + lsmain[0].HSCWHID.ToString() + ",'" + lsmain[0].HSCWHName.ToString() + "'" + ",'" + lsmain[0].HCloudUserName.ToString() + "','" + lsmain[0].HCloudUserPsd.ToString() + "',"+ lsmain[0].HOrgID.ToString() + "," + lsmain[0].HProcID.ToString() + "" + - ","+ lsmain[0].HGroupID.ToString() + ","+ lsmain[0].HSourceID.ToString() + ")"); + ","+ lsmain[0].HGroupID.ToString() + ","+ lsmain[0].HSourceID.ToString() + "," + lsmain[0].HCheckEmpID.ToString() + "," + lsmain[0].HWorkCenterID.ToString() + ",'" + lsmain[0].HICNumber + "'" + ")"); //鏂板鍚庢煡璇� 纭繚鏁版嵁娣诲姞鎴愬姛 ds = oCN.RunProcReturn("Select * from Gy_Czygl where Czybm='" + lsmain[0].Czybm.ToString() + "'", "Gy_Czygl"); @@ -256,6 +277,7 @@ ",HDeptID=" + lsmain[0].HDeptID.ToString() + ",HDept='" + lsmain[0].HDept.ToString() + "'" + ",HWhID=" + lsmain[0].HWhID.ToString() + + ",HCheckEmpID=" + lsmain[0].HCheckEmpID.ToString() + ",HWHName='" + lsmain[0].HWHName.ToString() + "'" + ",HSCWHID=" + lsmain[0].HSCWHID.ToString() + ",HSCWHName='" + lsmain[0].HSCWHName.ToString() + "'" + @@ -263,10 +285,12 @@ ",HProcID=" + lsmain[0].HProcID.ToString() + ",HSourceID=" + lsmain[0].HSourceID.ToString() + ",HGroupID=" + lsmain[0].HGroupID.ToString() + + ",HWorkCenterID=" + lsmain[0].HWorkCenterID.ToString() + ",HSupName='" + lsmain[0].HSupName.ToString() + "'" + ",HCloudUserName='" + lsmain[0].HCloudUserName.ToString() + "'" + ",HCloudUserPsd='" + lsmain[0].HCloudUserPsd.ToString() + "'" + ",HUSEORGID=" + lsmain[0].HOrgID.ToString() + + ",HICNumber='" + lsmain[0].HICNumber + "'" + " where Czybm='" + lsmain[0].Czybm.ToString() + "'"); } else @@ -283,6 +307,7 @@ ",HSellMan='" + lsmain[0].HSellMan.ToString() + "'" + ",HDeptID=" + lsmain[0].HDeptID.ToString() + ",HDept='" + lsmain[0].HDept.ToString() + "'" + + ",HCheckEmpID=" + lsmain[0].HCheckEmpID.ToString() + ",HWhID=" + lsmain[0].HWhID.ToString() + ",HWHName='" + lsmain[0].HWHName.ToString() + "'" + ",HSCWHID=" + lsmain[0].HSCWHID.ToString() + @@ -291,10 +316,12 @@ ",HProcID=" + lsmain[0].HProcID.ToString() + ",HSourceID=" + lsmain[0].HSourceID.ToString() + ",HGroupID=" + lsmain[0].HGroupID.ToString() + + ",HWorkCenterID=" + lsmain[0].HWorkCenterID.ToString() + ",HSupName='" + lsmain[0].HSupName.ToString() + "'" + ",HCloudUserName='" + lsmain[0].HCloudUserName.ToString() + "'" + ",HCloudUserPsd='" + lsmain[0].HCloudUserPsd.ToString() + "'" + ",HUSEORGID=" + lsmain[0].HOrgID.ToString() + + ",HICNumber='" + lsmain[0].HICNumber + "'" + " where Czybm='" + lsmain[0].Czybm.ToString() + "'"); } @@ -723,6 +750,316 @@ objJsonResult.count = 0; objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); objJsonResult.data = 1; + return objJsonResult; + } + } + #endregion + + #region 鐢ㄦ埛鍏宠仈缁勭粐缁存姢鍒楄〃 + /// <summary> + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_User/UserRelationOrganizationList")] + [HttpGet] + public object UserRelationOrganizationList(string sWhere, string user) + { + try + { + List<object> columnNameList = new List<object>(); + //鏌ョ湅鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_Query", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + string sql = ""; + + + if (sWhere == null || sWhere.Equals("")) + { + sql = "select * from h_v_Gy_UserOrganizationRelationList_Query order by 鐢ㄦ埛浠g爜 asc,缁勭粐浠g爜 asc"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_UserOrganizationRelationList_Query"); + } + else + { + sql = "select * from h_v_Gy_UserOrganizationRelationList_Query where 1=1 "; + sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,缁勭粐浠g爜 asc"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_UserOrganizationRelationList_Query"); + } + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 鐢ㄦ埛鍏宠仈缁勭粐缁存姢 鍒犻櫎 + /// <summary> + ///鍙傛暟锛歴tring HInterID銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_User/UserRelationOrganizationlist_Drop")] + [HttpGet] + public object UserRelationOrganizationlist_Drop(string HInterID, string user) + { + try + { + string s = ""; + + //鏌ョ湅鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_Drop", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + if (HInterID == null || HInterID.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.BeginTran(); + + string sql = "delete from Gy_UserORGRelation where HItemID = " + HInterID; + oCN.RunProc(sql); + + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 鐢ㄦ埛鍏宠仈缁勭粐缁存姢 缂栬緫鍒濆鍖� + /// <summary> + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_User/UserRelationOrganizationList_EditInit")] + [HttpGet] + public object UserRelationOrganizationList_EditInit(int HItemID, string user) + { + try + { + List<object> columnNameList = new List<object>(); + //鏌ョ湅鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_Query", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + string sql = "select * from h_v_Gy_UserOrganizationRelationList_Query where HItemID = " + HItemID; + ds = oCN.RunProcReturn(sql, "h_v_Gy_UserOrganizationRelationList_Query"); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 鐢ㄦ埛鍏宠仈缁勭粐缁存姢 淇濆瓨 + [Route("Xt_User/UserRelationOrganizationList_Save")] + [HttpPost] + public object UserRelationOrganizationList_Save([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(); + string saveType = sArray[2].ToString(); + try + { + //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_Edit", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); + List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); + + foreach (JObject item in Excel) + { + Dictionary<string, string> dic = new Dictionary<string, string>(); + foreach (var itm in item.Properties()) + { + dic.Add(itm.Name, itm.Value.ToString()); + } + list.Add(dic); + } + + if (saveType == "1") + { + oCN.BeginTran(); + string err = ""; + int i = 1; + string sql = ""; + foreach (Dictionary<string, string> item in list) + { + string HItemID = item["HItemID"].ToString(); // + string HUserID = item["HUserID"].ToString(); //鐢ㄦ埛浠g爜 + string HUserName = item["HUserName"].ToString(); //鐢ㄦ埛鍚嶇О + string HOrgID = item["HOrgID"].ToString(); //缁勭粐鍐呯爜 + string HOrgNumber = item["HOrgNumber"].ToString(); //缁勭粐浠g爜 + string HOrgName = item["HOrgName"].ToString(); //缁勭粐鍚嶇О + + + sql = "select * from Gy_UserORGRelation where HUserID = '" + HUserID + "' and HOrgID = " + HOrgID; + ds = oCN.RunProcReturn(sql, "Gy_UserORGRelation"); + if (ds.Tables[0].Rows.Count == 0) + { + sql = "insert into Gy_UserORGRelation(HUserID,HOrgID)" + + "values(" + + "'" + HUserID + "'" + + "," + HOrgID + "" + + ")"; + oCN.RunProc(sql); + } + else + { + err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱旂粍缁囥��" + HOrgName + "銆�"; + } + i++; + } + //鍒ゆ柇鏄惁瀛樺湪閿欒 + if (err.Length > 0) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + err; + objJsonResult.data = null; + return objJsonResult; + } + } + else if (saveType == "3") + { + oCN.BeginTran(); + string err = ""; + int i = 1; + string sql = ""; + foreach (Dictionary<string, string> item in list) + { + string HItemID = item["HItemID"].ToString(); // + string HUserID = item["HUserID"].ToString(); //鐢ㄦ埛浠g爜 + string HUserName = item["HUserName"].ToString(); //鐢ㄦ埛鍚嶇О + string HOrgID = item["HOrgID"].ToString(); //缁勭粐鍐呯爜 + string HOrgNumber = item["HOrgNumber"].ToString(); //缁勭粐浠g爜 + string HOrgName = item["HOrgName"].ToString(); //缁勭粐鍚嶇О + + sql = "select * from Gy_UserORGRelation where HItemID = " + HItemID; + ds = oCN.RunProcReturn(sql, "Gy_UserORGRelation"); + if (ds.Tables[0].Rows.Count > 0) + { + sql = "select * from Gy_UserORGRelation where HUserID = '" + HUserID + "' and HOrgID = " + HOrgID + " and HItemID <> " + HItemID; + ds = oCN.RunProcReturn(sql, "Gy_UserORGRelation"); + if (ds.Tables[0].Rows.Count == 0) + { + sql = "update Gy_UserORGRelation set " + + "HUserID = '" + HUserID + "' " + + ",HOrgID = " + HOrgID + " " + + "where HItemID = " + HItemID; + oCN.RunProc(sql); + } + else + { + err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱旂粍缁囥��" + HOrgName + "銆�"; + } + } + else + { + err += "绗�" + i + "琛岋細璁板綍涓嶅瓨鍦�!"; + } + i++; + } + //鍒ゆ柇鏄惁瀛樺湪閿欒 + if (err.Length > 0) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + err; + objJsonResult.data = null; + return objJsonResult; + } + } + + oCN.Commit(); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛!"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + LogService.Write(e); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; return objJsonResult; } } @@ -1231,6 +1568,168 @@ objJsonResult.count = 0; objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); objJsonResult.data = 1; + return objJsonResult; + } + } + #endregion + + #region 鐢ㄦ埛鍏宠仈閮ㄩ棬鏌ヨ + /// <summary> + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_User/UserRelationDeptlist")] + [HttpGet] + public object UserRelationDeptlist(string sWhere, string user) + { + try + { + List<object> columnNameList = new List<object>(); + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationDept_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + string sql = ""; + + + if (sWhere == null || sWhere.Equals("")) + { + sql = "select * from h_v_Gy_UserDeptRelationList_Query order by 鐢ㄦ埛浠g爜 asc,閮ㄩ棬浠g爜 asc"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_UserDeptRelationList_Query"); + } + else + { + sql = "select * from h_v_Gy_UserDeptRelationList_Query where 1=1 "; + sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,閮ㄩ棬浠g爜 asc"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_UserDeptRelationList_Query"); + } + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 鐢ㄦ埛鍏宠仈閮ㄩ棬 鏍规嵁鐢ㄦ埛ID鏌ユ壘 + /// <summary> + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_User/UserRelationDeptlist_EditInit")] + [HttpGet] + public object UserRelationDeptlist_EditInit(int HItemID, string user) + { + try + { + List<object> columnNameList = new List<object>(); + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationDept_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + string sql = "select * from h_v_Gy_UserDeptRelationList_Query where HItemID = " + HItemID; + ds = oCN.RunProcReturn(sql, "h_v_Gy_UserDeptRelationList_Query"); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 鐢ㄦ埛鍏宠仈閮ㄩ棬 鍒犻櫎 + /// <summary> + ///鍙傛暟锛歴tring HInterID銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_User/UserRelationDeptlist_Drop")] + [HttpGet] + public object UserRelationDeptlist_Drop(string HInterID, string user) + { + try + { + string s = ""; + + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationDept_Drop", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (HInterID == null || HInterID.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.BeginTran(); + + string sql = "delete from Gy_UserDeptRelation where HItemID = " + HInterID; + oCN.RunProc(sql); + + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; return objJsonResult; } } @@ -1872,6 +2371,316 @@ catch (Exception e) { LogService.Write(e); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 鐢ㄦ埛鍏宠仈鑱屽憳缁存姢鍒楄〃 + /// <summary> + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_User/UserRelationEmployeelist")] + [HttpGet] + public object UserRelationEmployeelist(string sWhere, string user) + { + try + { + List<object> columnNameList = new List<object>(); + //鏌ョ湅鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_Query", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + string sql = ""; + + + if (sWhere == null || sWhere.Equals("")) + { + sql = "select * from h_v_Gy_UserEmployeeRelationList_Query order by 鐢ㄦ埛浠g爜 asc,鑱屽憳浠g爜 asc"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_UserEmployeeRelationList_Query"); + } + else + { + sql = "select * from h_v_Gy_UserEmployeeRelationList_Query where 1=1 "; + sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,鑱屽憳浠g爜 asc"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_UserEmployeeRelationList_Query"); + } + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 鐢ㄦ埛鍏宠仈鑱屽憳缁存姢 鍒犻櫎 + /// <summary> + ///鍙傛暟锛歴tring HInterID銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_User/UserRelationEmployeelist_Drop")] + [HttpGet] + public object UserRelationEmployeelist_Drop(string HInterID, string user) + { + try + { + string s = ""; + + //鏌ョ湅鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_Drop", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + if (HInterID == null || HInterID.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.BeginTran(); + + string sql = "delete from Gy_UserEmployeeRelation where HItemID = " + HInterID; + oCN.RunProc(sql); + + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 鐢ㄦ埛鍏宠仈鑱屽憳缁存姢 缂栬緫鍒濆鍖� + /// <summary> + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_User/UserRelationEmployeelist_EditInit")] + [HttpGet] + public object UserRelationEmployeelist_EditInit(int HItemID, string user) + { + try + { + List<object> columnNameList = new List<object>(); + //鏌ョ湅鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_Query", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + string sql = "select * from h_v_Gy_UserEmployeeRelationList_Query where HItemID = " + HItemID; + ds = oCN.RunProcReturn(sql, "h_v_Gy_UserEmployeeRelationList_Query"); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 鐢ㄦ埛鍏宠仈鑱屽憳缁存姢 淇濆瓨 + [Route("Xt_User/UserRelationEmployeelist_Save")] + [HttpPost] + public object UserRelationEmployeelist_Save([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(); + string saveType = sArray[2].ToString(); + try + { + //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_Edit", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); + List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); + + foreach (JObject item in Excel) + { + Dictionary<string, string> dic = new Dictionary<string, string>(); + foreach (var itm in item.Properties()) + { + dic.Add(itm.Name, itm.Value.ToString()); + } + list.Add(dic); + } + + if (saveType == "1") + { + oCN.BeginTran(); + string err = ""; + int i = 1; + string sql = ""; + foreach (Dictionary<string, string> item in list) + { + string HItemID = item["HItemID"].ToString(); // + string HUserID = item["HUserID"].ToString(); //鐢ㄦ埛浠g爜 + string HUserName = item["HUserName"].ToString(); //鐢ㄦ埛鍚嶇О + string HEmpID = item["HEmpID"].ToString(); //瀹㈡埛鍐呯爜 + string HEmpNumber = item["HEmpNumber"].ToString(); //瀹㈡埛浠g爜 + string HEmpName = item["HEmpName"].ToString(); //瀹㈡埛鍚嶇О + + + sql = "select * from Gy_UserEmployeeRelation where HUserID = '" + HUserID + "' and HEmployeeID = " + HEmpID; + ds = oCN.RunProcReturn(sql, "Gy_UserEmployeeRelation"); + if (ds.Tables[0].Rows.Count == 0) + { + sql = "insert into Gy_UserEmployeeRelation(HUserID,HEmployeeID)" + + "values(" + + "'" + HUserID + "'" + + "," + HEmpID + "" + + ")"; + oCN.RunProc(sql); + } + else + { + err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱旇亴鍛樸��" + HEmpName + "銆�"; + } + i++; + } + //鍒ゆ柇鏄惁瀛樺湪閿欒 + if (err.Length > 0) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + err; + objJsonResult.data = null; + return objJsonResult; + } + } + else if (saveType == "3") + { + oCN.BeginTran(); + string err = ""; + int i = 1; + string sql = ""; + foreach (Dictionary<string, string> item in list) + { + string HItemID = item["HItemID"].ToString(); // + string HUserID = item["HUserID"].ToString(); //鐢ㄦ埛浠g爜 + string HUserName = item["HUserName"].ToString(); //鐢ㄦ埛鍚嶇О + string HEmpID = item["HEmpID"].ToString(); //鑱屽憳鍐呯爜 + string HEmpNumber = item["HEmpNumber"].ToString(); //鑱屽憳浠g爜 + string HEmpName = item["HEmpName"].ToString(); //鑱屽憳鍚嶇О + + sql = "select * from Gy_UserEmployeeRelation where HItemID = " + HItemID; + ds = oCN.RunProcReturn(sql, "Gy_UserEmployeeRelation"); + if (ds.Tables[0].Rows.Count > 0) + { + sql = "select * from Gy_UserEmployeeRelation where HUserID = '" + HUserID + "' and HEmployeeID = " + HEmpID + " and HItemID <> " + HItemID; + ds = oCN.RunProcReturn(sql, "Gy_UserEmployeeRelation"); + if (ds.Tables[0].Rows.Count == 0) + { + sql = "update Gy_UserEmployeeRelation set " + + "HUserID = '" + HUserID + "' " + + ",HEmployeeID = " + HEmpID + " " + + "where HItemID = " + HItemID; + oCN.RunProc(sql); + } + else + { + err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱旇亴鍛樸��" + HEmpName + "銆�"; + } + } + else + { + err += "绗�" + i + "琛岋細璁板綍涓嶅瓨鍦�!"; + } + i++; + } + //鍒ゆ柇鏄惁瀛樺湪閿欒 + if (err.Length > 0) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + err; + objJsonResult.data = null; + return objJsonResult; + } + } + + oCN.Commit(); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛!"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + LogService.Write(e); + oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception锛�" + e.ToString(); @@ -2598,12 +3407,26 @@ } } - //鍒ゅ畾璇ョ敤鎴蜂笌瀹㈡埛鏄惁宸茬粡鍏宠仈 - sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; + //鍒ゅ畾瀹㈡埛鏄惁宸茬粡鍏宠仈鐢ㄦ埛 + sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + + " from Gy_UserCustomerRelation as a" + + " left join Gy_Czygl as b on a.HUserID = b.Czybm " + + " left join Gy_Customer as c on a.HCusID = c.HItemID " + + " where a.HCusID = " + HCusID; ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); - if (ds.Tables[0].Rows.Count > 0) + if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HUserID"].ToString()!= HUserID) { - err += "鐢ㄦ埛宸茬粡鍏宠仈璇ュ鎴凤紱"; + err += "鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆戯紱"; + } + else + { + //鍒ゅ畾璇ョ敤鎴蜂笌瀹㈡埛鏄惁宸茬粡鍏宠仈 + sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; + ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); + if (ds.Tables[0].Rows.Count > 0) + { + err += "鐢ㄦ埛宸茬粡鍏宠仈璇ュ鎴凤紱"; + } } tb2.Rows[i - 1]["鍒ゅ畾缁撴灉"] = err; @@ -2685,12 +3508,26 @@ ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); if (ds.Tables[0].Rows.Count == 0) { - sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + + sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + + " from Gy_UserCustomerRelation as a" + + " left join Gy_Czygl as b on a.HUserID = b.Czybm " + + " left join Gy_Customer as c on a.HCusID = c.HItemID " + + " where a.HCusID = " + HCusID; + ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); + if (ds.Tables[0].Rows.Count == 0) + { + sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + "values(" + "'" + HUserID + "'" + "," + HCusID + "" + ")"; - oCN.RunProc(sql); + oCN.RunProc(sql); + } + else + { + err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆�,瀹㈡埛涓嶅彲琚涓敤鎴峰叧鑱旓紒"; + } + i++; } else { @@ -2698,7 +3535,18 @@ } i++; } - }else if(saveType == "2") + //鍒ゆ柇鏄惁瀛樺湪閿欒 + if (err.Length > 0) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀵煎叆閿欒锛�" + err; + objJsonResult.data = null; + return objJsonResult; + } + } + else if(saveType == "2") { oCN.BeginTran(); string err = ""; @@ -2714,20 +3562,34 @@ string HOrgNumber = item["缁勭粐浠g爜"].ToString(); string HOrgName = item["缁勭粐鍚嶇О"].ToString(); - sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; + + sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + + " from Gy_UserCustomerRelation as a" + + " left join Gy_Czygl as b on a.HUserID = b.Czybm " + + " left join Gy_Customer as c on a.HCusID = c.HItemID " + + " where a.HCusID = " + HCusID; ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); - if (ds.Tables[0].Rows.Count == 0) + if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HUserID"].ToString()!=HUserID) { - sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + - "values(" + - "'" + HUserID + "'" + - "," + HCusID + "" + - ")"; - oCN.RunProc(sql); + err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆�,瀹㈡埛涓嶅彲琚涓敤鎴峰叧鑱旓紒"; } else { - err += "绗�" + i + "琛岋細鐢ㄦ埛宸茬粡鍏宠仈璇ュ鎴�!"; + sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; + ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); + if (ds.Tables[0].Rows.Count == 0) + { + sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + + "values(" + + "'" + HUserID + "'" + + "," + HCusID + "" + + ")"; + oCN.RunProc(sql); + } + else + { + err += "绗�" + i + "琛岋細鐢ㄦ埛宸茬粡鍏宠仈璇ュ鎴�!"; + } } i++; } @@ -2974,7 +3836,11 @@ string HCusName = item["HCusName"].ToString(); //瀹㈡埛鍚嶇О - sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; + sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + + " from Gy_UserCustomerRelation as a" + + " left join Gy_Czygl as b on a.HUserID = b.Czybm " + + " left join Gy_Customer as c on a.HCusID = c.HItemID " + + " where a.HCusID = " + HCusID; ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); if (ds.Tables[0].Rows.Count == 0) { @@ -2987,7 +3853,7 @@ } else { - err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱斿鎴枫��" + HCusName + "銆�"; + err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆�,瀹㈡埛涓嶅彲琚涓敤鎴峰叧鑱旓紒"; } i++; } @@ -3021,7 +3887,11 @@ ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); if (ds.Tables[0].Rows.Count > 0) { - sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID + " and HItemID <> " + HItemID; + sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + + " from Gy_UserCustomerRelation as a" + + " left join Gy_Czygl as b on a.HUserID = b.Czybm " + + " left join Gy_Customer as c on a.HCusID = c.HItemID " + + " where a.HCusID = " + HCusID + " and a.HItemID <> " + HItemID; ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); if(ds.Tables[0].Rows.Count == 0) { @@ -3033,7 +3903,7 @@ } else { - err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱斿鎴枫��" + HCusName + "銆�"; + err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆�,瀹㈡埛涓嶅彲琚涓敤鎴峰叧鑱旓紒"; } } else -- Gitblit v1.9.1