温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:某大学211工程办公室网站源码(生成静态页)
当前文件:
211HtmNewsAccess/AdminClass.aspx.cs[4K,2009-6-12 11:30:48],打开代码结构图
211HtmNewsAccess/AdminClass.aspx.cs[4K,2009-6-12 11:30:48],打开代码结构图1using 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
//5 1 a s p x.com 12
13
namespace _211 14
{ 15
/// <summary> 16
/// AdminClass 的摘要说明。 17
/// </summary> 18
public partial class AdminClass : System.Web.UI.Page 19
{ 20
21
protected void Page_Load(object sender, System.EventArgs e) 22
{ 23
if(Session["name"]==null) 24
{ 25
Response.Write("<script>top.location='AdminLogin.aspx'</script>"); 26
return; 27
} 28
29
if(!Page.IsPostBack) 30
{ 31
BindAll(); 32
Button1.Attributes["onclick"]="return confirm('确定要删除么?')"; 33
} 34
} 35
36
private void ReadClass() 37
{ 38
c.DataSource=TableQuery.ClassQuery(); 39
c.DataTextField="ClassName"; 40
c.DataValueField="ClassId"; 41
c.DataBind(); 42
} 43
44
private void ReadItem() 45
{ 46
if(c.SelectedItem==null)return; 47
48
i.DataSource=TableQuery.ItemQuery(c.SelectedValue); 49
i.DataTextField="ItemName"; 50
i.DataValueField="ItemId"; 51
i.DataBind(); 52
} 53
54
private void ClassList2Text() 55
{ 56
if(c.SelectedItem!=null) 57
{ 58
c_modify.Text=c.SelectedItem.Text; 59
} 60
} 61
62
private void ItemList2Text() 63
{ 64
if(i.SelectedItem!=null) 65
{ 66
i_modify.Text=i.SelectedItem.Text; 67
} 68
} 69
70
private void BindClass() 71
{ 72
ReadClass(); 73
ClassList2Text(); 74
} 75
76
private void BindItem() 77
{ 78
ReadItem(); 79
ItemList2Text(); 80
} 81
82
private void BindAll() 83
{ 84
BindClass(); 85
BindItem(); 86
} 87
88
Web 窗体设计器生成的代码 107
108
109
protected void Button1_Click(object sender, System.EventArgs e) 110
{ 111
if(i.SelectedItem!=null) 112
{ 113
try 114
{ 115
DBQuery.ExceuteNonQuery("delete from [Item] where ItemId="+i.SelectedValue); 116
Response.Write("<script>alert('删除成功');</script>"); 117
} 118
catch(Exception ex) 119
{ 120
Response.Write("<script>alert('"+ex.Message.ToString()+"');</script>"); 121
} 122
123
BindItem(); 124
} 125
} 126
127
protected void Button4_Click(object sender, System.EventArgs e) 128
{ 129
if(i_add.Text==""||c.SelectedItem==null)return; 130
131
using(Item it=new Item(i_add.Text,false)) 132
{ 133
try 134
{ 135
it.setClassId(Convert.ToUInt32(c.SelectedValue)); 136
it.Add(); 137
138
i_add.Text=""; 139
Response.Write("<script>alert('添加成功');</script>"); 140
} 141
catch(Exception ex) 142
{ 143
Response.Write("<script>alert('"+ex.Message.ToString()+"');</script>"); 144
} 145
} 146
147
BindItem(); 148
} 149
150
protected void Button5_Click(object sender, System.EventArgs e) 151
{ 152
if(c_modify.Text=="")return; 153
154
using(Class cl=new Class(Convert.ToUInt32(c.SelectedValue))) 155
{ 156
cl.setClassName(c_modify.Text); 157
try 158
{ 159
cl.Update(); 160
161
Response.Write("<script>alert('修改成功');</script>"); 162
} 163
catch(Exception ex) 164
{ 165
Response.Write("<script>alert('"+ex.Message.ToString()+"');</script>"); 166
} 167
} 168
169
BindAll(); 170
} 171
172
protected void Button6_Click(object sender, System.EventArgs e) 173
{ 174
if(i_modify.Text=="")return; 175
176
using(Item it=new Item(Convert.ToUInt32(i.SelectedValue))) 177
{ 178
it.setItemName(i_modify.Text); 179
try 180
{ 181
it.Update(); 182
183
Response.Write("<script>alert('修改成功');</script>"); 184
} 185
catch(Exception ex) 186
{ 187
Response.Write("<script>alert('"+ex.Message.ToString()+"');</script>"); 188
} 189
} 190
191
BindItem(); 192
} 193
194
protected void c_SelectedIndexChanged(object sender, System.EventArgs e) 195
{ 196
ClassList2Text(); 197
BindItem(); 198
} 199
200
protected void i_SelectedIndexChanged(object sender, System.EventArgs e) 201
{ 202
ItemList2Text(); 203
} 204
} 205
} 206






}