| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 用户关联仓库列表查询 |
| | | [Route("Xt_User/Gy_UserStockRelationList")] |
| | | [HttpGet] |
| | | public object Gy_UserStockRelationList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserStockRelation_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | string sql1 = "select * from h_v_Gy_UserStockRelation where 1 = 1"; |
| | | string sql = sql1 + sWhere + " order by 用户代码 "; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserStockRelation"); |
| | | |
| | | //添加列名 |
| | | 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));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | 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> |
| | | ///参数:string HInterID。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Xt_User/Gy_UserStockRelationDrop")] |
| | | [HttpGet] |
| | | public object Gy_UserStockRelationDrop(string HItemID, string user) |
| | | { |
| | | try |
| | | { |
| | | |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserStockRelation_Drop", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无删除权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (HItemID == null || HItemID.Equals("")) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HItemID不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | |
| | | string sql = "delete from Gy_UserStockRelation where HItemID = " + HItemID; |
| | | oCN.RunProc(sql); |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 用户关联仓库保存 |
| | | [Route("Xt_User/SaveUserStock")] |
| | | [HttpPost] |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 用户关联物料列表查询 |
| | | [Route("Xt_User/Gy_UserMaterList")] |
| | | [HttpGet] |
| | | public object Gy_UserMaterList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserMaterList_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | string sql1 = "select * from h_v_Gy_UserMater where 1 = 1"; |
| | | string sql = sql1 + sWhere + " order by 用户代码 "; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserMater"); |
| | | |
| | | //添加列名 |
| | | 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));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | 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> |
| | | ///参数:string HInterID。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Xt_User/Gy_UserMaterRelationDrop")] |
| | | [HttpGet] |
| | | public object Gy_UserMaterRelationDrop(string HItemID, string user) |
| | | { |
| | | try |
| | | { |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserMaterList_Drop", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无删除权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (HItemID == null || HItemID.Equals("")) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HItemID不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | |
| | | string sql = "delete from Gy_UserMaterRelation where HItemID = " + HItemID; |
| | | oCN.RunProc(sql); |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 用户关联物料保存 |
| | | [Route("Xt_User/SaveUserMater")] |
| | | [HttpPost] |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | #region 用户关联客户 文件上传 |
| | | [Route("Xt_User/Gy_UserCustomer_ImportByExcel")] |
| | | [HttpPost] |
| | | public object Gy_UserCustomer_ImportByExcel() |
| | | { |
| | | try |
| | | { |
| | | //var WorkBookName = HttpContext.Current.Request["WorkBookName"]; |
| | | //DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]); |
| | | //获取文件名称 |
| | | 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("HCusID", typeof(Int32));//组织ID |
| | | tb2.Columns.Add("HUserID", typeof(Int32));//供应商 |
| | | |
| | | //添加数据 |
| | | 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); |
| | | } |
| | | |
| | | //查询Excel文件中没有的列 |
| | | var error = ""; |
| | | if (!tb2.Columns.Contains("客户代码")) |
| | | { |
| | | error += "没有找到【客户代码】的标题,"; |
| | | } |
| | | if (!tb2.Columns.Contains("客户名称")) |
| | | { |
| | | error += "没有找到【客户名称】的标题,"; |
| | | } |
| | | if (!tb2.Columns.Contains("用户名称")) |
| | | { |
| | | error += "没有找到【用户名称】的标题,"; |
| | | } |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //查询数据赋给数据表 |
| | | string err = ""; |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HCusNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户代码"].ToString()); |
| | | string HCusName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户名称"].ToString()); |
| | | string HUserName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["用户名称"].ToString()); |
| | | int index = i + 1; |
| | | string sql = ""; |
| | | if (HCusNumber != "" && HUserName != "") |
| | | { |
| | | //获取客户内码 |
| | | sql = "select * from Gy_Customer where HNumber = '" + HCusNumber + "'"; |
| | | string HCusID = "0"; |
| | | ds = oCN.RunProcReturn(sql, "Gy_Customer"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | err += "第" + index + "行,客户不存在!"; |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HCusID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | HCusID = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | //获取用户内码 |
| | | sql = "select * from Gy_Czygl where Czymc = '" + HUserName + "'"; |
| | | string HUserID = ""; |
| | | ds = oCN.RunProcReturn(sql, "Gy_Czygl"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | err += "第" + index + "行,用户不存在!"; |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HUserID"] = ds.Tables[0].Rows[0]["Czybm"].ToString(); |
| | | HUserID = ds.Tables[0].Rows[0]["Czybm"].ToString(); |
| | | } |
| | | |
| | | //判断表中是否已经存在该用户关联客户 |
| | | sql = "select * from Gy_UserCustomerRelation where HCusID = " + HCusID + " and HUserID = '" + HUserID + "'"; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | err += "第" + index + "行,该用户与客户已经关联!"; |
| | | continue; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | err += "第" + index + "行,客户代码或用户名称为空!"; |
| | | continue; |
| | | } |
| | | } |
| | | if (err.Length > 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "导入错误:" + err; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | 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/Gy_UserCustomer_ImportByExcel_Save")] |
| | | [HttpPost] |
| | | public object Gy_UserCustomer_ImportByExcel_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(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无导入权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | string err = ""; |
| | | int i = 1; |
| | | string sql = ""; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HUserID = item["HUserID"].ToString();//供应商 |
| | | string HUserName = item["用户名称"].ToString();//物料ID |
| | | string HCusID = item["HCusID"].ToString();//组织ID |
| | | string HCusNumber = item["客户代码"].ToString(); |
| | | string HCusName = item["客户名称"].ToString(); |
| | | |
| | | 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++; |
| | | } |
| | | //判断是否存在错误 |
| | | 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; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 用户关联客户保存 |
| | | [Route("Xt_User/SaveUserCustomer")] |
| | | [HttpPost] |
| | |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + e.ToString(); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 用户关联客户 文件上传 |
| | | [Route("Xt_User/Gy_UserCustomer_ImportByExcel")] |
| | | [HttpPost] |
| | | public object Gy_UserCustomer_ImportByExcel() |
| | | { |
| | | try |
| | | { |
| | | //var WorkBookName = HttpContext.Current.Request["WorkBookName"]; |
| | | //DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]); |
| | | //获取文件名称 |
| | | 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("客户内码", typeof(string));//客户内码 |
| | | tb2.Columns.Add("判定结果", typeof(string));//判定结果 |
| | | |
| | | //添加数据 |
| | | 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); |
| | | } |
| | | |
| | | //查询Excel文件中没有的列 |
| | | var error = ""; |
| | | if (!tb2.Columns.Contains("用户代码")) |
| | | { |
| | | error += "没有找到【用户代码】的标题,"; |
| | | } |
| | | if (!tb2.Columns.Contains("用户名称")) |
| | | { |
| | | error += "没有找到【用户名称】的标题,"; |
| | | } |
| | | if (!tb2.Columns.Contains("客户代码")) |
| | | { |
| | | error += "没有找到【客户代码】的标题,"; |
| | | } |
| | | if (!tb2.Columns.Contains("客户名称")) |
| | | { |
| | | error += "没有找到【客户名称】的标题,"; |
| | | } |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | { |
| | | error += "没有找到【组织代码】的标题,"; |
| | | } |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | { |
| | | error += "没有找到【组织名称】的标题,"; |
| | | } |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //查询数据赋给数据表 |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HUserID = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["用户代码"].ToString()); |
| | | string HUserName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["用户名称"].ToString()); |
| | | string HCusNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户代码"].ToString()); |
| | | string HCusName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户名称"].ToString()); |
| | | string HOrgNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | string HOrgName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | int index = i + 1; |
| | | //string sql = ""; |
| | | |
| | | ////判定用户是否存在并设置数据 |
| | | //sql = "select * from Gy_Czygl where Czybm = '" + HUserID + "'"; |
| | | //ds = oCN.RunProcReturn(sql, "Gy_Czygl"); |
| | | //if (ds.Tables[0].Rows.Count > 0) |
| | | //{ |
| | | // tb2.Rows[i]["用户名称"] = ds.Tables[0].Rows[0]["Czymc"]; |
| | | //} |
| | | //else |
| | | //{ |
| | | // sql = "select * from Gy_Czygl where Czymc = '" + HUserName + "'"; |
| | | // ds = oCN.RunProcReturn(sql, "Gy_Czygl"); |
| | | // if (ds.Tables[0].Rows.Count > 0) |
| | | // { |
| | | // tb2.Rows[i]["用户代码"] = ds.Tables[0].Rows[0]["Czybm"]; |
| | | // } |
| | | //} |
| | | |
| | | ////判定客户是否存在并设置数据 |
| | | //sql = "select c.HItemID 客户内码,c.HNumber 客户代码,c.HName 客户名称,isnull(c.HUSEORGID,0) 组织内码,isnull(o.HNumber,'') 组织代码,isnull(o.Hname,'') 组织名称 from " + |
| | | // "Gy_Customer as c " + |
| | | // "left join Xt_ORGANIZATIONS o on c.HUSEORGID = o.HItemID " + |
| | | // "where " + |
| | | // "c.HNumber = '" + HCusNumber + "' " + |
| | | // "and isnull(o.HNumber,'')<>'' and isnull(o.HNumber,'') = '" + HOrgNumber + "'"; |
| | | //ds = oCN.RunProcReturn(sql, "Gy_Customer"); |
| | | //if(ds.Tables[0].Rows.Count > 0) |
| | | //{ |
| | | // tb2.Rows[i]["客户内码"] = ds.Tables[0].Rows[0]["客户内码"]; |
| | | // tb2.Rows[i]["客户名称"] = ds.Tables[0].Rows[0]["客户名称"]; |
| | | // tb2.Rows[i]["组织名称"] = ds.Tables[0].Rows[0]["组织名称"]; |
| | | //} |
| | | //else |
| | | //{ |
| | | // sql = "select c.HItemID 客户内码,c.HNumber 客户代码,c.HName 客户名称,isnull(c.HUSEORGID,0) 组织内码,isnull(o.HNumber,'') 组织代码,isnull(o.Hname,'') 组织名称 from " + |
| | | // "Gy_Customer as c " + |
| | | // "left join Xt_ORGANIZATIONS o on c.HUSEORGID = o.HItemID " + |
| | | // "where " + |
| | | // "c.HNumber = '" + HCusNumber + "' " + |
| | | // "and isnull(o.HName,'')<>'' and isnull(o.HName,'') = '" + HOrgName + "'"; |
| | | // ds = oCN.RunProcReturn(sql, "Gy_Customer"); |
| | | // if (ds.Tables[0].Rows.Count > 0) |
| | | // { |
| | | // tb2.Rows[i]["客户内码"] = ds.Tables[0].Rows[0]["客户内码"]; |
| | | // tb2.Rows[i]["客户名称"] = ds.Tables[0].Rows[0]["客户名称"]; |
| | | // tb2.Rows[i]["组织代码"] = ds.Tables[0].Rows[0]["组织代码"]; |
| | | // } |
| | | //} |
| | | |
| | | tb2.Rows[i]["判定结果"] = ""; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | 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/Gy_UserCustomer_ImportByExcel_Confirm")] |
| | | [HttpPost] |
| | | public object Gy_UserCustomer_ImportByExcel_Confirm([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[] importFieldList = sArray[2].ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | try |
| | | { |
| | | 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); |
| | | } |
| | | |
| | | //创建临时表并设置列名 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | tb2.Columns.Add("用户代码", typeof(string)); |
| | | tb2.Columns.Add("用户名称", typeof(string)); |
| | | tb2.Columns.Add("客户内码", typeof(string)); |
| | | tb2.Columns.Add("客户代码", typeof(string)); |
| | | tb2.Columns.Add("客户名称", typeof(string)); |
| | | tb2.Columns.Add("组织代码", typeof(string)); |
| | | tb2.Columns.Add("组织名称", typeof(string)); |
| | | tb2.Columns.Add("判定结果", typeof(string)); |
| | | |
| | | string error = ""; |
| | | int i = 1; |
| | | string sql = ""; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | //记录判定结果 |
| | | string err = ""; |
| | | |
| | | DataRow row = tb2.NewRow(); |
| | | tb2.Rows.Add(row); |
| | | string HUserID = item["用户代码"].ToString(); |
| | | string HUserName = item["用户名称"].ToString(); |
| | | string HCusID = item["客户内码"].ToString(); |
| | | string HCusNumber = item["客户代码"].ToString(); |
| | | string HCusName = item["客户名称"].ToString(); |
| | | string HOrgNumber = item["组织代码"].ToString(); |
| | | string HOrgName = item["组织名称"].ToString(); |
| | | |
| | | tb2.Rows[i - 1]["用户代码"] = HUserID; |
| | | tb2.Rows[i - 1]["用户名称"] = HUserName; |
| | | tb2.Rows[i - 1]["客户内码"] = HCusID; |
| | | tb2.Rows[i - 1]["客户代码"] = HCusNumber; |
| | | tb2.Rows[i - 1]["客户名称"] = HCusName; |
| | | tb2.Rows[i - 1]["组织代码"] = HOrgNumber; |
| | | tb2.Rows[i - 1]["组织名称"] = HOrgName; |
| | | tb2.Rows[i - 1]["判定结果"] = ""; |
| | | |
| | | //根据导入字段获取用户相关数据,并进行校验 |
| | | sql = ""; |
| | | if (importFieldList[0] == "HUserID") |
| | | { |
| | | sql = "select * from Gy_Czygl where Czybm = '" + HUserID + "'"; |
| | | } |
| | | else if(importFieldList[0] == "HUserName") |
| | | { |
| | | sql = "select * from Gy_Czygl where Czymc = '" + HUserName + "'"; |
| | | } |
| | | ds = oCN.RunProcReturn(sql, "Gy_Czygl"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | err += "用户不存在;"; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i - 1]["用户代码"] = ds.Tables[0].Rows[0]["Czybm"]; |
| | | tb2.Rows[i - 1]["用户名称"] = ds.Tables[0].Rows[0]["Czymc"]; |
| | | |
| | | HUserID = ds.Tables[0].Rows[0]["Czybm"].ToString(); |
| | | HUserName = ds.Tables[0].Rows[0]["Czymc"].ToString(); |
| | | } |
| | | |
| | | //根据导入字段获取客户相关数据,并进行校验 |
| | | sql = ""; |
| | | if (importFieldList[1] == "HOrgNumber") |
| | | { |
| | | sql = "select * from Xt_ORGANIZATIONS where HNumber = '" + HOrgNumber + "'"; |
| | | } |
| | | else if (importFieldList[1] == "HOrgName") |
| | | { |
| | | sql = "select * from Xt_ORGANIZATIONS where HName = '" + HOrgName + "'"; |
| | | } |
| | | ds = oCN.RunProcReturn(sql, "Xt_ORGANIZATIONS"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | err += "组织不存在;"; |
| | | |
| | | HCusID = "0"; |
| | | tb2.Rows[i - 1]["客户内码"] = "0"; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i - 1]["组织代码"] = ds.Tables[0].Rows[0]["HNumber"]; |
| | | tb2.Rows[i - 1]["组织名称"] = ds.Tables[0].Rows[0]["HName"]; |
| | | |
| | | sql = "select c.* from " + |
| | | "Gy_Customer as c " + |
| | | "left join Xt_ORGANIZATIONS o on c.HUSEORGID = o.HItemID " + |
| | | "where c.HNumber = '" + HCusNumber + "' " + |
| | | "and o.HNumber = '" + ds.Tables[0].Rows[0]["HNumber"] + "' " + |
| | | "and o.HName = '" + ds.Tables[0].Rows[0]["HName"] + "'"; |
| | | ds = oCN.RunProcReturn(sql, "Gy_Customer"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | err += "该组织下客户不存在;"; |
| | | HCusID = "0"; |
| | | tb2.Rows[i - 1]["客户内码"] = "0"; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i - 1]["客户内码"] = ds.Tables[0].Rows[0]["HItemID"]; |
| | | tb2.Rows[i - 1]["客户代码"] = ds.Tables[0].Rows[0]["HNumber"]; |
| | | tb2.Rows[i - 1]["客户名称"] = ds.Tables[0].Rows[0]["HName"]; |
| | | |
| | | HCusID = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | |
| | | //判定该用户与客户是否已经关联 |
| | | 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; |
| | | error += err; |
| | | |
| | | i++; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = (error.Length>0?"0":"1"); |
| | | objJsonResult.data = tb2; |
| | | 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; |
| | | } |
| | | } |
| | | #endregion |
| | | #region 用户关联客户 导入(保存) |
| | | [Route("Xt_User/Gy_UserCustomer_ImportByExcel_Save")] |
| | | [HttpPost] |
| | | public object Gy_UserCustomer_ImportByExcel_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_UserRelationCustomer_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 HUserID = item["用户代码"].ToString();//供应商 |
| | | string HUserName = item["用户名称"].ToString();//物料ID |
| | | string HCusID = item["客户内码"].ToString();//组织ID |
| | | string HCusNumber = item["客户代码"].ToString(); |
| | | string HCusName = item["客户名称"].ToString(); |
| | | string HOrgNumber = item["组织代码"].ToString(); |
| | | string HOrgName = item["组织名称"].ToString(); |
| | | |
| | | 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 |
| | | { |
| | | |
| | | } |
| | | i++; |
| | | } |
| | | }else if(saveType == "2") |
| | | { |
| | | oCN.BeginTran(); |
| | | string err = ""; |
| | | int i = 1; |
| | | string sql = ""; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HUserID = item["用户代码"].ToString();//供应商 |
| | | string HUserName = item["用户名称"].ToString();//物料ID |
| | | string HCusID = item["客户内码"].ToString();//组织ID |
| | | string HCusNumber = item["客户代码"].ToString(); |
| | | string HCusName = item["客户名称"].ToString(); |
| | | string HOrgNumber = item["组织代码"].ToString(); |
| | | string HOrgName = item["组织名称"].ToString(); |
| | | |
| | | 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++; |
| | | } |
| | | //判断是否存在错误 |
| | | 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; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 用户关联客户维护列表 |
| | | /// <summary> |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Xt_User/UserRelationCustomerlist")] |
| | | [HttpGet] |
| | | public object UserRelationCustomerlist(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_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_UserCustomerRelationList_Query order by 用户代码 asc,客户代码 asc"; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | } |
| | | else |
| | | { |
| | | sql = "select * from h_v_Gy_UserCustomerRelationList_Query where 1=1 "; |
| | | sql = sql + sWhere + " order by 用户代码 asc,客户代码 asc"; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | 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> |
| | | ///参数:string HInterID。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Xt_User/UserRelationCustomerlist_Drop")] |
| | | [HttpGet] |
| | | public object UserRelationCustomerlist_Drop(string HInterID, string user) |
| | | { |
| | | try |
| | | { |
| | | string s = ""; |
| | | |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_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_UserCustomerRelation 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> |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Xt_User/UserRelationCustomerlist_EditInit")] |
| | | [HttpGet] |
| | | public object UserRelationCustomerlist_EditInit(int HItemID, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | string sql = "select * from h_v_Gy_UserCustomerRelationList_Query where HItemID = " + HItemID; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserCustomerRelationList_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/UserRelationCustomerlist_Save")] |
| | | [HttpPost] |
| | | public object UserRelationCustomerlist_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_UserRelationCustomer_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(); //用户代码 |
| | | string HUserName = item["HUserName"].ToString(); //用户名称 |
| | | string HCusID = item["HCusID"].ToString(); //客户内码 |
| | | string HCusNumber = item["HCusNumber"].ToString(); //客户代码 |
| | | string HCusName = item["HCusName"].ToString(); //客户名称 |
| | | |
| | | |
| | | 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 + "行:用户【" + HUserName + "】已经关联客户【" + HCusName + "】"; |
| | | } |
| | | 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(); //用户代码 |
| | | string HUserName = item["HUserName"].ToString(); //用户名称 |
| | | string HCusID = item["HCusID"].ToString(); //客户内码 |
| | | string HCusNumber = item["HCusNumber"].ToString(); //客户代码 |
| | | string HCusName = item["HCusName"].ToString(); //客户名称 |
| | | |
| | | sql = "select * from Gy_UserCustomerRelation where HItemID = " + HItemID; |
| | | 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; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if(ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | sql = "update Gy_UserCustomerRelation set " + |
| | | "HUserID = '" + HUserID + "' " + |
| | | ",HCusID = " + HCusID + " " + |
| | | "where HItemID = " + HItemID; |
| | | oCN.RunProc(sql); |
| | | } |
| | | else |
| | | { |
| | | err += "第" + i + "行:用户【" + HUserName + "】已经关联客户【" + HCusName + "】"; |
| | | } |
| | | } |
| | | 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; |
| | | } |
| | | } |
| | |
| | | string HProcID = item["HProcID"].ToString();//工序ID |
| | | string HUserID = item["用户代码"].ToString();//用户代码 |
| | | string czymc = item["用户名称"].ToString();//用户名称 |
| | | string HNumber = item["工序代码"].ToString();//供应商代码 |
| | | string HName = item["工序名称"].ToString();//供应商名称 |
| | | string HNumber = item["工序代码"].ToString();//工序代码 |
| | | string HName = item["工序名称"].ToString();//工序名称 |
| | | |
| | | var ds = oCN.RunProcReturn("select * from Gy_UserByProcess where HProcID='" + HProcID + "'and HUserID='" + HUserID + "'", "Gy_UserByProcess"); |
| | | |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 用户关联工序列表查询 |
| | | [Route("Xt_User/UserProcesslist")] |
| | | [HttpGet] |
| | | public object UserProcesslist(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserProcessList_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | string sql1 = "select * from h_v_Gy_UserProcess where 1 = 1"; |
| | | string sql = sql1 + sWhere + " order by 用户代码 "; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserProcess"); |
| | | |
| | | //添加列名 |
| | | 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));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | 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> |
| | | ///参数:string HInterID。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Xt_User/Gy_UserProcessDrop")] |
| | | [HttpGet] |
| | | public object Gy_UserProcessDrop(string HItemID, string user) |
| | | { |
| | | try |
| | | { |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_UserProcessList_Drop", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无删除权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | if (HItemID == null || HItemID.Equals("")) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HInterID不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | |
| | | string sql = "delete from Gy_UserByProcess where HItemID = " + HItemID; |
| | | oCN.RunProc(sql); |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |