public static ScoreManageInfo ScoreManageInfo_Add(ScoreManageInfo model) { try { using (var conn = DbHelper.CCService()) { var p = new DynamicParameters(); p.Add("@output", dbType: DbType.Int32, direction: ParameterDirection.Output); p.Add("@OCID", model.OCID); p.Add("@UserID", model.UserID); p.Add("@UserName", model.UserName); p.Add("@CourseID", model.CourseID); p.Add("@StartDate", model.StartDate); p.Add("@EndDate", model.EndDate); p.Add("@Name", model.Name); p.Add("@ScoreTypeID", model.ScoreTypeID); conn.Execute("Score_Test_ADD", p, commandType: CommandType.StoredProcedure); model.TestID = p.Get<int>("output"); return model; } } catch (Exception e) { return null; } }
/// <summary> /// 成绩管理列表 /// </summary> /// <param name="smi"></param> /// <returns></returns> public static List<ScoreManageInfo> ScoreManageInfo_List(ScoreManageInfo smi, int DateID, int PageIndex = 1, int PageSize = 20) { try { using (var conn = DbHelper.CCService()) { var p = new DynamicParameters(); p.Add("@OCID", smi.OCID); p.Add("@UserID", smi.UserID); p.Add("@Name", smi.Name); p.Add("@DateSpan", DateID); p.Add("@ScoreTypeID", smi.ScoreTypeID); p.Add("@PageIndex", PageIndex); p.Add("@PageSize", PageSize); var multi = conn.QueryMultiple("Score_Test_List", p, commandType: CommandType.StoredProcedure); var items = multi.Read<ScoreManageInfo>().ToList(); var testStudents = multi.Read<TestStudent>().ToList(); foreach (var test in items) { var flag = testStudents.Find(t => t.TestID == test.TestID && t.SocreSection == "未参与"); if (flag != null) { test.NoPartUserNum = flag.UserNum; testStudents.Remove(flag); } flag = testStudents.Find(t => t.TestID == test.TestID && t.SocreSection == "<50"); if (flag != null) { test.Scoreless50 = flag.UserNum; testStudents.Remove(flag); } flag = testStudents.Find(t => t.TestID == test.TestID && t.SocreSection == "50~59"); if (flag != null) { test.Score50to59 = flag.UserNum; testStudents.Remove(flag); } flag = testStudents.Find(t => t.TestID == test.TestID && t.SocreSection == "60~69"); if (flag != null) { test.Score60to69 = flag.UserNum; testStudents.Remove(flag); } flag = testStudents.Find(t => t.TestID == test.TestID && t.SocreSection == "70~79"); if (flag != null) { test.Score70to79 = flag.UserNum; testStudents.Remove(flag); } flag = testStudents.Find(t => t.TestID == test.TestID && t.SocreSection == "80~89"); if (flag != null) { test.Score80to89 = flag.UserNum; testStudents.Remove(flag); } flag = testStudents.Find(t => t.TestID == test.TestID && t.SocreSection == ">=90"); if (flag != null) { test.Scoremore90 = flag.UserNum; testStudents.Remove(flag); } } return items; } } catch (Exception e) { return null; } }
public static bool ScoreManageInfo_Upd(ScoreManageInfo model) { try { using (var conn = DbHelper.CCService()) { var p = new DynamicParameters(); p.Add("@TestID", model.TestID); p.Add("@Name", model.Name); p.Add("@StartDate", model.StartDate); p.Add("@EndDate", model.EndDate); p.Add("@ScoreTypeID", model.ScoreTypeID); conn.Execute("Score_Test_Upd", p, commandType: CommandType.StoredProcedure); return true; } } catch (Exception e) { return false; } }