/// <summary> /// 调用存储过程增加一个 /// </summary> /// <param name="info">实体对象</param> /// <returns>正常返回大于 0 的自增id, 0代表重复,否则返回-1</returns> public static int student2tmAdd(Entity.student2tm info) { SqlParameter[] prams = { SqlDB.MakeInParam("@StudentId", SqlDbType.Int, 4, info.StudentId), SqlDB.MakeInParam("@Type", SqlDbType.Int, 4, info.Type), SqlDB.MakeInParam("@TiMuId", SqlDbType.Int, 4, info.TiMuId), SqlDB.MakeInParam("@Answer", SqlDbType.NVarChar, 50, info.Answer), SqlDB.MakeInParam("@RightAnswer", SqlDbType.NVarChar, 50, info.RightAnswer), SqlDB.MakeInParam("@Result", SqlDbType.Int, 4, info.Result), SqlDB.MakeInParam("@ZuBie", SqlDbType.NVarChar, 50, info.ZuBie), SqlDB.MakeInParam("@sx", SqlDbType.NVarChar, 50, info.sx), }; return(Basic.Utils.StrToInt(SqlDB.ExecuteScalar(strCon, CommandType.StoredProcedure, "student2tmAdd", prams).ToString(), -1)); }
/// <summary> /// 获取某一个实体 /// </summary> /// <param name="Id">标识</param> /// <returns>返回Entity</returns> public static Entity.student2tm student2tmEntityGet(int Id) { Entity.student2tm info = new Entity.student2tm(); DataTable dt = SqlDB.ExecuteDataset(strCon, CommandType.Text, "SELECT * FROM [student2tm] WHERE Id = " + Id + ";").Tables[0]; if (dt.Rows.Count > 0) { info.Id = Basic.Utils.StrToInt(dt.Rows[0]["Id"].ToString(), 0); info.StudentId = Basic.Utils.StrToInt(dt.Rows[0]["StudentId"].ToString(), 0); info.Type = Basic.Utils.StrToInt(dt.Rows[0]["Type"].ToString(), 0); info.TiMuId = Basic.Utils.StrToInt(dt.Rows[0]["TiMuId"].ToString(), 0); info.Answer = dt.Rows[0]["Answer"].ToString(); info.RightAnswer = dt.Rows[0]["RightAnswer"].ToString(); info.Result = Basic.Utils.StrToInt(dt.Rows[0]["Result"].ToString(), 0); info.ZuBie = dt.Rows[0]["ZuBie"].ToString(); info.sx = Basic.Utils.StrToInt(dt.Rows[0]["sx"].ToString(), 0); } return(info); }
/// <summary> /// 调用存储过程修改一个 /// </summary> /// <param name="info">实体对象</param> /// <returns>更新成功返回ture,否则返回false</returns> public static bool student2tmEdit(Entity.student2tm info) { SqlParameter[] prams = { SqlDB.MakeInParam("@Id", SqlDbType.Int, 4, info.Id), SqlDB.MakeInParam("@StudentId", SqlDbType.Int, 4, info.StudentId), SqlDB.MakeInParam("@Type", SqlDbType.Int, 4, info.Type), SqlDB.MakeInParam("@TiMuId", SqlDbType.Int, 4, info.TiMuId), SqlDB.MakeInParam("@Answer", SqlDbType.NVarChar, 50, info.Answer), SqlDB.MakeInParam("@RightAnswer", SqlDbType.NVarChar, 50, info.RightAnswer), SqlDB.MakeInParam("@Result", SqlDbType.Int, 4, info.Result), SqlDB.MakeInParam("@ZuBie", SqlDbType.NVarChar, 50, info.ZuBie), SqlDB.MakeInParam("@sx", SqlDbType.NVarChar, 50, info.sx), }; int intReturnValue = 0; intReturnValue = SqlDB.ExecuteNonQuery(strCon, CommandType.StoredProcedure, "student2tmEdit", prams); if (intReturnValue == 1) { return(true); } return(false); }