Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string userName     = Request.Form["username"].ToString();
        string userPassword = Request.Form["userpass"].ToString();
        string userNickName = Request.Form["usernickname"].ToString();
        string userImage    = "user.gif";
        string userEmail    = Request.Form["useremail"].ToString();
        string userFrom     = Request.Form["userfrom"] ?? "sjapp";
        string userWorkDay  = Request.Form["userworkday"].ToString();
        string userMoney    = Request.Form["usermoney"] ?? "0";
        string categoryRate = Request.Form["categoryrate"] ?? "90";

        if (userFrom.Length > 5)
        {
            userFrom = userFrom.Replace("_", "");
            userFrom = userFrom.Insert(5, "_");
        }

        UserEntity user = new UserEntity();

        user.UserName     = userName;
        user.UserPassword = userPassword;
        user.UserNickName = userNickName;
        user.UserImage    = userImage;
        user.UserPhone    = "";
        user.UserEmail    = userEmail;
        user.UserTheme    = "main";
        user.UserFrom     = userFrom;
        user.UserWorkDay  = userWorkDay;
        user.UserMoney    = Double.Parse(userMoney);
        user.CategoryRate = Double.Parse(categoryRate);

        string result = "{";

        bool repeat = UserAccess.CheckUserRepeat(userName);

        if (repeat)
        {
            result += "\"result\":\"2\"";
        }
        else
        {
            int  userId  = 0;
            bool success = UserAccess.InsertUser(user, out userId);
            if (success)
            {
                result += "\"result\":\"1\"";
            }
            else
            {
                result += "\"result\":\"0\"";
            }
        }

        result += "}";

        Response.Write(result);
        Response.End();
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int    userId       = Int32.Parse(Request.Form["userid"].ToString());
        string userName     = Request.Form["username"].ToString();
        string userPassword = Request.Form["userpass"].ToString();
        string userNickName = Request.Form["nickname"].ToString();
        string userEmail    = Request.Form["useremail"].ToString();
        string userImage    = Request.Form["userimage"].ToString();
        string userFrom     = Request.Form["userfrom"].ToString();
        string userWorkDay  = Request.Form["userworkday"].ToString();
        string categoryRate = Request.Form["categoryrate"] ?? "";

        if (userFrom.Length > 5)
        {
            userFrom = userFrom.Replace("_", "");
            userFrom = userFrom.Insert(5, "_");
        }

        UserEntity user = UserAccess.GetUserById(userId);

        user.UserName     = userName;
        user.UserPassword = userPassword;
        user.UserNickName = userNickName;
        user.UserImage    = userImage;
        user.UserEmail    = userEmail;
        user.UserFrom     = userFrom;
        user.UserWorkDay  = userWorkDay;
        if (categoryRate != "")
        {
            user.CategoryRate = Double.Parse(categoryRate);
        }

        string result = "{";

        bool login = SyncHelper.SyncCheckUserLogin(userName, userId);

        if (login)
        {
            result += UpdateUserInfo(user);
        }
        else
        {
            bool repeat = UserAccess.CheckUserRepeat(userName);
            if (repeat)
            {
                result += "\"result\":\"2\"";
            }
            else
            {
                result += UpdateUserInfo(user);
            }
        }

        result += "}";

        Response.Write(result);
        Response.End();
    }
Esempio n. 3
0
    //绑定新帐号
    protected void NewButton_Click(object sender, EventArgs e)
    {
        string userName = this.UserNameNew.Text.Trim();

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

        bool repeat = UserAccess.CheckUserRepeat(userName);

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

        string userPassword = this.UserPasswordNew.Text.Trim();

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

        bool success = OAuthAccess.OAuthBoundNew(userId, userName, userPassword);

        if (success)
        {
            PopulateControls();
            Utility.Alert(this, "绑定成功。", "UserBoundAdmin.aspx");
        }
        else
        {
            Utility.Alert(this, "绑定失败!");
        }
    }
Esempio n. 4
0
    protected void List_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        bool success = false;

        int userId = Int32.Parse(AdminList.DataKeys[e.RowIndex].Value.ToString());

        string oldUserName = ((HiddenField)AdminList.Rows[e.RowIndex].FindControl("UserNameHid")).Value;
        string userName    = ((TextBox)AdminList.Rows[e.RowIndex].FindControl("UserNameBox")).Text.Trim();

        if (userName == "")
        {
            Utility.Alert(this, "用户名未填写!");
            return;
        }
        if (oldUserName != userName)
        {
            success = UserAccess.CheckUserRepeat(userName);
            if (success)
            {
                Utility.Alert(this, "用户名重复!");
                return;
            }
        }

        string userPassword = ((TextBox)AdminList.Rows[e.RowIndex].FindControl("UserPassBox")).Text.Trim();

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

        string userNickName = ((TextBox)AdminList.Rows[e.RowIndex].FindControl("UserNickBox")).Text.Trim();

        string     userImage       = ((HiddenField)AdminList.Rows[e.RowIndex].FindControl("UserImageHid")).Value;
        FileUpload userImageUpload = (FileUpload)AdminList.Rows[e.RowIndex].FindControl("UserImageUpload");

        if (userImageUpload.HasFile)
        {
            userImage = "tu_" + userId + ImageHelper.GetImageExt(userImageUpload.FileName);
            string imagePath = Server.MapPath("Images/Users/") + userImage;
            try
            {
                userImageUpload.SaveAs(imagePath);
                ImageHelper.SaveImage(imagePath, 100, 100);
            }
            catch
            {
                Utility.Alert(this, "头像上传失败!");
                return;
            }
        }

        string userEmail    = ((TextBox)AdminList.Rows[e.RowIndex].FindControl("UserEmailBox")).Text.Trim();
        string userTheme    = ((TextBox)AdminList.Rows[e.RowIndex].FindControl("UserThemeBox")).Text.Trim();
        int    userLevel    = Int32.Parse(((TextBox)AdminList.Rows[e.RowIndex].FindControl("UserLevelBox")).Text.Trim());
        string userFrom     = ((TextBox)AdminList.Rows[e.RowIndex].FindControl("UserFromBox")).Text.Trim();
        string categoryRate = ((TextBox)AdminList.Rows[e.RowIndex].FindControl("CategoryRateBox")).Text.Trim();
        string userMoney    = ((TextBox)AdminList.Rows[e.RowIndex].FindControl("UserMoneyBox")).Text.Trim();

        UserEntity user = UserAccess.GetUserById(userId);

        user.UserName     = userName;
        user.UserPassword = userPassword;
        user.UserNickName = userNickName;
        user.UserImage    = userImage;
        user.UserEmail    = userEmail;
        user.UserTheme    = userTheme;
        user.UserLevel    = userLevel;
        user.UserFrom     = userFrom;
        user.CategoryRate = Double.Parse(categoryRate);
        user.UserMoney    = (userMoney == "" ? 0 : Double.Parse(userMoney));
        user.Synchronize  = 1;

        success = UserAccess.UpdateUser(user);
        if (success)
        {
            Utility.Alert(this, "更新成功。");
        }
        else
        {
            Utility.Alert(this, "更新失败!");
            return;
        }

        AdminList.EditIndex = -1;
        SwitchData();
    }
Esempio n. 5
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, "注册失败!");
        }
    }