温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:燕赵宽频点播系统V1.0源码
当前文件路径:hevod/DAL/Basic.cs

1using System; 2
using System.Data; 3
using System.Data.OleDb; 4
using System.Text; 5
6
//该源码下载自www.51aspx.com(51aspx.com) 7
8
namespace DAL 9
{ 10
/// <summary> 11
/// 基本信息basic 12
/// </summary> 13
public class Basic 14
{ 15
DBConn dbConn = new DBConn(); 16
17
/// <summary> 18
/// 读取基本信息 19
/// </summary> 20
/// <param name="id"></param> 21
/// <returns></returns> 22
public Model.Basic GetBasicInfo(int id) 23
{ 24
Model.Basic modelBasic = new Model.Basic(); 25
26
string sql = "select title,context from basic where id="+id; 27
OleDbCommand cmd = new OleDbCommand(sql, dbConn.conn); 28
dbConn.Open(); 29
OleDbDataReader dr = cmd.ExecuteReader(); 30
if (dr.Read()) 31
{ 32
modelBasic.Title = dr[0].ToString(); 33
modelBasic.Context = dr[1].ToString(); 34
} 35
else 36
{ 37
modelBasic.Title = "暂无"; 38
modelBasic.Context = "暂无"; 39
} 40
dr.Close(); 41
dbConn.Close(); 42
return modelBasic; 43
} 44
45
/// <summary> 46
/// 更新基本信息 47
/// </summary> 48
/// <param name="id"></param> 49
/// <returns></returns> 50
public bool UpdateBasic(int id,Model.Basic modelBasic) 51
{ 52
bool isOK=false; 53
string sql = "update basic set context='"+modelBasic.Context+"' where id="+id; 54
OleDbCommand cmd = new OleDbCommand(sql, dbConn.conn); 55
try 56
{ 57
dbConn.Open(); 58
if (cmd.ExecuteNonQuery() > 0) 59
isOK = true; 60
} 61
catch (OleDbException ex) 62
{ 63
throw ex; 64
} 65
finally 66
{ 67
dbConn.Close(); 68
} 69
return isOK; 70
} 71
72
} 73
} 74





}