示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.EditPageUrl = "RoleList.aspx";

        if (!Page.IsPostBack)
        {
            if (Request.QueryString["id"] == null)
                panelEdit.Visible = false;
            else
            {
                panelEdit.Visible = true;
                int roleId = int.Parse(Request.QueryString["id"]);
                ViewState["roleId"] = roleId;

                if (roleId == 0)
                {
                    txtRoleId.Text = "{����}";
                    txtRoleId.ForeColor = System.Drawing.Color.Red;
                    txtRole.Text = "";
                    btnDelete.Visible = false;
                }
                else
                {
                    UserBiz biz = new UserBiz();
                    txtRoleId.Text = roleId.ToString();
                    txtRoleId.ForeColor = System.Drawing.Color.DarkBlue;
                    txtRole.Text = biz.GetRoleNameById(roleId);
                    btnDelete.Visible = true;
                }
            }
        }
    }
示例#2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if ((int)ViewState["roleId"] == 0)
     {
         OmeiRole biz = new OmeiRole();
         biz.AddRole(txtRole.Text);
     }
     else
     {
         UserBiz biz = new UserBiz();
         biz.UpdateRoleName((int)ViewState["roleId"], txtRole.Text);
     }
 }
示例#3
0
        public string RecoverPassword(string email)
        {
            UserBiz biz = new UserBiz();
            int userId = biz.GetUserIdByEmail(email);
            if (userId < 0)
            {
                base.ErrorMessage = "��Email����]���]�ԣ�Ո��<a href=\"signup.aspx\">���Ñ��]������M�]�ԡ�</a>";
                return null;
            }

            string newPassword = RandomPassword.Generate(4);
            if (ChangePassword(userId, newPassword))
                return newPassword;
            else
                return null;
        }
示例#4
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["roleId"] <= 0) return;

        OmeiRole biz = new OmeiRole();
        UserBiz ubiz = new UserBiz();
        string roleName = ubiz.GetRoleNameById((int)ViewState["roleId"]);
        int roleMem = biz.GetUsersInRole(roleName).Length;
        if (roleMem > 0)
        {
            txtMessage.Text = string.Format("��ɫ[{0}]��߀��{1}���Ñ�����܄h����", roleName, roleMem);
            txtMessage.ForeColor = System.Drawing.Color.Red;
        }
        else
        {
            biz.DeleteRole(roleName);
            txtMessage.Text = string.Format("��ɫ[{0}]�фh����",roleName);
            txtMessage.ForeColor = System.Drawing.Color.DarkGreen;
        }
    }