温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:网博新闻管理系统0.1版源码文件
当前文件:
WebabcNews/admin/member_add.aspx.cs,打开代码结构图
WebabcNews/admin/member_add.aspx.cs,打开代码结构图1using System; 2
using System.Text; 3
using System.Data; 4
using System.Data.SqlClient; 5
using System.Configuration; 6
using System.Collections; 7
using System.Web; 8
using System.Web.Security; 9
using System.Web.UI; 10
using System.Web.UI.WebControls; 11
using System.Web.UI.WebControls.WebParts; 12
using System.Web.UI.HtmlControls; 13
14
public partial class admin_member_add : Sper.baseuser 15
{ 16
protected override void Page_Load(object sender, EventArgs e) 17
{ 18
base.Page_Load(sender, e); 19
if (!IsPostBack) 20
{ 21
txtexpireDate.Text = DateTime.Now.ToString(); 22
if (Request.QueryString["id"] != null) 23
{ 24
ShowInfo(int.Parse(Request.QueryString["id"])); 25
} 26
} 27
} 28
/******************************显示窗体代码********************************/ 29
30
private void ShowInfo(int ID) 31
{ 32
string sql = "select * from member"; 33
sql += " where id='" + ID.ToString() + "'"; 34
DataRow dr = DbHelperSQL.Query(sql).Tables[0].Rows[0]; 35
36
this.txtname.Text = dr["name"].ToString(); 37
//this.txtpassword.Text = model.password; 38
//this.txtemail.Text = model.email; 39
//this.txtgroupid.Text = model.groupid; 40
//this.txtremarks.Text = model.remarks; 41
//this.txtaddDate.Text = model.addDate.ToString(); 42
//this.txtaddNum.Text = model.addNum.ToString(); 43
//this.txtqq.Text = model.qq; 44
//this.txticq.Text = model.icq; 45
//this.txtmsn.Text = model.msn; 46
//this.txtquestion.Text = model.question; 47
//this.txtanswer.Text = model.answer; 48
//this.txtmale.Text = model.male; 49
//this.txtbirthday.Text = model.birthday.ToString(); 50
//this.txtrealname.Text = model.realname; 51
//this.txtcountry.Text = model.country; 52
//this.txtprovince.Text = model.province; 53
//this.txtcity.Text = model.city; 54
//this.txtphone.Text = model.phone; 55
//this.txtaddress.Text = model.address; 56
//this.txtpostcode.Text = model.postcode; 57
//this.txtbloodType.Text = model.bloodType; 58
//this.txtjob.Text = model.job; 59
//this.txtedu.Text = model.edu; 60
//this.txtschool.Text = model.school; 61
//this.txthideEmail.Text = model.hideEmail; 62
//this.txtlastLog.Text = model.lastLog.ToString(); 63
//this.txtlogTimes.Text = model.logTimes.ToString(); 64
//this.txtphoto.Text = model.photo; 65
//this.txtintroduction.Text = model.introduction; 66
//this.txtrssTitle.Text = model.rssTitle; 67
//this.txtvMoney.Text = model.vMoney.ToString(); 68
//this.txttotalMark.Text = model.totalMark.ToString(); 69
//this.txtnSignIn.Text = model.nSignIn.ToString(); 70
//this.txtaddSignIn.Text = model.addSignIn.ToString(); 71
//this.txtexpireDate.Text = model.expireDate.ToString(); 72
73
} 74
protected void Button1_Click(object sender, EventArgs e) 75
{ 76
Add(); 77
} 78
/// <summary> 79
/// 是否存在该记录 80
/// </summary> 81
public bool Exists(string name) 82
{ 83
StringBuilder strSql = new StringBuilder(); 84
strSql.Append("select count(1) from member"); 85
strSql.Append(" where name=@name"); 86
87
SqlParameter[] parameters = { 88
new SqlParameter("@name", SqlDbType.NVarChar) }; 89
parameters[0].Value = name; 90
Response.Write(strSql.ToString()); 91
//Response.End(); 92
return DbHelperSQL.Exists(strSql.ToString(), parameters); 93
} 94
/// <summary> 95
/// 增加一条数据 96
/// </summary> 97
public void Add() 98
{ 99
string name = this.txtname.Text; 100
string password = fun.Encrypt(this.txtpassword.Text,1); 101
string email = this.txtemail.Text; 102
string groupid = "0"; 103
string remarks = this.txtremarks.Text; 104
DateTime addDate = DateTime.Now; 105
int addNum = 0; 106
string qq = this.txtqq.Text; 107
string icq = this.txticq.Text; 108
string msn = this.txtmsn.Text; 109
string question = this.txtquestion.Text; 110
string answer = this.txtanswer.Text; 111
string male = this.txtmale.SelectedValue; 112
DateTime birthday = DateTime.Now; 113
string realname = this.txtrealname.Text; 114
string country = this.txtcountry.Text; 115
string province = this.txtprovince.Text; 116
string city = this.txtcity.Text; 117
string phone = this.txtphone.Text; 118
string address = this.txtaddress.Text; 119
string postcode = this.txtpostcode.Text; 120
string bloodType = this.txtbloodType.Value; 121
string job = this.txtjob.Value; 122
string edu = this.txtedu.Value; 123
string school = this.txtschool.Text; 124
string hideEmail = "true"; 125
DateTime lastLog = DateTime.Now; 126
int logTimes = 0; 127
string photo = this.txtphoto.Text; 128
string introduction = this.txtintroduction.Text; 129
string rssTitle = this.txtrssTitle.Text; 130
int vMoney = int.Parse(this.txtvMoney.Text); 131
int totalMark = int.Parse(this.txttotalMark.Text); 132
int nSignIn = 0; 133
int addSignIn = 0; 134
DateTime expireDate = DateTime.Parse(this.txtexpireDate.Text); 135
136
// Response.Write(); 137
138
string strErr = ""; 139
if (name == "") 140
{ 141
strErr += "用户名不能为空!\\n"; 142
} 143
if (password == "") 144
{ 145
strErr += "密码不能为空!\\n"; 146
} 147
if (Exists(name)) 148
{ 149
strErr += "该用户已经存在!\\n"; 150
} 151
if (strErr != "") 152
{ 153
MessageBox.Show(this, strErr); 154
return; 155
} 156
157
StringBuilder strSql = new StringBuilder(); 158
strSql.Append("insert into member("); 159
strSql.Append("name,password,email,groupid,remarks,addDate,addNum,qq,icq,msn,question,answer,male,birthday,realname,country,province,city,phone,address,postcode,bloodType,job,edu,school,hideEmail,lastLog,logTimes,photo,introduction,rssTitle,vMoney,totalMark,nSignIn,addSignIn,expireDate)"); 160
strSql.Append(" values ("); 161
strSql.Append("@name,@password,@email,@groupid,@remarks,@addDate,@addNum,@qq,@icq,@msn,@question,@answer,@male,@birthday,@realname,@country,@province,@city,@phone,@address,@postcode,@bloodType,@job,@edu,@school,@hideEmail,@lastLog,@logTimes,@photo,@introduction,@rssTitle,@vMoney,@totalMark,@nSignIn,@addSignIn,@expireDate)"); 162
SqlParameter[] parameters = { 163
new SqlParameter("@name", SqlDbType.NVarChar), 164
new SqlParameter("@password", SqlDbType.NVarChar), 165
new SqlParameter("@email", SqlDbType.NVarChar), 166
new SqlParameter("@groupid", SqlDbType.NVarChar), 167
new SqlParameter("@remarks", SqlDbType.NVarChar), 168
new SqlParameter("@addDate", SqlDbType.DateTime), 169
new SqlParameter("@addNum", SqlDbType.Int,4), 170
new SqlParameter("@qq", SqlDbType.NVarChar), 171
new SqlParameter("@icq", SqlDbType.NVarChar), 172
new SqlParameter("@msn", SqlDbType.NVarChar), 173
new SqlParameter("@question", SqlDbType.NVarChar), 174
new SqlParameter("@answer", SqlDbType.NVarChar), 175
new SqlParameter("@male", SqlDbType.Bit,1), 176
new SqlParameter("@birthday", SqlDbType.DateTime), 177
new SqlParameter("@realname", SqlDbType.NVarChar), 178
new SqlParameter("@country", SqlDbType.NVarChar), 179
new SqlParameter("@province", SqlDbType.NVarChar), 180
new SqlParameter("@city", SqlDbType.NVarChar), 181
new SqlParameter("@phone", SqlDbType.NVarChar), 182
new SqlParameter("@address", SqlDbType.NVarChar), 183
new SqlParameter("@postcode", SqlDbType.NVarChar), 184
new SqlParameter("@bloodType", SqlDbType.NVarChar), 185
new SqlParameter("@job", SqlDbType.NVarChar), 186
new SqlParameter("@edu", SqlDbType.NVarChar), 187
new SqlParameter("@school", SqlDbType.NVarChar), 188
new SqlParameter("@hideEmail", SqlDbType.Bit,1), 189
new SqlParameter("@lastLog", SqlDbType.DateTime), 190
new SqlParameter("@logTimes", SqlDbType.Int,4), 191
new SqlParameter("@photo", SqlDbType.NVarChar), 192
new SqlParameter("@introduction", SqlDbType.NVarChar), 193
new SqlParameter("@rssTitle", SqlDbType.NVarChar), 194
new SqlParameter("@vMoney", SqlDbType.Int,4), 195
new SqlParameter("@totalMark", SqlDbType.Int,4), 196
new SqlParameter("@nSignIn", SqlDbType.Int,4), 197
new SqlParameter("@addSignIn", SqlDbType.Int,4), 198
new SqlParameter("@expireDate", SqlDbType.DateTime)}; 199
parameters[0].Value = name; 200
parameters[1].Value = password; 201
parameters[2].Value = email; 202
parameters[3].Value = groupid; 203
parameters[4].Value = remarks; 204
parameters[5].Value = addDate; 205
parameters[6].Value = addNum; 206
parameters[7].Value = qq; 207
parameters[8].Value = icq; 208
parameters[9].Value = msn; 209
parameters[10].Value = question; 210
parameters[11].Value = answer; 211
parameters[12].Value = male; 212
parameters[13].Value = birthday; 213
parameters[14].Value = realname; 214
parameters[15].Value = country; 215
parameters[16].Value = province; 216
parameters[17].Value = city; 217
parameters[18].Value = phone; 218
parameters[19].Value = address; 219
parameters[20].Value = postcode; 220
parameters[21].Value = bloodType; 221
parameters[22].Value = job; 222
parameters[23].Value = edu; 223
parameters[24].Value = school; 224
parameters[25].Value = hideEmail; 225
parameters[26].Value = lastLog; 226
parameters[27].Value = logTimes; 227
parameters[28].Value = photo; 228
parameters[29].Value = introduction; 229
parameters[30].Value = rssTitle; 230
parameters[31].Value = vMoney; 231
parameters[32].Value = totalMark; 232
parameters[33].Value = nSignIn; 233
parameters[34].Value = addSignIn; 234
parameters[35].Value = expireDate; 235
236
//Response.Write(strSql.ToString()); 237
//Response.End(); 238
DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); 239
} 240
} 241





}
}