温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:小区物业管理系统源码
当前文件:
SmallHouse/admin/addhomepark.aspx.cs,打开代码结构图
SmallHouse/admin/addhomepark.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 addpavilion : System.Web.UI.Page 14
{ 15
BaseClass bc = new BaseClass(); 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
19
20
if (Convert.ToString(Session["UID"]) == "") 21
{ 22
Response.Redirect("login.aspx"); 23
24
} 25
if (!IsPostBack) 26
{ 27
this.bind(); 28
29
} 30
31
} 32
33
protected void bind() 34
{ 35
36
37
38
bc.ExecDropDownList(parkname, "select * from basepark", "Name", "parkID"); 39
bc.ExecDropDownList(pav, "select * from pavilion", "Name", "paID");//楼宇 40
bc.ExecDropDownList(cell, "select * from type where type='DY'", "name", "code");//单元 41
string pavcell = pav.SelectedItem.Value.ToString() + cell.SelectedItem.Value.ToString(); 42
int pavcelllength = pavcell.Length; 43
string sql = "select Code,ownerID from room where left(Code," + pavcelllength + ")=" + pavcell + " and state=1"; 44
// Response.Write(sql); 45
// Response.End(); 46
bc.ExecDropDownList(ddlownerID, sql, "ownerID", "Code"); 47
48
49
50
51
52
} 53
54
55
protected void Button1_Click(object sender, EventArgs e) 56
{ 57
string sql = "select amount from basepark where parkID=" + parkname.SelectedItem.Value; 58
59
int parkcount=(int)bc.ExecCscalar(sql);//实际停车数量 60
61
string sql2 = "select count(*) from homepark where parkID=" + parkname.SelectedItem.Value; 62
int parkcounted = (int)bc.ExecCscalar(sql2);//已有车辆数量 63
64
if (parkcounted > parkcount) 65
{ 66
Response.Write("<script language=javascript>alert('停车场已潢,请选择其它停车场!');</script>"); 67
68
return; 69
} 70
else 71
{ 72
string code=ddlownerID.SelectedItem.Value; 73
string parkID = parkname.SelectedItem.Value; 74
string carplace = txtcarplace.Text; 75
string carID = txtcarcode.Text; 76
string type = txttype.Text; 77
string buyDate = txtbuydate.Text; 78
string color = txtcolor.Text; 79
80
//string valsql = "select count(*) from homepark where carplace='" + carplace + "' or carID='" + carID + "'"; 81
//int val=(int)bc.ExecCscalar(valsql);//检查车牌号和车位是否重复添加 82
//if(val>0) 83
//{ 84
// Response.Write("<script language=javascript>alert('车牌号或车位重复,请检查!');</script>"); 85
// return; 86
//} 87
string valsql2 = "select count(*) from homepark where carplace='" + carplace + "' and parkID=" + parkID + ""; 88
int val = (int)bc.ExecCscalar(valsql2); 89
if (val > 0) 90
{ 91
Response.Write("<script language=javascript>alert('停车场:"+parkname.SelectedItem.Text+"停车位已有住户!');</script>"); 92
return; 93
} 94
95
96
97
string insertsql = "insert into homepark (code,parkID,carplace,carID,type,buyDate,color)values('"; 98
insertsql += code + "','" + parkID + "','" + carplace + "','" + carID + "','" +type+"','"+ buyDate + "','" + color + "')"; 99
// Response.Write(insertsql); 100
// Response.End(); 101
if (bc.ExecSql(insertsql)) 102
{ 103
Response.Write("<script language=javascript>alert('添加住户车输信息成功!');location='homepark.aspx'</script>"); 104
return; 105
} 106
else 107
{ 108
Response.Write("<script language=javascript>alert('添加住户车辆信息失败!')</script>"); 109
110
return; 111
} 112
113
114
115
116
117
} 118
119
120
} 121
122
protected void cell_SelectedIndexChanged(object sender, EventArgs e) 123
{ 124
string pavcell = pav.SelectedItem.Value.ToString() + cell.SelectedItem.Value.ToString(); 125
int pavcelllength = pavcell.Length; 126
string sql = "select Code,ownerID from room where left(Code," + pavcelllength + ")=" + pavcell + " and state=1"; 127
// Response.Write(sql); 128
// Response.End(); 129
bc.ExecDropDownList(ddlownerID, sql, "ownerID", "Code"); 130
} 131
} 132




BaseClass bc 
}
}