Пример #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Member member = MemberRepositories.findEmail(txtEmail.Text);

            erMessage.Text      = "";
            erMessage.ForeColor = System.Drawing.Color.Red;

            if (member == null)
            {
                erMessage.Text = "Email Not Found";
            }
            else
            {
                string name = member.Name;
                string newPassword;

                const string alphabet = "abcdefghijklmnopqrstuvwxyz";

                Random rand = new Random((int)DateTime.Now.Ticks);

                string number1 = rand.Next(0, 9).ToString();
                string number2 = rand.Next(0, 9).ToString();
                string char1   = alphabet.Substring(rand.Next(0, alphabet.Length - 1), 1);
                string char2   = alphabet.Substring(rand.Next(0, alphabet.Length - 1), 1);
                string cutName = name.Substring(0, 2);

                newPassword = number1 + number2 + char1 + char2 + cutName;

                erMessage.ForeColor = System.Drawing.Color.Green;
                erMessage.Text      = "Your New Password : " + newPassword;

                List <Member> m   = MemberRepositories.getAllMember(txtEmail.Text);
                int           row = MemberRepositories.updateMember(m, newPassword);
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Member currentUser = (Member)Session["userLogin"];

            erMessage.Text      = "";
            erMessage.ForeColor = System.Drawing.Color.Red;

            if (txtOldPassword.Text == "")
            {
                erMessage.Text = "Old Password Must Not Empty";
            }
            else if (txtNewPassword.Text == "")
            {
                erMessage.Text = "New Password Must Not Empty";
            }
            else if (txtConfirmPassword.Text == "")
            {
                erMessage.Text = "Confirm Password Must Not Empty";
            }
            else if (txtOldPassword.Text != currentUser.Password)
            {
                erMessage.Text = "Wrong Old Password";
            }
            else if (txtConfirmPassword.Text != txtNewPassword.Text)
            {
                erMessage.Text = "Password Not Match";
            }
            else
            {
                List <Member> m   = MemberRepositories.getAllMember(currentUser.Email);
                int           row = MemberRepositories.updateMember(m, txtNewPassword.Text);

                erMessage.ForeColor = System.Drawing.Color.Green;
                erMessage.Text      = "Change Password Success";
            }
        }