您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->小区物业管理系统源码>>admin/admin.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:小区物业管理系统源码
当前文件:文件类型 SmallHouse/admin/admin.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12 13 14public partial class admin_Default2 : System.Web.UI.Page 15{ 16 17 18 static string valpass="";//验证原密码是否正确 19 BaseClass bc=new BaseClass(); 20 protected void Page_Load(object sender, EventArgs e) 21 { 22 23 if (Convert.ToString(Session["UID"]) == "") 24 { 25 Response.Redirect("login.aspx"); 26 27 } 28 29 if (!IsPostBack) 30 { 31 this.bind(); 32 } 33 34 35 36 37 } 38 39 //初使时对数据进行绑定 40 protected void bind() 41 { 42 string sqlstr="select * from admin"; 43 bc.ExecGridView(GridView1, sqlstr); 44 45 46 } 47 48 protected void Button3_Click(object sender, EventArgs e) 49 { 50 adduser.Visible = true; 51 } 52 53 //取消输入 54 protected void Button1_Click(object sender, EventArgs e) 55 { 56 tbuser.Text = ""; 57 tbpass.Text = ""; 58 tbtwopass.Text = ""; 59 adduser.Visible = false; 60 } 61 62 //添加用户名 63 protected void btnadduser_Click(object sender, EventArgs e) 64 { 65 66 try 67 { 68 if (val()) 69 { 70 string sqlstr = "insert into admin(name,UID,PWD)values('" + tbname.Text + "','" + tbuser.Text + "','" + tbpass.Text + "')"; 71 72 if (bc.ExecSql(sqlstr)) 73 { 74 Response.Write("<script language=javascript>alert('用户名添加成功!');</script>"); 75 adduser.Visible = false; 76 this.bind(); 77 78 79 } 80 else 81 { 82 Response.Write("<script language=javascript>alert('添加失败,请重试!');</script>"); 83 return; 84 } 85 } 86 else 87 { 88 Response.Write("<script language=javascript>alert('用户名存在,请选择其它用户名!');</script>"); 89 return; 90 } 91 } 92 finally 93 { 94 bc.Closeconn(); 95 } 96 97 } 98 99 100 //验证新的用户名是否存在 101 protected bool val() 102 { 103 string conn = Convert.ToString(ConfigurationManager.ConnectionStrings["SmallHouseConn"]); 104 105 SqlConnection sqlcon = new SqlConnection(conn); 106 sqlcon.Open(); 107 string sqlstr = "select count(*) from admin where uid='" + tbuser.Text + "'"; 108 109 110 //Response.Write(sqlstr); 111 SqlCommand scd = new SqlCommand(sqlstr, sqlcon); 112 int count = Convert.ToInt32(scd.ExecuteScalar()); 113 114 //Response.Write(count); 115 //Response.End(); 116 117 if (count <= 0) 118 { 119 120 return true; 121 } 122 else 123 { 124 125 return false; 126 127 } 128 } 129 //gridview 数数绑定时执行 130 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 131 { 132 if (e.Row.RowType == DataControlRowType.DataRow) 133 { 134 135 136 ((LinkButton)(e.Row.Cells[4].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')"); 137 e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#22dd22';this.Style.color='buttontext';this.Style.cursor='default';"); 138 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color='';"); 139 } 140 } 141 142 143 ///修改密码 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 //删除管理员帐号时执行 159 160 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 161 { 162 163 string uid = GridView1.DataKeys[e.RowIndex].Value.ToString(); 164 165 166 if (Session["UID"].ToString() != uid) 167 { 168 string sqlstr = "delete from admin where ID='" + uid + "'"; 169 //Response.Write(sqlstr); 170 //Response.End(); 171 try 172 { 173 if (bc.ExecSql(sqlstr)) 174 { 175 Response.Write("<script>alert('删除管理员帐号成功!');</script>"); 176 this.bind(); 177 } 178 else 179 { 180 Response.Write("<script>alert('操作失败,请重试!');</script>"); 181 } 182 } 183 catch (Exception ex) 184 { 185 Response.Write("<script>alert('删除失败,失败原因:" + ex.Message.ToString() + "');</script>"); 186 return; 187 } 188 } 189 else 190 { 191 Response.Write("<script>alert('管理员用不能删除自已');</script>"); 192 return; 193 } 194 195 196 197 198 } 199 200}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:小区物业管理系统源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号