/*添加学期信息实现*/ public static bool AddTermInfo_(ENTITY.TermInfo_ termInfo_) { string sql = "insert into TermInfo_(termName) values(@termName)"; /*构建sql参数*/ SqlParameter[] parm = new SqlParameter[] { new SqlParameter("@termName", SqlDbType.VarChar) }; /*给参数赋值*/ parm[0].Value = termInfo_.termName; //学期名称 /*执行sql进行添加*/ return((DBHelp.ExecuteNonQuery(sql, parm) > 0) ? true : false); }
/*更新学期信息实现*/ public static bool EditTermInfo_(ENTITY.TermInfo_ termInfo_) { string sql = "update TermInfo_ set termName=@termName where termId=@termId"; /*构建sql参数信息*/ SqlParameter[] parm = new SqlParameter[] { new SqlParameter("@termName", SqlDbType.VarChar), new SqlParameter("@termId", SqlDbType.Int) }; /*为参数赋值*/ parm[0].Value = termInfo_.termName; parm[1].Value = termInfo_.termId; /*执行更新*/ return((DBHelp.ExecuteNonQuery(sql, parm) > 0) ? true : false); }
/*根据termId获取某条学期信息记录*/ public static ENTITY.TermInfo_ getSomeTermInfo_(int termId) { /*构建查询sql*/ string sql = "select * from TermInfo_ where termId=" + termId; SqlDataReader DataRead = DBHelp.ExecuteReader(sql, null); ENTITY.TermInfo_ termInfo_ = new ENTITY.TermInfo_(); /*如果查询存在记录,就包装到对象中返回*/ if (DataRead.Read()) { termInfo_.termId = Convert.ToInt32(DataRead["termId"]); termInfo_.termName = DataRead["termName"].ToString(); } return(termInfo_); }