/// <summary> /// 向数据表tb_ExamCls更新一条记录。带事务 /// </summary> /// <param name="sp">事务对象</param> /// <param name="_tb_ExamClsModel">_tb_ExamClsModel</param> /// <returns>影响的行数</returns> public int Update(SqlTransaction sp, tb_ExamClsEntity _tb_ExamClsModel) { string sqlStr = "update tb_ExamCls set [SchoolId]=@SchoolId,[ParentId]=@ParentId,[Name]=@Name,[Description]=@Description,[Status]=@Status,[Addtime]=@Addtime,[Updatetime]=@Updatetime where ExamClsId=@ExamClsId"; SqlParameter[] _param = { new SqlParameter("@ExamClsId", SqlDbType.Int), new SqlParameter("@SchoolId", SqlDbType.Int), new SqlParameter("@ParentId", SqlDbType.Int), new SqlParameter("@Name", SqlDbType.VarChar), new SqlParameter("@Description", SqlDbType.VarChar), new SqlParameter("@Status", SqlDbType.Int), new SqlParameter("@Addtime", SqlDbType.DateTime), new SqlParameter("@Updatetime", SqlDbType.DateTime) }; _param[0].Value = _tb_ExamClsModel.ExamClsId; _param[1].Value = _tb_ExamClsModel.SchoolId; _param[2].Value = _tb_ExamClsModel.ParentId; _param[3].Value = _tb_ExamClsModel.Name; _param[4].Value = _tb_ExamClsModel.Description; _param[5].Value = _tb_ExamClsModel.Status; _param[6].Value = _tb_ExamClsModel.Addtime; _param[7].Value = _tb_ExamClsModel.Updatetime; return(SqlHelper.ExecuteNonQuery(sp, CommandType.Text, sqlStr, _param)); }
/// <summary> /// 向数据库中插入一条新记录。带事务 /// </summary> /// <param name="sp">事务对象</param> /// <param name="_tb_ExamClsModel">tb_ExamCls实体</param> /// <returns>新插入记录的编号</returns> public int Insert(SqlTransaction sp, tb_ExamClsEntity _tb_ExamClsModel) { string sqlStr = "insert into tb_ExamCls([SchoolId],[ParentId],[Name],[Description],[Status],[Addtime],[Updatetime]) values(@SchoolId,@ParentId,@Name,@Description,@Status,@Addtime,@Updatetime) select @@identity"; int res; SqlParameter[] _param = { new SqlParameter("@SchoolId", SqlDbType.Int), new SqlParameter("@ParentId", SqlDbType.Int), new SqlParameter("@Name", SqlDbType.VarChar), new SqlParameter("@Description", SqlDbType.VarChar), new SqlParameter("@Status", SqlDbType.Int), new SqlParameter("@Addtime", SqlDbType.DateTime), new SqlParameter("@Updatetime", SqlDbType.DateTime) }; _param[0].Value = _tb_ExamClsModel.SchoolId; _param[1].Value = _tb_ExamClsModel.ParentId; _param[2].Value = _tb_ExamClsModel.Name; _param[3].Value = _tb_ExamClsModel.Description; _param[4].Value = _tb_ExamClsModel.Status; _param[5].Value = _tb_ExamClsModel.Addtime; _param[6].Value = _tb_ExamClsModel.Updatetime; res = Convert.ToInt32(SqlHelper.ExecuteScalar(sp, CommandType.Text, sqlStr, _param)); return(res); }
/// <summary> /// 得到 tb_examcls 数据实体 /// </summary> /// <param name="dr">dr</param> /// <returns>tb_examcls 数据实体</returns> public tb_ExamClsEntity Populate_tb_ExamClsEntity_FromDr(IDataReader dr) { tb_ExamClsEntity Obj = new tb_ExamClsEntity(); Obj.ExamClsId = ((dr["ExamClsId"]) == DBNull.Value)?0:Convert.ToInt32(dr["ExamClsId"]); Obj.SchoolId = ((dr["SchoolId"]) == DBNull.Value)?0:Convert.ToInt32(dr["SchoolId"]); Obj.ParentId = ((dr["ParentId"]) == DBNull.Value)?0:Convert.ToInt32(dr["ParentId"]); Obj.Name = dr["Name"].ToString(); Obj.Description = dr["Description"].ToString(); Obj.Status = ((dr["Status"]) == DBNull.Value)?0:Convert.ToInt32(dr["Status"]); Obj.Addtime = ((dr["Addtime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(dr["Addtime"]); Obj.Updatetime = ((dr["Updatetime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(dr["Updatetime"]); return(Obj); }
/// <summary> /// 根据ID,返回一个tb_ExamCls对象 /// </summary> /// <param name="examClsId">examClsId</param> /// <returns>tb_ExamCls对象</returns> public tb_ExamClsEntity Get_tb_ExamClsEntity(int examClsId) { tb_ExamClsEntity _obj = null; SqlParameter[] _param = { new SqlParameter("@ExamClsId", SqlDbType.Int) }; _param[0].Value = examClsId; string sqlStr = "select * from tb_ExamCls with(nolock) where ExamClsId=@ExamClsId"; using (SqlDataReader dr = SqlHelper.ExecuteReader(WebConfig.ExamRW, CommandType.Text, sqlStr, _param)) { while (dr.Read()) { _obj = Populate_tb_ExamClsEntity_FromDr(dr); } } return(_obj); }
/// <summary> /// 得到 tb_examcls 数据实体 /// </summary> /// <param name="row">row</param> /// <returns>tb_examcls 数据实体</returns> public tb_ExamClsEntity Populate_tb_ExamClsEntity_FromDr(DataRow row) { tb_ExamClsEntity Obj = new tb_ExamClsEntity(); if (row != null) { Obj.ExamClsId = ((row["ExamClsId"]) == DBNull.Value)?0:Convert.ToInt32(row["ExamClsId"]); Obj.SchoolId = ((row["SchoolId"]) == DBNull.Value)?0:Convert.ToInt32(row["SchoolId"]); Obj.ParentId = ((row["ParentId"]) == DBNull.Value)?0:Convert.ToInt32(row["ParentId"]); Obj.Name = row["Name"].ToString(); Obj.Description = row["Description"].ToString(); Obj.Status = ((row["Status"]) == DBNull.Value)?0:Convert.ToInt32(row["Status"]); Obj.Addtime = ((row["Addtime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(row["Addtime"]); Obj.Updatetime = ((row["Updatetime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(row["Updatetime"]); } else { return(null); } return(Obj); }
public void Update(tb_ExamClsEntity tb_ExamClsEntity) { tb_ExamClsdal.Update(tb_ExamClsEntity); }
public int Insert(tb_ExamClsEntity tb_ExamClsEntity) { return(tb_ExamClsdal.Insert(tb_ExamClsEntity)); }