温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:校园新闻发布系统源码
当前文件:
SchoolNews/common/Lb_Model.cs[3K,2009-6-12 11:53:17],打开代码结构图
SchoolNews/common/Lb_Model.cs[3K,2009-6-12 11:53:17],打开代码结构图1# region 导入命名空间 2
using System; 3
using System.Collections; 4
using System.Collections.Specialized; 5
using System.Configuration; 6
using System.Data; 7
using System.Data.OleDb; 8
using System.Drawing; 9
using System.Reflection; 10
using System.Runtime.CompilerServices; 11
using System.Text; 12
using System.Text.RegularExpressions; 13
using System.Web; 14
using System.Web.Caching; 15
using System.Web.SessionState; 16
using System.Web.Security; 17
using System.Web.UI; 18
using System.Web.UI.WebControls; 19
using System.Web.UI.HtmlControls; 20
21
# endregion 22
//该源码下载自www.51aspx.com(51aspx.com) 23
24
25
namespace Lb_news 26
{ 27
/// <summary> 28
/// Lbshop2Class 的摘要说明。 29
/// </summary> 30
/// 31
// 数据库操作 32
public class Conn //数据访问类 33
{ 34
public Conn() 35
{ 36
// 37
// TODO: 在此处添加构造函数逻辑 38
// 39
} 40
41
// 数据库连接字符串 42
public OleDbConnection Lb_Conn=new OleDbConnection(strConn); 43
44
private string vername; 45
46
47
public int grade; 48
49
50
public string verName 51
{ 52
get 53
54
{ 55
56
vername="新闻发布管理系统"; 57
58
return vername; 59
60
} 61
62
} 63
64
65
public static string strConn 66
{ 67
get 68
{ 69
StringBuilder strResult = new StringBuilder(); 70
strResult.Append("Provider = Microsoft.Jet.OLEDB.4.0"); 71
strResult.Append("; "); 72
strResult.Append("Data Source = "); 73
strResult.Append(HttpContext.Current.Server.MapPath(".")); 74
strResult.Append("\\"); 75
strResult.Append(ConfigurationSettings.AppSettings["MdbPath"]); 76
return strResult.ToString(); 77
} 78
} 79
80
81
82
83
public void DBopen() 84
{ 85
if (Lb_Conn.State==ConnectionState.Closed) 86
{ 87
Lb_Conn.Open(); 88
} 89
} 90
91
public void DBclose() 92
{ 93
if (Lb_Conn.State==ConnectionState.Open) 94
{ 95
Lb_Conn.Close(); 96
} 97
} 98
99
public OleDbDataReader ExecuteOleDbDataReader(string strSql) 100
{ 101
102
OleDbCommand cmd=new OleDbCommand(strSql,Lb_Conn); 103
OleDbDataReader rd=cmd.ExecuteReader(); 104
return rd; 105
106
} 107
108
109
110
public DataSet CreateDataSet(string strSql,string tableName) 111
{ 112
OleDbDataAdapter da=new OleDbDataAdapter(strSql,Lb_Conn); 113
DataSet dst=new DataSet(); 114
da.Fill(dst,tableName); 115
return dst; 116
117
} 118
119
public int ChangeToInt(string a) 120
{ 121
122
int b=Int32.Parse(a.ToString()); 123
return b; 124
125
} 126
127
128
public int ExecuteSql(string strSql) 129
{ 130
131
OleDbCommand cmd2=new OleDbCommand(strSql,Lb_Conn); 132
int result=cmd2.ExecuteNonQuery(); 133
134
return result; 135
136
} 137
138
//登陆检验 or 管理页面检验 139
140
public void CheckCookies(int check_grade) 141
{ 142
143
144
145
146
if (System.Web.HttpContext.Current.Request.Cookies["UserInfo"]==null) 147
{ 148
System.Web.HttpContext.Current.Response.Redirect ("admin_login.aspx"); 149
150
} 151
else 152
{ 153
154
HttpCookie Mycookie=System.Web.HttpContext.Current.Request.Cookies["UserInfo"]; 155
156
grade=ChangeToInt(Mycookie.Values["grade"].ToString()); 157
158
if (grade<check_grade) 159
{ 160
161
162
163
System.Web.HttpContext.Current.Response.Write ("<script>alert('你的权限不够');location.href('admin_main.htm')</script>"); 164
165
} 166
167
168
169
} 170
System.Web.HttpContext.Current.Response.Write("<div align='center'><a style='font-size:15px;color:#FFFFFF;font-weight:bold;'>新闻后台管理区</a></div>"); 171
172
173
174
} 175
176
177
//javascript 178
179
public void alert(string a,string b) 180
{ 181
string Content=a.ToString(); 182
string Url=b.ToString(); 183
184
System.Web.HttpContext.Current.Response.Write ("<script>alert('"+Content+"');location.href('"+Url+"')</script>"); 185
186
} 187
188
189
190
//测试 191
public void test() 192
{ 193
194
System.Web.HttpContext.Current.Response.Write ("Hello World!"); 195
196
} 197
198
} 199
200
//ReWrite 201
public class UrlFormat 202
{ 203
204
public UrlFormat() 205
{ 206
} 207
208
public virtual string NewsUrl(int NewsID) 209
{ 210
return GetUrl("n" + NewsID + ".aspx"); 211
} 212
213
public virtual string ClassUrl(int ClassID) 214
{ 215
return GetUrl("c" + ClassID + ".aspx"); 216
} 217
218
protected virtual string GetUrl(string pattern, params object[] items) 219
{ 220
return string.Format(pattern,items); 221
} 222
223
} 224
} 225






}