温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:小区物业管理系统源码
当前文件:
SmallHouse/admin/addhomehold.aspx.cs,打开代码结构图
SmallHouse/admin/addhomehold.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.Data.SqlClient; 12
13
public partial class admin_Default2 : System.Web.UI.Page 14
{ 15
BaseClass bc = new BaseClass(); 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
if (Convert.ToString(Session["UID"]) == "") 19
{ 20
Response.Redirect("login.aspx"); 21
22
} 23
if (!IsPostBack) 24
{ 25
bind(); 26
} 27
28
29
} 30
31
protected void bind() 32
{ 33
34
bc.ExecDropDownList(pav, "select * from pavilion", "Name", "paID");//楼宇 35
bc.ExecDropDownList(cell, "select * from type where type='DY'", "name", "code");//单元 36
string pavcell = pav.SelectedItem.Value.ToString() + cell.SelectedItem.Value.ToString(); 37
int pavcelllength = pavcell.Length; 38
string sql = "select Code,ownerID from room where left(Code," + pavcelllength + ")=" + pavcell + ""; 39
// Response.Write(sql); 40
// Response.End(); 41
bc.ExecDropDownList(ddlownerID, sql, "ownerID", "Code"); 42
} 43
44
45
46
47
48
49
50
protected void Button2_Click(object sender, EventArgs e) 51
{ 52
53
string name=txtname.Text.Trim(); 54
string tel=txttel.Text.Trim(); 55
string roomID=txtroomID.Text.Trim(); 56
string cardid=txtcardid.Text.Trim(); 57
string contact=txtcontact.Text.Trim(); 58
string mobile=txtmobile.Text.Trim(); 59
string email=txtemail.Text.Trim(); 60
string unit=txtunit.Text.Trim(); 61
string meme=txtmemo.Text.Trim(); 62
string uid,pwd; 63
if(txtuid.Text=="") 64
{ 65
uid=txtcardid.Text.Trim(); 66
} 67
else 68
{ 69
uid=txtuid.Text.Trim(); 70
} 71
72
if(txtpwd.Text=="") 73
{ 74
pwd = txtcardid.Text.Trim(); 75
76
} 77
else 78
{ 79
pwd=txtpwd.Text.Trim(); 80
} 81
82
83
string varuser = "select Count(*) from homehold where uid='" + uid + "'"; 84
int count = (int)bc.ExecCscalar(varuser); 85
if (count > 0) 86
{ 87
Response.Write("<script>alert('登录用户名重复,请选择其它用户名!');</script>"); 88
89
return; 90
} 91
92
93
string strsql = "select count(*) from homehold where Code='" + ddlownerID.SelectedItem.Value + "'"; 94
95
count = (int)bc.ExecCscalar(strsql); 96
97
if (count > 0) 98
{ 99
Response.Write("<script>alert('已有住户,添加失败,请重试!');</script>"); 100
//Response.Write("qq"); 101
Response.End(); 102
return; 103
104
} 105
else //表明数据库中没有相关信息,执行插入记录 106
{ 107
ArrayList arraySQl=new ArrayList(); 108
string sql = "insert into homehold(code,Name,tel,contact,mobile,Email,cardID,roomID,unit,password,uid,memo)values('"; 109
sql = sql + ddlownerID.SelectedItem.Value.ToString() + "','" + name + "','" + tel + "','" + contact + "','" + mobile + "','" + email + "','" + cardid + "','" + roomID + "','"+unit; 110
sql = sql + "','" + pwd + "','" + uid + "','" + meme + "')"; 111
// Response.Write(sql); 112
//Response.End(); 113
arraySQl.Add(sql); 114
string sql1 = "update room set state=1 where Code='" + ddlownerID.SelectedItem.Value + "'"; 115
arraySQl.Add(sql1); 116
if (bc.ExecSQLTrans(arraySQl)) 117
{ 118
Response.Write("<script>alert('数据保存成功!');location='homehold.aspx'</script>"); 119
120
} 121
else 122
{ 123
Response.Write("<script>alert('数据保存失败!');</script>"); 124
125
return; 126
127
} 128
129
} 130
131
132
133
134
135
136
137
138
} 139
140
141
142
143
protected void cell_SelectedIndexChanged(object sender, EventArgs e) 144
{ 145
string pavcell = pav.SelectedItem.Value.ToString() + cell.SelectedItem.Value.ToString(); 146
int pavcelllength = pavcell.Length; 147
string sql = "select Code,ownerID from room where left(Code," + pavcelllength + ")=" + pavcell + ""; 148
// Response.Write(sql); 149
// Response.End(); 150
bc.ExecDropDownList(ddlownerID, sql, "ownerID", "Code"); 151
} 152
153
//根据文本档中的单元名称查找相应的房间业主信息绑定到相应的地方 154
根据文本档中的单元名称查找相应的房间业主信息绑定到相应的地方 214
} 215




BaseClass bc 
}
}