public void ShowData() { if (Request["AdminID"] + "" == "") { Response.Redirect("RightsWarn.aspx"); } else { int i; if (!int.TryParse(Request["AdminID"].ToString(), out i)) { Response.Redirect("RightsWarn.aspx"); } else { try { WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo(); WebProject.Model.SysManage.ZT_SYS_AdminInfo model_AdminInfo = bll_AdminInfo.GetModel(Int32.Parse(Request["AdminID"].ToString())); this.lblAdminNo.Text = model_AdminInfo.AdminNo.ToString(); this.txtIsLockedOut.SelectedValue = model_AdminInfo.IsLockedOut.ToString(); this.txtRole.SelectedValue = model_AdminInfo.RoleNo.ToString(); } catch { Response.Redirect("RightsWarn.aspx"); } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo(); WebProject.Model.SysManage.ZT_SYS_AdminInfo model_AdminInfo = bll_AdminInfo.GetModel(SessionUtil.GetAdminSession().AdminID); if (this.txtOldPwd.Text.Trim() == "") { MessageBox.Show(this, "原密码不能为空!"); } else if (this.txtNewPwd.Text.Trim() == "") { MessageBox.Show(this, "新密码不能为空!"); } else if (this.txtOkNewPwd.Text.Trim() == "") { MessageBox.Show(this, "新密码不能为空!"); } else if (this.txtNewPwd.Text.Trim() != this.txtOkNewPwd.Text.Trim()) { MessageBox.Show(this, "两次输入的新密码不一致!"); } else if (WebProject.Common.Encrypt.MD5Encrypt.MD5(this.txtOldPwd.Text.Trim()) != model_AdminInfo.Password.ToString()) { MessageBox.Show(this, "原密码不正确,请重新输入!"); } else { model_AdminInfo.Password = WebProject.Common.Encrypt.MD5Encrypt.MD5(this.txtNewPwd.Text.Trim()); bll_AdminInfo.Update(model_AdminInfo); LogManage.WriteLog(Request.UserHostAddress, "用户管理", "修改密码", "成功", "操作名:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.ShowAndRedirect(this, "密码修改成功!", "Main.aspx"); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (!Communal.CheckQx("AdminDelete.aspx")) { Response.Redirect("RightsWarn.aspx"); } else { //删除数据库的信息 Label ll = (Label)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("lblAdminID"); int AdminID = Convert.ToInt32(ll.Text); WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo(); LogManage.WriteLog(Request.UserHostAddress, "用户管理", "删除用户", "成功", "用户名:" + bll_AdminInfo.GetModel(AdminID).AdminNo + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); bll_AdminInfo.Delete(AdminID); //重新加载信息 ShowData(); } } }
public void ShowData() { WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo(); DataSet ds = bll_AdminInfo.GetList(" 1=1 "); if (ds.Tables[0].Rows.Count > 0) { this.GridView1.Visible = true; this.GridView1.DataSource = ds; this.GridView1.DataBind(); } else { this.GridView1.Visible = false; } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (Request["AdminID"] + "" == "") { Response.Redirect("RightsWarn.aspx"); } else { if (CheckString.CheckSqlKeyWord(this.txtPassword.Text) == true) { MessageBox.Show(this, "密码中请不要包含非法字段!"); return; } try { WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo(); WebProject.Model.SysManage.ZT_SYS_AdminInfo model_AdminInfo = bll_AdminInfo.GetModel(Int32.Parse(Request["AdminID"].ToString())); model_AdminInfo.RoleNo = this.txtRole.SelectedValue; model_AdminInfo.IsLockedOut = this.txtIsLockedOut.SelectedValue; model_AdminInfo.LastUpdateBy = SessionUtil.GetAdminSession().AdminNo; model_AdminInfo.LastUpdateDate = DateTime.Now; if (this.txtPassword.Text.Trim() != "") { model_AdminInfo.Password = WebProject.Common.Encrypt.MD5Encrypt.MD5(this.txtPassword.Text.Trim()); } bll_AdminInfo.Update(model_AdminInfo); LogManage.WriteLog(Request.UserHostAddress, "用户管理", "修改用户", "成功", "用户名:" + model_AdminInfo.AdminNo + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.ShowAndRedirect(this, "修改用户信息成功!", "AdminList.aspx"); } catch { Response.Redirect("RightsWarn.aspx"); } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo(); if (this.txtAdminNo.Text.Trim() == "") { MessageBox.Show(this, "用户名不能为空!"); return; } if (this.txtPassword.Text.Trim() == "") { MessageBox.Show(this, "密码不能为空!"); return; } if (CheckString.CheckSqlKeyWord(this.txtAdminNo.Text) == true || CheckString.CheckSqlKeyWord(this.txtPassword.Text) == true) { MessageBox.Show(this, "用户名和密码中请不要包含非法字段!"); return; } if (bll_AdminInfo.GetModelList(" AdminNo='" + this.txtAdminNo.Text.Trim() + "'").Count > 0) { MessageBox.Show(this, "用户名已存在!"); return; } WebProject.Model.SysManage.ZT_SYS_AdminInfo model_AdminInfo = new WebProject.Model.SysManage.ZT_SYS_AdminInfo(); model_AdminInfo.AdminNo = this.txtAdminNo.Text.Trim(); model_AdminInfo.Password = WebProject.Common.Encrypt.MD5Encrypt.MD5(this.txtPassword.Text.Trim()); model_AdminInfo.IsLockedOut = this.txtIsLockedOut.SelectedValue.ToString(); model_AdminInfo.RoleNo = this.txtRole.SelectedValue.ToString(); model_AdminInfo.CreateBy = SessionUtil.GetAdminSession().AdminNo; model_AdminInfo.CreateDate = DateTime.Now; bll_AdminInfo.Add(model_AdminInfo); LogManage.WriteLog(Request.UserHostAddress, "用户管理", "添加用户", "成功", "用户名:" + model_AdminInfo.AdminNo + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.ShowAndRedirect(this, "添加用户成功!", "AdminList.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { string url = Request.Url.ToString(); if (CheckString.CheckSqlKeyWord(url) == true) { MessageBox.ShowAndRedirect(this, "你的IP地址为:" + Page.Request.UserHostAddress + ",请不要输入非法字段!", "Login.aspx"); } else { if (!IsPostBack) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (!Communal.CheckQx("LogList.aspx")) { Response.Redirect("RightsWarn.aspx"); } else { WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo(); DataSet ds = bll_AdminInfo.GetList(" 1=1 "); BindData.BindDropDownList("所有用户", "ALL", "AdminNo", "AdminNo", ds, txtCreateBy); ShowData(this.txtCreateBy.SelectedValue.ToString(), this.txtLogType.SelectedValue.ToString()); this.btnDeleteSelect.Attributes.Add("onclick", "return confirm('您确认要删除这些记录?');"); } } } } }
public void ShowData() { WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo(); WebProject.Model.SysManage.ZT_SYS_AdminInfo model_AdminInfo = bll_AdminInfo.GetModel(SessionUtil.GetAdminSession().AdminID); this.lblAdminNo.Text = model_AdminInfo.AdminNo; }
protected void btnLogin_Click(object sender, ImageClickEventArgs e) { if (this.txtAdminName.Text.Trim() == "") //当用户名为空时触发的事件 { MessageBox.Show(this, "用户名不能为空,请重新输入!"); this.txtPassword.Text = ""; this.txtCheckNum.Text = ""; this.txtAdminName.Focus(); } else { if (this.txtPassword.Text.Trim() == "") //当密码为空时触发的事件 { MessageBox.Show(this, "密码不能为空,请重新输入!"); this.txtCheckNum.Text = ""; this.txtPassword.Focus(); } else { if (this.txtCheckNum.Text.Trim() == "") //当验证码为空时触发的事件 { MessageBox.Show(this, "验证码不能为空,请重新输入!"); this.txtPassword.Text = ""; this.txtPassword.Focus(); } else //当所有项全部不为空时触发的事件 { if (this.txtCheckNum.Text.Trim().ToLower() != Session["validate_code"].ToString().ToLower()) //判断用户填写的验证码和生成的验证码是否一致,当不一致时触发的事件 { MessageBox.Show(this, "验证码不正确,请重新输入!"); this.txtPassword.Text = ""; this.txtCheckNum.Text = ""; this.txtPassword.Focus(); } else //判断用户填写的验证码和生成的验证码是否一致,当一致时触发的事件 { //判断用户名和密码中是否含有非法字段 if (CheckString.CheckSqlKeyWord(this.txtAdminName.Text) == true || CheckString.CheckSqlKeyWord(this.txtPassword.Text) == true) { MessageBox.ShowAndRedirect(this, "你的IP地址为:" + Page.Request.UserHostAddress + ",请不要输入非法字段!", "Login.aspx"); } else { WebProject.BLL.SysManage.ZT_SYS_AdminInfo bll_AdminInfo = new WebProject.BLL.SysManage.ZT_SYS_AdminInfo(); DataSet ds = bll_AdminInfo.GetList("AdminNo='" + this.txtAdminName.Text.Trim() + "'"); if (ds.Tables[0].Rows.Count == 0) //当用户名不存在触发的事件 { MessageBox.Show(this, "用户名不存在,请重新输入!"); this.txtAdminName.Text = ""; this.txtPassword.Text = ""; this.txtCheckNum.Text = ""; this.txtAdminName.Focus(); } else if (ds.Tables[0].Rows.Count > 0) { string PassWord = MD5Encrypt.MD5(this.txtPassword.Text.Trim()); if (ds.Tables[0].Rows[0]["Password"].ToString() != PassWord) { MessageBox.Show(this, "密码错误,请重新输入!"); this.txtPassword.Text = ""; this.txtCheckNum.Text = ""; this.txtPassword.Focus(); } else { if (ds.Tables[0].Rows[0]["IsLockedOut"].ToString() == "1") { MessageBox.Show(this, "此帐号已被禁用!"); this.txtPassword.Text = ""; this.txtCheckNum.Text = ""; this.txtPassword.Focus(); } else { if (ds.Tables[0].Rows[0]["RoleNo"].ToString() == "") { MessageBox.Show(this, "此帐号还没有被分配权限!"); this.txtPassword.Text = ""; this.txtCheckNum.Text = ""; this.txtPassword.Focus(); } else { int AdminID = 0; string AdminNo = "", AdminName = "", RoleNo = ""; if (ds.Tables[0].Rows[0]["AdminID"].ToString() != "") { AdminID = Convert.ToInt32(ds.Tables[0].Rows[0]["AdminID"]); } if (ds.Tables[0].Rows[0]["AdminNo"].ToString() != "") { AdminNo = ds.Tables[0].Rows[0]["AdminNo"].ToString(); } if (ds.Tables[0].Rows[0]["AdminName"].ToString() != "") { AdminName = ds.Tables[0].Rows[0]["AdminName"].ToString(); } if (ds.Tables[0].Rows[0]["RoleNo"].ToString() != "") { RoleNo = ds.Tables[0].Rows[0]["RoleNo"].ToString(); } WebProject.BLL.SysManage.ZT_SYS_RoleInfo bll_RoleInfo = new WebProject.BLL.SysManage.ZT_SYS_RoleInfo(); string RoleName = ""; DataSet ds2 = bll_RoleInfo.GetList(" RoleNo='" + RoleNo + "'"); if (ds2.Tables[0].Rows.Count > 0) { if (ds2.Tables[0].Rows[0]["RoleName"].ToString() != "") { RoleName = ds2.Tables[0].Rows[0]["RoleName"].ToString(); } } AdminSession adminSession = new AdminSession(AdminID, AdminNo, AdminName, RoleNo, RoleName); SessionUtil.SaveAdminSession(adminSession); this.txtAdminName.Text = ""; this.txtPassword.Text = ""; this.txtCheckNum.Text = ""; this.txtAdminName.Focus(); LogManage.WriteLog(Request.UserHostAddress, "登陆退出", "系统登陆", "成功", " 管理员登陆系统"); WebProject.Model.SysManage.ZT_SYS_AdminInfo model_AdminInfo = bll_AdminInfo.GetModel(AdminID); model_AdminInfo.LastLoginDate = DateTime.Now; bll_AdminInfo.Update(model_AdminInfo); Page.Response.Redirect("Index.aspx"); } } } } } } } } } }