温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:小区物业管理系统源码
当前文件:
SmallHouse/admin/areafacility.aspx.cs,打开代码结构图
SmallHouse/admin/areafacility.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.Collections; 12
public partial class admin_areafacility : System.Web.UI.Page 13
{ 14
public static string sql = ""; 15
BaseClass bc = new BaseClass(); 16
stringoperator stroper = new stringoperator(); 17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
20
if (Convert.ToString(Session["UID"]) == "") 21
{ 22
Response.Redirect("login.aspx"); 23
24
} 25
if(!IsPostBack) 26
{ 27
this.bind(); 28
Button6.Attributes.Add("onclick", "javascript:return confirm('你确认要删除吗?')"); 29
30
} 31
32
33
34
} 35
36
public void bind() 37
{ 38
39
bc.ExecDropDownList(DropDownList1, "select * from type where type = 'Area'", "Name", "code"); 40
string strsql = "select * from v_areafac "+sql+"order by ID desc"; 41
42
43
44
45
46
bc.ExecGridView(GridView1, strsql);//绑定数据 47
} 48
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 49
{ 50
if (e.Row.RowType == DataControlRowType.DataRow) 51
{ 52
53
54
// ((LinkButton)(e.Row.Cells[6].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')"); 55
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#99ccff';this.Style.color='buttontext';this.Style.cursor='default';"); 56
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color='';"); 57
} 58
} 59
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 60
{ 61
this.GridView1.PageIndex = e.NewPageIndex; 62
this.bind(); 63
} 64
65
66
//删除记录 67
68
//protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 69
//{ 70
// string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString(); 71
// //Response.Write(id); 72
// //Response.End(); 73
74
// BaseClass bcc = new BaseClass(); 75
// string sqlstr = "delete from areaFacility where ID='" + id + "'"; 76
// if (bcc.ExecSql(sqlstr)) 77
// { 78
// Response.Write("<script>alert('删除信息成功!');</script>"); 79
// this.bind(); 80
// } 81
// else 82
// { 83
// Response.Write("<script>alert('操作失败!');</script>"); 84
// } 85
//} 86
protected void Button1_Click(object sender, EventArgs e) 87
{ 88
Hashtable htabel = new Hashtable(); 89
if (CheckBox1.Checked) 90
{ 91
htabel.Add("unitName", TextBox1.Text); 92
// Response.Write(htabel["unitName"].GetType().ToString()); 93
// Response.End(); 94
95
} 96
if (CheckBox2.Checked) 97
{ 98
htabel.Add("mainHead", TextBox2.Text); 99
100
} 101
if (CheckBox3.Checked) 102
{ 103
htabel.Add("contactPerson", TextBox3.Text); 104
} 105
if (CheckBox4.Checked) 106
{ 107
htabel.Add("tel", TextBox4.Text); 108
} 109
if (CheckBox5.Checked) 110
{ 111
htabel.Add("typeID", Convert.ToInt32(DropDownList1.SelectedValue)); 112
} 113
if (CheckBox6.Checked) 114
{ 115
sql = stroper.GetConditionClause(htabel,true); 116
} 117
else 118
{ 119
sql = stroper.GetConditionClause(htabel,false); 120
} 121
122
//Response.Write(sql); 123
//Response.End(); 124
this.bind(); 125
} 126
protected void Button2_Click(object sender, EventArgs e) 127
{ 128
sql = ""; 129
this.bind(); 130
} 131
//全选 132
protected void Button3_Click(object sender, EventArgs e) 133
{ 134
for (int i = 0; i < GridView1.Rows.Count; i++) 135
{ 136
CheckBox chkSelect = (CheckBox)GridView1.Rows[i].FindControl("chkSelect"); 137
chkSelect.Checked = true; 138
} 139
140
} 141
//反选 142
protected void Button4_Click(object sender, EventArgs e) 143
{ 144
for (int i = 0; i < GridView1.Rows.Count; i++) 145
{ 146
CheckBox chkSelect = (CheckBox)GridView1.Rows[i].FindControl("chkSelect"); 147
chkSelect.Checked = !chkSelect.Checked; 148
} 149
} 150
//取消 151
protected void Button5_Click(object sender, EventArgs e) 152
{ 153
for (int i = 0; i < GridView1.Rows.Count; i++) 154
{ 155
CheckBox chkSelect = (CheckBox)GridView1.Rows[i].FindControl("chkSelect"); 156
chkSelect.Checked = false; 157
} 158
} 159
//删除 160
protected void Button6_Click(object sender, EventArgs e) 161
{ 162
ArrayList sqltrans = new ArrayList(); 163
for (int i = 0; i < GridView1.Rows.Count; i++) 164
{ 165
CheckBox chkSelect = (CheckBox)GridView1.Rows[i].FindControl("chkSelect"); 166
if (chkSelect.Checked) 167
{ 168
string str = ((Label)GridView1.Rows[i].FindControl("labID")).Text; 169
string sqlstr = "delete from areafacility where ID=" + str; 170
171
sqltrans.Add(sqlstr); 172
} 173
174
175
} 176
//foreach (string item in sqltrans) 177
//{ 178
// Response.Write(item + "</br>"); 179
180
//} 181
//Response.End(); 182
if (bc.ExecSQLTrans(sqltrans)) 183
{ 184
Response.Write("<script>alert('删除信息成功!');</script>"); 185
this.bind(); 186
} 187
else 188
{ 189
Response.Write("<script>alert('操作失败!');</script>"); 190
return; 191
} 192
} 193
} 194
195





}
}