/// <summary> /// 批量删除 /// </summary> /// <param name="idList"></param> /// <returns></returns> public bool DeleteList(List <int> idList, int actType, int isDeleted) { Type type = typeof(T); List <CommandInfo> comList = new List <CommandInfo>(); foreach (int id in idList) { string strWhere = $"[{type.GetPrimary()}]=@Id"; string delSql = ""; if (actType == 1) { delSql = CreateSql.CreateDeleteSql <T>(strWhere); } else { delSql = $"update [{type.GetTName()}] set IsDeleted={isDeleted} where {strWhere}"; } SqlParameter[] paras = { new SqlParameter("@Id", id) }; CommandInfo com = new CommandInfo(delSql, false, paras); comList.Add(com); } return(SqlHelper.ExecuteTrans(comList)); }
/// <summary> /// 修改工具组数据的删除状态 /// </summary> /// <param name="tgIds"></param> /// <param name="delType"></param> /// <param name="isDeleted"></param> /// <returns></returns> public bool UpdateToolGroupDeleteState(List <int> tgIds, int delType, int isDeleted) { string delSql = ""; string ids = string.Join(",", tgIds); string strWhere = $" and TGroupId in ({ids})"; if (delType == 0) { delSql = CreateSql.CreateLogicDeleteSql <ToolGroupInfoModel>(strWhere, isDeleted); } else if (delType == 1) { delSql = CreateSql.CreateDeleteSql <ToolGroupInfoModel>(strWhere); } List <string> list = new List <string>(); list.Add(delSql); return(SqlHelper.ExecuteTrans(list)); }
/// <summary> /// 按条件删除数据(假删除,包含可以恢复) /// </summary> /// <param name="strWhere">条件</param> /// <param name="paras">参数列表</param> /// <returns></returns> public bool Delete(int actType, string strWhere, int isDeleted, SqlParameter[] paras) { Type type = typeof(T); string delSql = ""; if (actType == 1) { delSql = CreateSql.CreateDeleteSql <T>(strWhere); } else { delSql = $"update [{type.GetTName()}] set IsDeleted={isDeleted} where {strWhere}"; } List <CommandInfo> list = new List <CommandInfo>(); list.Add(new CommandInfo() { CommandText = delSql, IsProc = false, Paras = paras }); return(SqlHelper.ExecuteTrans(list)); }