Exemplo n.º 1
0
    //修改资料
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        string userNickName = this.UserNickName.Text.Trim();

        this.Label3.Text = "";
        string userEmail = this.UserEmail.Text.Trim();

        if (userEmail != "")
        {
            if (!ValidHelper.CheckEmail(userEmail))
            {
                this.Label3.Text = "邮箱格式填写错误!";
                return;
            }
        }

        string userPhone = this.UserPhone.Text.Trim();

        if (userPhone != "")
        {
            if (!ValidHelper.CheckPhone(userPhone))
            {
                this.Label6.Text = "手机号码填写错误!";
                return;
            }
        }

        string userWorkDay = this.UserWorkDay.SelectedValue;

        string categoryRate = this.CategoryRate.Text.Trim();

        if (!ValidHelper.CheckDouble(categoryRate))
        {
            Utility.Alert(this, "预算率填写错误!");
            return;
        }

        UserEntity user = UserAccess.GetUserById(userId);

        user.UserNickName = userNickName;
        user.UserEmail    = userEmail;
        user.UserPhone    = userPhone;
        user.UserWorkDay  = userWorkDay;
        user.CategoryRate = Double.Parse(categoryRate);
        user.Synchronize  = 1;

        bool success = UserAccess.UpdateUser(user);

        if (success)
        {
            Session["UserNickName"] = user.UserNickName;
            Session["UserWorkDay"]  = user.UserWorkDay;
            Session["CategoryRate"] = user.CategoryRate;
            Utility.Alert(this, "修改成功。", "UserAdmin.aspx");
        }
        else
        {
            Utility.Alert(this, "修改失败!");
        }
    }
Exemplo n.º 2
0
    //注册按钮
    protected void SubmitButtom_Click(object sender, EventArgs e)
    {
        string userName      = this.UserName.Text.Trim();
        string userPassword  = this.UserPassword.Text.Trim();
        string userPassword2 = this.UserPassword2.Text.Trim();
        string userNickName  = this.UserNickName.Text.Trim();
        string userEmail     = this.UserEmail.Text.Trim();
        string userTheme     = "main";
        string userWorkDay   = this.UserWorkDay.SelectedValue;

        if (!ValidHelper.CheckLength(userName, 2))
        {
            Utility.Alert(this, "用户名填写错误!");
            return;
        }

        bool success = bll.UserExists(userName);

        if (success)
        {
            Utility.Alert(this, "用户名重复!");
            return;
        }

        if (!ValidHelper.CheckLength(userPassword, 2))
        {
            Utility.Alert(this, "密码填写错误!");
            return;
        }

        if (userPassword2 == "")
        {
            Utility.Alert(this, "重复密码未填写!");
            return;
        }

        if (userPassword != userPassword2)
        {
            Utility.Alert(this, "两次密码不一致!");
            return;
        }

        if (userEmail != "")
        {
            if (!ValidHelper.CheckEmail(userEmail))
            {
                Utility.Alert(this, "邮箱格式填写错误!");
                return;
            }
        }

        if (Request.Cookies["ThemeCookie"] != null)
        {
            userTheme = Request.Cookies["ThemeCookie"].Value;
        }

        UserInfo user = new UserInfo();

        user.UserName     = userName;
        user.UserPassword = userPassword;
        user.UserNickName = userNickName;
        user.UserEmail    = userEmail;
        user.UserWorkDay  = userWorkDay;
        user.UserTheme    = userTheme;
        user.IsUpdate     = 1;

        success = bll.InsertUser(user);
        if (success)
        {
            Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd");

            UserInfo newUser = bll.GetUserByUserPassword(userName, userPassword);
            UserHelper.SaveSession(newUser);

            Utility.Alert(this, "注册成功。", "Default.aspx");
        }
        else
        {
            Utility.Alert(this, "注册失败!");
        }
    }
Exemplo n.º 3
0
    //修改资料
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        string userNickName = this.UserNickName.Text.Trim();
        string userEmail    = this.UserEmail.Text.Trim();
        string userPhone    = this.UserPhone.Text.Trim();
        string userWorkDay  = this.UserWorkDay.SelectedValue;
        string categoryRate = this.CategoryRate.Text.Trim();

        this.Label3.Text = "";
        if (userEmail != "")
        {
            if (!ValidHelper.CheckEmail(userEmail))
            {
                this.Label3.Text = "邮箱格式填写错误!";
                return;
            }
        }

        if (userPhone != "")
        {
            if (!ValidHelper.CheckPhone(userPhone))
            {
                this.Label6.Text = "手机号码填写错误!";
                return;
            }
        }

        if (!ValidHelper.CheckNumber(categoryRate))
        {
            Utility.Alert(this, "预算率填写错误!");
            return;
        }

        int rateValue = Convert.ToInt32(categoryRate);

        if (rateValue > 100)
        {
            Utility.Alert(this, "预算率不能大于100!");
            return;
        }

        user.UserNickName = userNickName;
        user.UserEmail    = userEmail;
        user.UserPhone    = userPhone;
        user.UserWorkDay  = userWorkDay;
        user.CategoryRate = rateValue;
        user.Synchronize  = 1;
        user.ModifyDate   = DateTime.Now;

        bool success = bll.UpdateUser(user);

        if (success)
        {
            Session["UserNickName"] = user.UserNickName;
            Session["UserWorkDay"]  = user.UserWorkDay;
            Session["CategoryRate"] = user.CategoryRate;
            Utility.Alert(this, "修改成功。", "UserAdmin.aspx#info");
        }
        else
        {
            Utility.Alert(this, "修改失败!");
        }
    }
Exemplo n.º 4
0
    protected void SubmitButtom_Click(object sender, EventArgs e)
    {
        string userName      = this.UserName.Text.Trim();
        string userPassword  = this.UserPassword.Text.Trim();
        string userPassword2 = this.UserPassword2.Text.Trim();
        string userNickName  = this.UserNickName.Text.Trim();
        string userEmail     = this.UserEmail.Text.Trim();
        string userTheme     = "main";
        string userWorkDay   = this.UserWorkDay.SelectedValue;

        if (!ValidHelper.CheckLength(userName, 2))
        {
            Utility.Alert(this, "用户名填写错误!");
            return;
        }

        bool repeat = UserAccess.CheckUserRepeat(userName);

        if (repeat)
        {
            Utility.Alert(this, "用户名重复!");
            return;
        }

        if (!ValidHelper.CheckLength(userPassword, 2))
        {
            Utility.Alert(this, "密码填写错误!");
            return;
        }

        if (userPassword2 == "")
        {
            Utility.Alert(this, "重复密码未填写!");
            return;
        }

        if (userPassword != userPassword2)
        {
            Utility.Alert(this, "两次密码不一致!");
            return;
        }

        if (userEmail != "")
        {
            if (!ValidHelper.CheckEmail(userEmail))
            {
                Utility.Alert(this, "邮箱格式填写错误!");
                return;
            }
        }

        if (Request.Cookies["ThemeCookie"] != null)
        {
            userTheme = Request.Cookies["ThemeCookie"].Value;
        }

        UserEntity user = new UserEntity();

        user.UserName     = userName;
        user.UserPassword = userPassword;
        user.UserNickName = userNickName;
        user.UserImage    = "none.gif";
        user.UserEmail    = userEmail;
        user.UserWorkDay  = userWorkDay;
        user.UserTheme    = userTheme;
        user.UserFrom     = "web";
        user.UserPhone    = "";
        user.UserMoney    = 0;
        user.CategoryRate = 90;

        int  userId  = 0;
        bool success = UserAccess.InsertUser(user, out userId);

        if (success)
        {
            Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd");

            UserEntity newUser = UserAccess.GetUserById(userId);
            Session["UserID"]       = newUser.UserID;
            Session["UserName"]     = newUser.UserName;
            Session["UserNickName"] = newUser.UserNickName;
            Session["UserTheme"]    = newUser.UserTheme;
            Session["UserLevel"]    = newUser.UserLevel.ToString();
            Session["UserFrom"]     = newUser.UserFrom;
            Session["UserWorkDay"]  = newUser.UserWorkDay;
            Session["UserFunction"] = newUser.UserFunction;
            Session["CategoryRate"] = user.CategoryRate;

            Utility.Alert(this, "注册成功。", "Default.aspx");
        }
        else
        {
            Utility.Alert(this, "注册失败!");
        }
    }