/// <summary> /// 新增地域 /// </summary> /// <param name="data"></param> /// <param name="user_id"></param> /// <returns></returns> public ERROR_CODE SaveTerritory(d_general data, long user_id, ref int id) { var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } if (id > 0) { var res = new GeneralBLL().GetSingleGeneral(data.name, data.general_table_id); if (res != null && res.id != data.id) { return(ERROR_CODE.EXIST); } var old = new GeneralBLL().GetSingleGeneral(data.id); data.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); data.update_user_id = user_id; if (!_dal.Update(data)) { return(ERROR_CODE.ERROR); } var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, // oper_object_id = data.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.CompareValue(old, data), remark = "修改地域信息" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 } else { data.general_table_id = (int)GeneralTableEnum.TERRITORY; data.create_time = data.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); data.create_user_id = user_id; //唯一性校验 var res = new GeneralBLL().GetSingleGeneral(data.name, data.general_table_id); if (res != null) { return(ERROR_CODE.EXIST); } _dal.Insert(data); var re = _dal.FindSignleBySql <d_general>($"select * from d_general where name='{data.name}'"); if (re != null) { id = re.id; } var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, oper_object_id = data.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(data), remark = "新增地域信息" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 } return(ERROR_CODE.SUCCESS); }
/// <summary> /// 新增配置项类型 /// </summary> /// <param name="data"></param> /// <param name="group"></param> /// <param name="user_id"></param> /// <returns></returns> public ERROR_CODE InsertConfigType(d_general data, List <ConfigUserDefinedFieldDto> group, long user_id) { int groupid;//自定义分组id var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } //新增自定义字段组47 //groupid=data.id=(int)(_dal.GetNextIdCom()); data.parent_id = (int)DicEnum.UDF_CATE.CONFIGURATION_ITEMS; data.general_table_id = (int)GeneralTableEnum.UDF_FILED_GROUP; var res = new GeneralBLL().GetSingleGeneral(data.name, data.general_table_id); if (res != null) { return(ERROR_CODE.EXIST); } data.create_time = data.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); data.create_user_id = data.update_user_id = user_id; _dal.Insert(data); var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, // oper_object_id = data.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(data), remark = "新增自定义字段组47" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 var k = _dal.FindSignleBySql <d_general>($"select * from d_general where name={data.name} and general_table_id={data.general_table_id} and delete_time=0"); if (k == null) { return(ERROR_CODE.ERROR); } else { groupid = k.id; } //新增配置项类型(table=108) data.ext1 = groupid.ToString(); data.general_table_id = (int)GeneralTableEnum.INSTALLED_PRODUCT_CATE; var res2 = new GeneralBLL().GetSingleGeneral(data.name, data.general_table_id); if (res2 != null) { return(ERROR_CODE.EXIST); } _dal.Insert(data); var add1_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, // oper_object_id = data.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(data), remark = "新增配置项类型" }; // 创建日志 new sys_oper_log_dal().Insert(add1_log); // 插入日志 //自定义字段组 sys_udf_group_field groupfield = new sys_udf_group_field(); groupfield.create_time = groupfield.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); groupfield.create_user_id = groupfield.update_user_id = user.id; groupfield.group_id = groupid; foreach (var t in group) { if (t.id != 0) { groupfield.udf_field_id = t.id; groupfield.is_required = t.is_required; groupfield.sort_order = t.sort_order; udf_group_dal.Insert(groupfield); var add2_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, // oper_object_id = groupfield.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(groupfield), remark = "新增自定义字段组" }; // 创建日志 new sys_oper_log_dal().Insert(add2_log); // 插入日志 } } return(ERROR_CODE.SUCCESS); }