温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:冬雷物语个人综合网站源码
当前文件:
FHWUUXMQKKG24/edit.aspx.cs[7K,2009-6-12 11:42:31],打开代码结构图
FHWUUXMQKKG24/edit.aspx.cs[7K,2009-6-12 11:42:31],打开代码结构图1using System; 2
using System.Collections; 3
using System.Data .OleDb; 4
using System.ComponentModel; 5
using System.Data; 6
using System.Drawing; 7
using System.Web; 8
using System.Web.SessionState; 9
using System.Web.UI; 10
using System.Web.UI.WebControls; 11
using System.Web.UI.HtmlControls; 12
13
namespace temp 14
{ 15
/// <summary> 16
/// edit 的摘要说明。 17
/// </summary> 18
public class edit : System.Web.UI.Page 19
{ 20
protected System.Web.UI.WebControls.TextBox txtUserName; 21
protected System.Web.UI.WebControls.TextBox txtUserPass; 22
protected System.Web.UI.WebControls.TextBox txtTitle; 23
protected System.Web.UI.WebControls.TextBox txtDirector; 24
protected System.Web.UI.WebControls.TextBox txtForm; 25
protected System.Web.UI.WebControls.TextBox TB_Detail; 26
protected System.Web.UI.WebControls.Button BT_Submit; 27
protected System.Web.UI.WebControls.TextBox txtMusic; 28
protected System.Web.UI.WebControls.DropDownList DDLType; 29
protected System.Web.UI.HtmlControls.HtmlForm Form1; 30
31
private void Page_Load(object sender, System.EventArgs e) 32
{ 33
// 在此处放置用户代码以初始化页面 34
//是否回传! 35
if(!IsPostBack) 36
{ 37
bindType(); 38
} 39
40
int id; 41
if (Request.Params ["id"] !="") 42
{ 43
id=System.Convert .ToInt32 (Request.Params ["id"]); 44
} 45
else 46
{ 47
id=1; 48
} 49
50
string dbname=".\\dbxcl\\temp.mdb"; 51
string strConnection=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath (dbname)+";"; 52
OleDbConnection objConnection=new OleDbConnection(strConnection); 53
objConnection.Open(); 54
55
DataSet myDataSet=new DataSet (); 56
57
string strSel="select d_username from d_user where d_userid=(select d_hwwhoupdateid from d_heartword where d_hwid = "+id+")"; 58
OleDbCommand myCommand=new OleDbCommand( strSel, objConnection ); 59
60
OleDbDataAdapter myDbAdapter=new OleDbDataAdapter (); 61
myDbAdapter.SelectCommand=myCommand; 62
63
myDbAdapter.Fill (myDataSet,"d_user"); 64
65
66
if (myDataSet.Tables ["d_user"].Rows .Count >0) 67
{ 68
69
if(Request["d_username"]!=null && Request["d_username"]!="") 70
{ 71
if(Request["d_username"]!=myDataSet.Tables["d_user"].Rows[0]["d_username"].ToString()) 72
{ 73
if(Request["d_adminuser"]!=null && Request["d_adminuser"]!="") 74
{ 75
if(Request["d_adminuser"]!="temp2") 76
{ 77
Response.Write("<script language=javascript>alert('您无权访问本页,请先登录!');location.href='login.aspx';</script>"); 78
} 79
else 80
{ 81
txtUserName.Text =myDataSet.Tables["d_user"].Rows[0]["d_username"].ToString(); 82
} 83
} 84
else 85
{ 86
87
Response.Write("<script language=javascript>alert('您无权访问本页,请先登录!');location.href='login.aspx';</script>"); 88
} 89
} 90
else 91
{ 92
txtUserName.Text =myDataSet.Tables["d_user"].Rows[0]["d_username"].ToString(); 93
} 94
} 95
else 96
{ 97
Response.Write("<script language=javascript>alert('您无权访问本页,请先登录!');location.href='login.aspx';</script>"); 98
} 99
100
} 101
102
myDataSet.Dispose(); 103
objConnection.Dispose(); 104
105
} 106
private void bindType() 107
{ 108
109
//绑定 110
int id; 111
if (Request.Params ["id"] !="") 112
{ 113
id=System.Convert .ToInt32 (Request.Params ["id"]); 114
} 115
else 116
{ 117
id=1; 118
} 119
120
string dbname=".\\dbxcl\\temp.mdb"; 121
string strConnection=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath (dbname)+";"; 122
OleDbConnection objConnection=new OleDbConnection(strConnection); 123
objConnection.Open(); 124
125
DataSet myDataSet=new DataSet (); 126
DataRow myDr; 127
128
string strSel="select * from d_heartword where d_hwid="+id+" order by d_hwtime desc"; 129
OleDbCommand myCommand=new OleDbCommand( strSel, objConnection ); 130
131
OleDbDataAdapter myDbAdapter=new OleDbDataAdapter (); 132
myDbAdapter.SelectCommand=myCommand; 133
134
myDbAdapter.Fill (myDataSet,"d_detail"); 135
136
137
if (myDataSet.Tables ["d_detail"].Rows .Count >0) 138
{ 139
myDr=myDataSet.Tables["d_detail"].Rows [0]; 140
txtTitle.Text=myDr["d_hwtitle"].ToString (); 141
txtTitle.Enabled=false; 142
txtUserName.Enabled=false; 143
txtDirector.Text=myDr["d_hwdirector"].ToString (); 144
txtForm.Text=myDr["d_hwfrom"].ToString (); 145
TB_Detail.Text=myDr["d_hwtext"].ToString (); 146
txtMusic.Text=myDr["d_hwmusic"].ToString(); 147
} 148
else 149
{ 150
Response.Redirect("error.htm"); 151
} 152
153
string strSelType="select * from d_type"; 154
OleDbCommand myCommandType=new OleDbCommand( strSelType, objConnection ); 155
156
157
OleDbDataAdapter myDbAdapterType=new OleDbDataAdapter (); 158
myDbAdapterType.SelectCommand=myCommandType; 159
160
161
myDbAdapterType.Fill (myDataSet,"d_type"); 162
DDLType.DataSource =myDataSet.Tables ["d_type"] ; 163
DDLType.DataTextField="d_type"; 164
DDLType.DataValueField ="d_typeid"; 165
DDLType.DataBind(); 166
167
myDataSet.Dispose(); 168
objConnection.Dispose(); 169
} 170
171
Web 窗体设计器生成的代码 192
193
194
private void BT_edit(object sender, System.EventArgs e) 195
{ 196
int id; 197
if (Request.Params ["id"] !="") 198
{ 199
id=System.Convert .ToInt32 (Request.Params ["id"]); 200
} 201
else 202
{ 203
id=1; 204
} 205
string dbname=".\\dbxcl\\temp.mdb"; 206
string strConnection=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath (dbname)+";"; 207
OleDbConnection objConnection=new OleDbConnection(strConnection); 208
objConnection.Open(); 209
DataSet myDataSet=new DataSet (); 210
string strSelUser="select d_userid from d_user where d_username='"+txtUserName.Text+"'"; 211
212
OleDbCommand myCommandUser=new OleDbCommand (strSelUser,objConnection); 213
OleDbDataAdapter myDbAdapterUser=new OleDbDataAdapter (); 214
myDbAdapterUser.SelectCommand =myCommandUser; 215
216
myDbAdapterUser.Fill (myDataSet,"d_user"); 217
string userid=myDataSet.Tables ["d_user"].Rows [0]["d_userid"].ToString (); 218
string title=txtTitle.Text.Replace("'","''") ; 219
string director=txtDirector.Text.Replace("'","''"); 220
string from=txtForm.Text.Replace("'","''"); 221
string typeid=DDLType.SelectedItem.Value; 222
string text=TB_Detail.Text.Replace("'","''") ; 223
string time=DateTime.Now.ToString(); 224
string music=txtMusic.Text.ToString().Trim().Replace("'","''"); 225
string updateStr="update d_heartword set d_hwdirector='"+director+"',d_hwtext='"+text+"',d_hwfrom='"+from+"',d_hwwhoupdateid='"+userid+"',d_hwtime='"+time+"',d_hwmusic='"+music+"',d_typeid="+typeid+" where d_hwid="+id; 226
OleDbCommand myCommandUpate=new OleDbCommand( updateStr, objConnection ); 227
myCommandUpate.ExecuteNonQuery (); 228
229
230
objConnection.Dispose(); 231
Response.Redirect ("success.aspx?action=edit"); 232
233
} 234
} 235
} 236






}