/// <summary> /// 获取当前使用的试卷 /// </summary> /// <param name="info">实验类型或考试(-1)</param> /// <returns></returns> public ActionResult GetCurrentExercises(stId info) { CurrentExercises result = ExercisesTestbll.GetCurrentExercises(info.Id); var res = new ConfigurableJsonResult(); res.Data = result; HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", "*"); return(res); }
private CurrentExercises DataTableToCurrentExercises(DataTable dt) { CurrentExercises info = new CurrentExercises(); if (dt != null && dt.Rows.Count > 0) { info.CurrentExercisesId = dt.Rows[0]["CurrentExercisesId"] == DBNull.Value ? -100 : Convert.ToInt32(dt.Rows[0]["CurrentExercisesId"]); info.ExercisesTestId = dt.Rows[0]["ExercisesTestId"] == DBNull.Value ? -100 : Convert.ToInt32(dt.Rows[0]["ExercisesTestId"]); info.ExercisesTypeId = dt.Rows[0]["ExercisesTypeId"] == DBNull.Value ? -100 : Convert.ToInt32(dt.Rows[0]["ExercisesTypeId"]); } else { info.CurrentExercisesId = -100; } return(info); }
public int SaveCurrentExercises(int ExercisesTestId) { string strSql = ""; ExercisesTest?info = GetExercisesTest(ExercisesTestId); if (info == null) { return(-1); } else { CurrentExercises model = GetCurrentExercises(info.Value.ExercisesTypeId); if (model.CurrentExercisesId == -100) { //增加 strSql = "insert into CurrentExercises(ExercisesTestId,ExercisesTypeId) values(@ExercisesTestId,@ExercisesTypeId)"; return(DBFactory.GetDB(DBType.SQLITE, m_strConn).ExecuteNonQuery(strSql, new DbParameter[] { new SQLiteParameter() { Value = ExercisesTestId, ParameterName = "@ExercisesTestId" }, new SQLiteParameter() { Value = info.Value.ExercisesTypeId, ParameterName = "@ExercisesTypeId" } })); } else { strSql = "update CurrentExercises set ExercisesTestId=@ExercisesTestId where ExercisesTypeId=@ExercisesTypeId"; //修改 return(DBFactory.GetDB(DBType.SQLITE, m_strConn).ExecuteNonQuery(strSql, new DbParameter[] { new SQLiteParameter() { Value = ExercisesTestId, ParameterName = "@ExercisesTestId" }, new SQLiteParameter() { Value = info.Value.ExercisesTypeId, ParameterName = "@ExercisesTypeId" } })); } } }