|
using System; |
2 |
using System.Collections; |
3 |
using System.ComponentModel; |
4 |
using System.Data; |
5 |
using System.Drawing; |
6 |
using System.Web; |
7 |
using System.Web.SessionState; |
8 |
using System.Web.UI; |
9 |
using System.Web.UI.WebControls; |
10 |
using System.Web.UI.HtmlControls; |
11 |
using System.Data.OleDb;//修改类型 |
12 |
|
13 |
namespace Lb_news |
14 |
{ |
15 |
|
16 |
|
17 |
|
18 |
public class admin_setup : System.Web.UI.Page |
19 |
{ |
20 |
protected System.Web.UI.WebControls.TextBox LbNew_Title; |
21 |
protected System.Web.UI.WebControls.TextBox LbNew_Url; |
22 |
protected System.Web.UI.WebControls.TextBox LbNew_Logo; |
23 |
protected System.Web.UI.WebControls.TextBox LbNew_Banner; |
24 |
protected System.Web.UI.WebControls.TextBox LbNew_Copyright; |
25 |
protected System.Web.UI.WebControls.RequiredFieldValidator required5; |
26 |
protected System.Web.UI.WebControls.RegularValidator regular5; |
27 |
protected System.Web.UI.WebControls.Button Submit; |
28 |
protected System.Web.UI.WebControls.RequiredFieldValidator required1; |
29 |
protected System.Web.UI.WebControls.RegularValidator regular1; |
30 |
protected System.Web.UI.WebControls.RequiredFieldValidator required2; |
31 |
protected System.Web.UI.WebControls.RegularValidator regular2; |
32 |
protected System.Web.UI.WebControls.RequiredFieldValidator required3; |
33 |
protected System.Web.UI.WebControls.RegularValidator regular3; |
34 |
protected System.Web.UI.WebControls.RequiredFieldValidator required4; |
35 |
protected System.Web.UI.WebControls.RegularValidator regular4; |
36 |
protected System.Web.UI.WebControls.RequiredFieldValidator CheckBody; |
37 |
protected Conn ds1=new Conn(); |
38 |
protected OleDbDataReader rd; |
39 |
protected System.Web.UI.WebControls.TextBox LbNew_Board; |
40 |
protected System.Web.UI.WebControls.TextBox LbNew_Script; |
41 |
protected System.Web.UI.WebControls.TextBox LbNews_SciptName; |
42 |
protected System.Web.UI.WebControls.RequiredFieldValidator CheckScriptName; |
43 |
protected System.Web.UI.WebControls.RequiredFieldValidator CheckScript; |
44 |
protected DataSet ds; |
45 |
|
46 |
|
47 |
private void Page_Load(object sender, System.EventArgs e) |
48 |
{ |
49 |
ds1.CheckCookies(3); |
50 |
|
51 |
|
52 |
if(!Page.IsPostBack) |
53 |
{ |
54 |
LbNew_Default(); |
55 |
} |
56 |
} |
57 |
|
58 |
//修改安装 |
59 |
private void LbSetupUpdate() |
60 |
{ |
61 |
|
62 |
try |
63 |
{ |
64 |
ds1.DBopen(); |
65 |
string Title=LbNew_Title.Text.ToString(); |
66 |
string Url=LbNew_Url.Text.ToString(); |
67 |
string Logo=LbNew_Logo.Text.ToString(); |
68 |
string Banner=LbNew_Banner.Text.ToString(); |
69 |
string Copyright=LbNew_Copyright.Text.ToString().Replace("\r\n","<br>"); |
70 |
string Board=LbNew_Board.Text.ToString().Replace("\r\n","<br>");; |
71 |
string ScriptCode=LbNew_Script.Text.ToString().Replace("\r\n","<br>");; |
72 |
string ScriptName=LbNews_SciptName.Text.Trim(); |
73 |
string sql="update Lb_Setup set S_Title='"+Title+"',S_Url='"+Url+"',S_Logo='"+Logo+"',S_Banner='"+Banner+"',S_Copyright='"+Copyright+"',S_Board='"+Board+"',S_ScriptCode='"+ScriptCode+"',S_ScriptName='"+ScriptName+"'"; |
74 |
|
75 |
|
76 |
int result=ds1.ExecuteSql(sql); |
77 |
|
78 |
if(result>0) |
79 |
{ |
80 |
|
81 |
ds1.alert("修改成功","admin_setup.aspx"); |
82 |
|
83 |
|
84 |
} |
85 |
else |
86 |
{ |
87 |
|
88 |
|
89 |
ds1.alert("修改成功","admin_setup.aspx"); |
90 |
|
91 |
} |
92 |
|
93 |
|
94 |
} |
95 |
catch (System.Data.OleDb.OleDbException g) |
96 |
{ |
97 |
|
98 |
Response.Write (g.ToString()); |
99 |
} |
100 |
finally |
101 |
{ |
102 |
ds1.DBclose(); |
103 |
} |
104 |
|
105 |
|
106 |
} |
107 |
|
108 |
//默认安装 |
109 |
private void LbNew_Default() |
110 |
{ |
111 |
|
112 |
try |
113 |
{ |
114 |
ds1.DBopen(); |
115 |
|
116 |
rd=ds1.ExecuteOleDbDataReader("select * from Lb_Setup"); |
117 |
|
118 |
if (rd.HasRows) |
119 |
{ |
120 |
rd.Read(); |
121 |
LbNew_Title.Text=(string)rd["S_Title"]; |
122 |
LbNew_Url.Text=(string)rd["S_Url"]; |
123 |
LbNew_Logo.Text=(string)rd["S_Logo"]; |
124 |
LbNew_Banner.Text=(string)rd["S_Banner"]; |
125 |
LbNew_Copyright.Text=rd["S_Copyright"].ToString().Replace("<br>","\r\n"); |
126 |
LbNew_Board.Text=rd["S_Board"].ToString().Replace("<br>","\r\n"); |
127 |
LbNew_Script.Text=(string)rd["S_ScriptCode"].ToString().Replace("<br>","\r\n"); |
128 |
LbNews_SciptName.Text=(string)rd["S_ScriptName"]; |
129 |
} |
130 |
else |
131 |
{ |
132 |
Response.Write ("暂时还没有记录"); |
133 |
|
134 |
} |
135 |
} |
136 |
catch(System.Data.OleDb.OleDbException e) |
137 |
|
138 |
{ |
139 |
Response.Write (e.ToString()); |
140 |
|
141 |
} |
142 |
finally |
143 |
{ |
144 |
ds1.DBclose(); |
145 |
} |
146 |
} |
147 |
//以下自动生成 |
148 |
#region Web 窗体设计器生成的代码 |
149 |
override protected void OnInit(EventArgs e) |
150 |
{ |
151 |
// |
152 |
|
153 |
// |
154 |
InitializeComponent(); |
155 |
base.OnInit(e); |
156 |
} |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
private void InitializeComponent() |
163 |
{ |
164 |
this.Submit.Click += new System.EventHandler(this.Submit_Click); |
165 |
this.Load += new System.EventHandler(this.Page_Load); |
166 |
|
167 |
} |
168 |
#endregion |
169 |
|
170 |
private void Submit_Click(object sender, System.EventArgs e) |
171 |
{ |
172 |
|
173 |
if (Page.IsValid) |
174 |
{ |
175 |
LbSetupUpdate(); |
176 |
} |
177 |
|
178 |
} |
179 |
} |
180 |
} |