/// <summary> /// 新增员工和地域之间的关联记录 /// </summary> /// <param name="cat"></param> /// <param name="user_id"></param> /// <returns></returns> public ERROR_CODE Insert(sys_resource_territory cat, long user_id) { cat.id = (int)_dal.GetNextIdCom(); //不得插入重复数据 var kk = new sys_resource_territory_dal().FindSignleBySql <sys_resource_territory>($"select * from sys_resource_territory where territory_id={cat.territory_id} and resource_id={cat.resource_id} and delete_time=0"); if (kk != null) { return(ERROR_CODE.EXIST); } new sys_resource_territory_dal().Insert(cat); return(ERROR_CODE.SUCCESS); }
/// <summary> /// 删除sys_resource_territory中的员工和地域的关系 /// </summary> /// <param name="aid"></param> /// <param name="tid"></param> /// <returns></returns> public bool DeleteAccount_Territory(long aid, long tid, long user_id) { var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(false); } sys_resource_territory_dal cat_dal = new sys_resource_territory_dal(); var i = cat_dal.FindSignleBySql <sys_resource_territory>($"select * from sys_resource_territory where resource_id={aid} and territory_id={tid} and delete_time=0"); if (i != null) { i.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); i.delete_user_id = user_id; if (cat_dal.Update(i)) { 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.RESOURCE, //员工 oper_object_id = i.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.DELETE, oper_description = cat_dal.AddValue(i), remark = "删除地域与员工的关联" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 return(true); } } return(false); }