protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (!Communal.CheckQx("RoleDelete.aspx")) { Response.Redirect("RightsWarn.aspx"); } else { //删除数据库的信息 Label ll = (Label)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("lblRoleID"); int RoleID = Convert.ToInt32(ll.Text); WebProject.BLL.SysManage.ZT_SYS_RoleInfo bll_RoleInfo = new WebProject.BLL.SysManage.ZT_SYS_RoleInfo(); LogManage.WriteLog(Request.UserHostAddress, "角色管理", "删除角色", "成功", "角色名称:" + bll_RoleInfo.GetModel(RoleID).RoleName + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); bll_RoleInfo.Delete(RoleID); //重新加载信息 ShowData(); } } } }
public void ShowData() { WebProject.BLL.SysManage.ZT_SYS_RoleInfo bll_RoleInfo = new WebProject.BLL.SysManage.ZT_SYS_RoleInfo(); DataSet ds = bll_RoleInfo.GetList(" 1=1 "); if (ds.Tables[0].Rows.Count > 0) { this.lblMessage.Visible = false; this.GridView1.Visible = true; this.GridView1.DataSource = ds; this.GridView1.DataBind(); } else { this.lblMessage.Visible = true; this.GridView1.Visible = false; } }
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 (!this.IsPostBack) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (!Communal.CheckQx("AdminEdit.aspx")) { Response.Redirect("RightsWarn.aspx"); } else { WebProject.BLL.SysManage.ZT_SYS_RoleInfo bll_RoleInfo = new WebProject.BLL.SysManage.ZT_SYS_RoleInfo(); DataSet ds = bll_RoleInfo.GetList(" 1=1 "); BindData.BindDropDownList("RoleName", "RoleNo", ds, txtRole); ShowData(); } } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (this.txtRoleNo.Text.Trim() == "") { MessageBox.Show(this, "请输入角色编号!"); return; } if (this.txtRoleName.Text.Trim() == "") { MessageBox.Show(this, "请输入角色名称!"); return; } try { this.mElemStr = ""; string elems = this.GetAllNodeText(this.TreeView1.Nodes);//+ this.GetAllNodeText(this.TreeView2.Nodes); if (elems.Split(',').Length <= 1) { MessageBox.Show(this, "至少选择一个权限!"); return; } elems = elems.Substring(1); WebProject.BLL.SysManage.ZT_SYS_RoleInfo bll_RoleInfo = new WebProject.BLL.SysManage.ZT_SYS_RoleInfo(); WebProject.Model.SysManage.ZT_SYS_RoleInfo model_RoleInfo = bll_RoleInfo.GetModel(Int32.Parse(Request["RoleID"].ToString())); model_RoleInfo.RoleNo = this.txtRoleNo.Text.Trim(); model_RoleInfo.RoleName = this.txtRoleName.Text.Trim(); model_RoleInfo.RoleElements = elems; model_RoleInfo.LastUpdateBy = SessionUtil.GetAdminSession().AdminNo; model_RoleInfo.LastUpdateDate = DateTime.Now; bll_RoleInfo.Update(model_RoleInfo); LogManage.WriteLog(Request.UserHostAddress, "角色管理", "修改角色", "成功", "角色名:" + model_RoleInfo.RoleName + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.ShowAndRedirect(this, "修改角色信息成功!", "RoleList.aspx"); } catch { Response.Redirect("RightsWarn.aspx"); } } }
public void ShowData() { if (Request["RoleID"] + "" == "") { Response.Redirect("RightsWarn.aspx"); } else { try { WebProject.BLL.SysManage.ZT_SYS_RoleInfo bll_RoleInfo = new WebProject.BLL.SysManage.ZT_SYS_RoleInfo(); WebProject.Model.SysManage.ZT_SYS_RoleInfo model_RoleInfo = bll_RoleInfo.GetModel(Int32.Parse(Request["RoleID"].ToString())); this.txtRoleName.Text = model_RoleInfo.RoleName.ToString(); this.txtRoleNo.Text = model_RoleInfo.RoleNo.ToString(); mExistElems = model_RoleInfo.RoleElements; } catch { Response.Redirect("RightsWarn.aspx"); } } }
public static bool CheckQx(string ElementLink) { if (SessionUtil.GetAdminSession().RoleNo + "" == "") { return false; } else { WebProject.BLL.SysManage.ZT_SYS_RoleInfo bll_RoleInfo = new WebProject.BLL.SysManage.ZT_SYS_RoleInfo(); WebProject.Model.SysManage.ZT_SYS_RoleInfo model_RoleInfo = bll_RoleInfo.GetModel(SessionUtil.GetAdminSession().RoleNo); string RoleElements = model_RoleInfo.RoleElements; WebProject.BLL.SysManage.ZT_SYS_ElementInfo bll_ElementInfo = new WebProject.BLL.SysManage.ZT_SYS_ElementInfo(); DataSet ds = bll_ElementInfo.GetList("ElementLink='" + ElementLink + "'"); if (ds.Tables[0].Rows.Count > 0) { string ElementCode = ds.Tables[0].Rows[0]["ElementCode"].ToString(); if (RoleElements.IndexOf(ElementCode) < 0) { return false; } else { return true; } } else { return false; } } }
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"); } } } } } } } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (this.txtRoleNo.Text.Trim() == "") { MessageBox.Show(this, "请输入角色编号!"); return; } if (this.txtRoleName.Text.Trim() == "") { MessageBox.Show(this, "请输入角色名称!"); return; } WebProject.BLL.SysManage.ZT_SYS_RoleInfo bll_RoleInfo = new WebProject.BLL.SysManage.ZT_SYS_RoleInfo(); if (bll_RoleInfo.GetModelList(" RoleNo='" + this.txtRoleNo.Text.Trim() + "'").Count > 0) { MessageBox.Show(this, "角色编号不能重复!"); return; } this.mElemStr = ""; string elems = this.GetAllNodeText(this.TreeView1.Nodes); if (elems.Split(',').Length <= 1) { MessageBox.Show(this, "至少选择一个权限!"); return; } elems = elems.Substring(1); WebProject.Model.SysManage.ZT_SYS_RoleInfo model_RoleInfo = new WebProject.Model.SysManage.ZT_SYS_RoleInfo(); model_RoleInfo.RoleNo = this.txtRoleNo.Text.Trim(); model_RoleInfo.RoleName = this.txtRoleName.Text.Trim(); model_RoleInfo.RoleElements = elems; model_RoleInfo.CreateBy = SessionUtil.GetAdminSession().AdminNo; model_RoleInfo.CreateDate = DateTime.Now; bll_RoleInfo.Add(model_RoleInfo); LogManage.WriteLog(Request.UserHostAddress, "角色管理", "添加角色", "成功", "角色编号:" + model_RoleInfo.RoleNo + " 角色名称:" + model_RoleInfo.RoleName + "操作人:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.ShowAndRedirect(this, "添加角色成功!", "RoleList.aspx"); } }