diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs index e25b59cb..fe0064cd 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs @@ -97,44 +97,44 @@ public class Ghre_CourseWareServices : BaseServices(sql); -// for (int i = 0; i < questionAnswers.Count; i++) -// { -// await Db.Deleteable(new Ghre_QuestionAnswer() { Id = questionAnswers[i].Id }).ExecuteCommandAsync(); -// sql = $@"UPDATE A -//SET A.TaxisNo = B.NUM -//FROM Ghre_QuestionAnswer A -// JOIN -// (SELECT ID, NUM * 100 NUM -// FROM (SELECT *, ROW_NUMBER () OVER (ORDER BY TaxisNo) NUM -// FROM (SELECT * -// FROM (SELECT * -// FROM Ghre_QuestionAnswer -// WHERE QuestionId = '{questionAnswers[i].QuestionId}') A) B) C) B -// ON A.ID = b.ID; - - - -//UPDATE Ghre_QuestionAnswer -//SET QuestionNo = -// CASE TaxisNo -// WHEN 100 THEN 'A' -// WHEN 200 THEN 'B' -// WHEN 300 THEN 'C' -// WHEN 400 THEN 'D' -// WHEN 500 THEN 'E' -// WHEN 600 THEN 'F' -// WHEN 700 THEN 'G' -// WHEN 800 THEN 'H' -// WHEN 900 THEN 'I' -// WHEN 1000 THEN 'J' -// WHEN 1100 THEN 'K' -// WHEN 1200 THEN 'L' -// END -//WHERE QuestionId = '{questionAnswers[i].QuestionId}'"; -// await Db.Ado.SqlQueryAsync(sql); -// } + // string sql = "SELECT Id,QuestionId from Ghre_QuestionAnswer where AnswerContent='单选题'"; + // var questionAnswers = await Db.Ado.SqlQueryAsync(sql); + // for (int i = 0; i < questionAnswers.Count; i++) + // { + // await Db.Deleteable(new Ghre_QuestionAnswer() { Id = questionAnswers[i].Id }).ExecuteCommandAsync(); + // sql = $@"UPDATE A + //SET A.TaxisNo = B.NUM + //FROM Ghre_QuestionAnswer A + // JOIN + // (SELECT ID, NUM * 100 NUM + // FROM (SELECT *, ROW_NUMBER () OVER (ORDER BY TaxisNo) NUM + // FROM (SELECT * + // FROM (SELECT * + // FROM Ghre_QuestionAnswer + // WHERE QuestionId = '{questionAnswers[i].QuestionId}') A) B) C) B + // ON A.ID = b.ID; + + + + //UPDATE Ghre_QuestionAnswer + //SET QuestionNo = + // CASE TaxisNo + // WHEN 100 THEN 'A' + // WHEN 200 THEN 'B' + // WHEN 300 THEN 'C' + // WHEN 400 THEN 'D' + // WHEN 500 THEN 'E' + // WHEN 600 THEN 'F' + // WHEN 700 THEN 'G' + // WHEN 800 THEN 'H' + // WHEN 900 THEN 'I' + // WHEN 1000 THEN 'J' + // WHEN 1100 THEN 'K' + // WHEN 1200 THEN 'L' + // END + //WHERE QuestionId = '{questionAnswers[i].QuestionId}'"; + // await Db.Ado.SqlQueryAsync(sql); + // } return result; @@ -237,4 +237,37 @@ public class Ghre_CourseWareServices : BaseServices + /// 删除指定ID的数据 + /// + /// 主键ID + /// + public override async Task DeleteById1(object id) + { + + if (await Db.Queryable().AnyAsync(x => x.CourseWareId == (long)id)) + throw new Exception($"该课件已与课程关联,暂不可删除!"); + + return await base.DeleteById1(id); + } + + /// + /// 删除指定ID集合的数据(批量删除) + /// + /// 主键ID集合 + /// + public override async Task DeleteByIds1(long[] ids) + { + + foreach (var id in ids) + { + if (await Db.Queryable().AnyAsync(x => x.CourseWareId == (long)id)) + throw new Exception($"课件已与课程关联,暂不可删除!"); + } + + return await base.DeleteByIds1(ids); + } + #endregion } \ No newline at end of file