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 viewCustomer_RowDeleting(object sender, GridViewDeleteEventArgs e) { String memberEmail = viewCustomerGrid.Rows[e.RowIndex].Cells[1].Text; Member x = MemberRepositories.findEmail(memberEmail); int row = MemberRepositories.deleteMember(x); lblErr.Text = "Deletion Success!"; if (row > 0) { loadData(); } }
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"; } }
void loadData() { viewCustomerGrid.DataSource = MemberRepositories.getAllMemberOnly(); viewCustomerGrid.DataBind(); }
protected void btnRegister_Click(object sender, EventArgs e) { String name = txtName.Text; String email = txtEmail.Text; String password = txtPassword.Text; String cPassword = txtConfirmPassword.Text; String phone = txtPhone.Text; String address = txtAddress.Text; System.DateTime dob; Member member = MemberRepositories.findEmail(email); erMessage.Text = ""; erMessage.ForeColor = System.Drawing.Color.Red; if (member == null) { if (!DateTime.TryParse(txtDOB.Text, out dob)) { erMessage.Text = "Wrong input of DOB"; } else if (name == "") { erMessage.Text = "Name Must Not Empty"; } else if (email == "") { erMessage.Text = "Email Must Not Empty"; } else if (checkEmail(email) == false) { erMessage.Text = "Wrong Email Format"; } else if (password == "") { erMessage.Text = "Password Must Not Empty"; } else if (cPassword != password) { erMessage.Text = "Password Not Match"; } else if (phone == "") { erMessage.Text = "Phone Must Not Empty"; } else if (address == "") { erMessage.Text = "Address Must Not Empty"; } else { Member m = Factory.MemberFactory.create(name, email, password, dob, phone, address); int row = MemberRepositories.register(m); if (row > 0) { erMessage.ForeColor = System.Drawing.Color.Blue; erMessage.Text = "Register Success"; } else { erMessage.Text = "Register Failed"; } } } else { erMessage.Text = "Email Already Taken"; } }