protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["User"] == null) { oUser = new Class.User(); oUser.ID = -1; if (String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtPassword.Text)) { error.Style.Add("display", ""); error.Text = "Email and Password are required fields."; } else { oUser.Email = txtEmail.Text; oUser.FirstName = txtFirstname.Text; oUser.LastName = txtLastName.Text; oUser.Password = txtPassword.Text; oUser.Address = txtAddress.Text; oUser.City = txtCity.Text; //oUser.PetType = ddlPettype.SelectedItem.Value; oUser.Phone = txtPhone.Text; oUser.PostalCode = txtPostal.Text; oUser.Province = txtProv.Text; if (!oDB.IsUserExist(oUser)) { if (oDB.UpdateUser(oUser)) { result.Style.Add("display", ""); result.Text = "The profile has been created."; Session["User"] = oUser; // Response.Redirect("register.aspx?reg=1"); Response.Redirect("home.aspx"); } else { error.Style.Add("display", ""); error.Text = "Unexpected Error occurs. Please try it again later."; } } else { error.Style.Add("display", ""); error.Text = "The Email address already exists"; } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["User"] == null) { oUser = new Class.User(); oUser.ID = -1; if (String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtPassword.Text)) { error.Style.Add("display", ""); error.Text = "Email and Password are required fields."; } else { oUser.Email = txtEmail.Text; oUser.FirstName = txtFirstname.Text; oUser.LastName = txtLastName.Text; oUser.Password = txtPassword.Text; oUser.Address = txtAddress.Text; oUser.City = txtCity.Text; //oUser.PetType = ddlPettype.SelectedItem.Value; oUser.Phone = txtPhone.Text; oUser.PostalCode = txtPostal.Text; oUser.Province = txtProv.Text; if (!oDB.IsUserExist(oUser)) { if (oDB.UpdateUser(oUser)) { SmtpClient smtpClient = new SmtpClient(); MailMessage oMessage1 = new MailMessage(); oMessage1.Subject = "Registration confirmation"; oMessage1.Body = "Hi, <br/><br/><br/> Thanks for register to One Stop Pet Shop. <br /> Your User name is " + oUser.Email + "'. <br/><br/><br/><br/><br/><br/><br/><br/>One Stop Pet Shop team. "; oMessage1.IsBodyHtml = true; oMessage1.To.Add(new MailAddress(txtEmail.Text)); oMessage1.From = new MailAddress("*****@*****.**"); // https://www.google.com/settings/security/lesssecureapps smtpClient.Send(oMessage1); oUser = oDB.Login(oUser.Email, oUser.Password); Session["User"] = oUser; result.Style.Add("display", ""); result.Text = "The profile has been created."; Session["User"] = oUser; Response.Redirect("profile.aspx?Created=Y"); } else { error.Style.Add("display", ""); error.Text = "Unexpected Error occurs. Please try it again later."; } } else { error.Style.Add("display", ""); error.Text = "The Email address already exists"; } } } else { oUser = (PetStore.Class.User)Session["User"]; if (txtPassword.Text == "") { error.Style.Add("display", ""); error.Text = "Please enter your password."; } else { oUser.Email = txtEmail.Text; oUser.FirstName = txtFirstname.Text; oUser.LastName = txtLastName.Text; oUser.Password = txtPassword.Text; oUser.Address = txtAddress.Text; oUser.City = txtCity.Text; oUser.Phone = txtPhone.Text; oUser.PostalCode = txtPostal.Text; oUser.Province = txtProv.Text; oDB.UpdateUser(oUser); Session["User"] = oUser; result.Style.Add("display", ""); result.Text = "The profile has been updated."; } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtEmail.Text)) { error.Style.Add("display", ""); result.Style.Add("display", "none"); } else { oUser = new Class.User(); oDB = new PetStore.DB.Data(); oUser.Email = txtEmail.Text; if (oDB.IsUserExist(oUser)) { oUser = oDB.Login(txtEmail.Text, "tempassword12345"); //Guid oGuid = Guid.NewGuid(); Random oRandom = new Random(); int tempPassword = oRandom.Next(100000); oUser.Password = oUser.LastName + tempPassword.ToString(); oDB.UpdateUser(oUser); //update the password with new password //send an email witht the Guid password SmtpClient smtpClient = new SmtpClient(); MailMessage oMessage1 = new MailMessage(); oMessage1.Subject = "New password for One stop pet shop"; oMessage1.Body = "Hi, here is the new password, '" + oUser.Password + "'. <br/> Once you log in the site, please update your password again."; oMessage1.IsBodyHtml = true; oMessage1.To.Add(new MailAddress(txtEmail.Text)); oMessage1.From = new MailAddress("*****@*****.**"); // https://www.google.com/settings/security/lesssecureapps smtpClient.Send(oMessage1); //// SmtpClient client1 = new SmtpClient(); //// client1.Host = "smtp.gmail.com"; //// client1.Port = 587; //// client1.UseDefaultCredentials = false; //// client1.DeliveryMethod = SmtpDeliveryMethod.Network; //// client1.EnableSsl = true; //// client1.Credentials = new NetworkCredential("*****@*****.**", "sendingemail"); ////MailMessage oMessage = new MailMessage(); //// oMessage.Subject = "hello"; //// oMessage.Body = "body"; //// oMessage.To.Add(new MailAddress(txtEmail.Text)); //// oMessage.From = new MailAddress("*****@*****.**"); //// client1.Send(oMessage); //// MailMessage objeto_mail = new MailMessage(); //// SmtpClient client3 = new SmtpClient(); //// client3.Port = 587; //// client3.Host = "smtp.gmail.com"; //// client3.Timeout = 10000; //// client3.DeliveryMethod = SmtpDeliveryMethod.Network; //// client3.UseDefaultCredentials = false; //// client3.EnableSsl = true; //// client3.Credentials = new System.Net.NetworkCredential("*****@*****.**", "sendingemail"); //// objeto_mail.From = new MailAddress("*****@*****.**"); //// objeto_mail.To.Add(new MailAddress(txtEmail.Text)); //// objeto_mail.Subject = "Password Recover"; //// objeto_mail.Body = "Message"; //// client3.Send(objeto_mail); result.Style.Add("display", ""); } else { error.Style.Add("display", ""); } } }