//when register button are clicked protected void btnRegister_Click(object sender, EventArgs e) { Member m = new Member() { Email = tbxEmail.Text, Name = tbxName.Text, Password = tbxPw.Text, PhoneNo = Convert.ToInt32(tbxPhone.Text), Address = tbxAddress.Text }; int id = ParticipantMgr.insertParticipant(m); lblOutput.Text = id + " Added!"; //send an email by using smpt client of gmail.com SmtpClient client = new SmtpClient("smtp.gmail.com"); client.EnableSsl = true; client.Credentials = new NetworkCredential("*****@*****.**", "inft.3050"); MailMessage message = new MailMessage("*****@*****.**", tbxEmail.Text); message.Subject = "Registration"; message.Body = "Registration successful!"; client.Send(message); lblOutput.Text = "Please check email for username and password"; }
protected void Page_Load(object sender, EventArgs e) { //if session of user is null if (Session["user"] == null) { //if session of admin is not null if (Session["admin"] != null) { //list the gridview from database List <Member> members = ParticipantMgr.getAllParticipant(); gvMember.DataSource = members; gvMember.DataBind(); } else { //redirect to the invalid page Response.Redirect("InvalidPage.aspx"); } } else { //redirect to the invalid page Response.Redirect("InvalidPage.aspx"); } }
protected void gvMember_SelectedIndexChanged(object sender, EventArgs e) { Panel1.Visible = true; List <Member> members = ParticipantMgr.getAllParticipant(); Member m = members[gvMember.SelectedIndex]; List <ShoppingCart> shoppingcarts = ShoppingCartDBMgr.getAllShoppingCartByAdmin(m.Email); gvShoppingCart.DataSource = shoppingcarts; gvShoppingCart.DataBind(); }
//when update button are being clicked protected void btnUpdate_Click(object sender, EventArgs e) { //calling member class to the session of user Member m = (Member)Session["user"]; m.Name = tbxName.Text; m.Email = tbxEmail.Text; m.PhoneNo = Convert.ToInt32(tbxPhone.Text); m.Address = tbxAddress.Text; m.Password = tbxPw.Text; m.CPassword = tbxCpw.Text; Session["user"] = m; int row = ParticipantMgr.updateParticipant(m); //display an output lblOutput.Text = "Update successfully!"; databinded(); }
protected void btnLogin_Click(object sender, EventArgs e) { //create an admin account if (tbxEmail.Text == "*****@*****.**" && tbxPassword.Text == "admin") { //create a session for admin Session["admin"] = tbxEmail.Text; //redirect to AdminView page Server.Transfer("AdminView.aspx"); } //check the boolean is true bool found = true; //call participant database to the member login Member m = ParticipantMgr.getParticipantByEmail(tbxEmail.Text, tbxPassword.Text); if (m != null) { if (m.Email == tbxEmail.Text) { found = true; if (m.Password == tbxPassword.Text) { //create session for user Session["user"] = m; //redirect to the default page Server.Transfer("Default.aspx"); } else { lblOutput.Text = "Incorrect password"; } } //if boolean is false //user have not register yet if (found == false) { //to show invalid email and password lblOutput.Text = "Invalid email and password!"; } } }