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

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

            if (member == null)
            {
                txtError.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;

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

                List <Member> m   = DatabaseRepositories.getAllMember(inputemail.Text);
                int           row = DatabaseRepositories.updateMember(m, newPassword);
            }
        }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string memberEmail = GridView1.Rows[e.RowIndex].Cells[1].Text;

            Member m = DatabaseRepositories.findEmail(memberEmail);

            int row = DatabaseRepositories.deleteMember(m);

            if (row > 0)
            {
                Response.Redirect("ViewCustomer.aspx");
            }
            else
            {
                errorText.ForeColor = System.Drawing.Color.Red;
                errorText.Text      = "Delete Failed";
            }
        }
Пример #3
0
        protected void registerBtn_Click(object sender, EventArgs e)
        {
            string name      = inputName.Text;
            string email     = inputEmail.Text;
            string password  = inputPassword.Text;
            string cPassword = confirmPassword.Text;
            string phone     = inputPhoneNumber.Text;
            string address   = inputAddress.Text;

            System.DateTime dob;

            Member member = DatabaseRepositories.findEmail(email);

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

            if (member == null)
            {
                if (!DateTime.TryParse(inputDOB.Text, out dob))
                {
                    txtError.Text = "DOB is Wrong";
                }
                else if (name == "")
                {
                    txtError.Text = "Name Must Not Empty";
                }
                else if (email == "")
                {
                    txtError.Text = "Email Must Not Empty";
                }
                else if (checkEmail(email) == false)
                {
                    txtError.Text = "Wrong Email Format";
                }
                else if (password == "")
                {
                    txtError.Text = "Password Must Not Empty";
                }
                else if (cPassword != password)
                {
                    txtError.Text = "Password Not Match";
                }
                else if (phone == "")
                {
                    txtError.Text = "Phone Must Not Empty";
                }
                else if (address == "")
                {
                    txtError.Text = "Address Must Not Empty";
                }
                else
                {
                    Member m = UserFactory.create(email, password, name, dob, phone, address);

                    int row = DatabaseRepositories.register(m);
                    if (row > 0)
                    {
                        txtError.ForeColor = System.Drawing.Color.Blue;
                        txtError.Text      = "Register Success";
                    }
                    else
                    {
                        txtError.Text = "Register Failed";
                    }
                }
            }
            else
            {
                txtError.Text = "Email Already Taken";
            }
        }