Esempio n. 1
0
        protected void SignUp_Click(object sender, EventArgs e)
        {
            User_Class newUser = new User_Class();

            newUser.Name = Name.Text;
            newUser.Surname = Surname.Text;
            newUser.Pass = Password.Text;
            newUser.Nick = UserName.Text;
            newUser.Email = Email.Text;

            foreach (ListItem li in ListBox1.Items)
            {
                if (li.Selected == true)
                {
                    if (Int32.Parse(li.Value) == 0)
                    {
                        newUser.Gender = 'F';
                    }
                    else if (Int32.Parse(li.Value) == 1)
                    {
                        newUser.Gender = 'M';
                    }

                }
            }

            newUser.Entry_date = DateTime.Now.ToShortDateString();
            newUser.Birth_date = Calendar1.SelectedDate.ToString();
            newUser.Image_url = "../Images/no_image.jpeg";

            if (!newUser.existeUsuario(newUser.Nick))
            {
                newUser.addUser();
                string subject = "[Thanks for signing up Sticky Notes]";
                MailMessage mail = new MailMessage();
                mail.To.Add(Email.Text);
                mail.From = new MailAddress("*****@*****.**");
                mail.Subject = subject;
                mail.Body = "Thanks by have been registered in Sticky Notes.\n\nYour User information is:\nUser: "******"\nPass: "******"\n\nI hope you enjoy our social network.\nSticky Notes’ team.";
                mail.IsBodyHtml = false;
                mail.Priority = MailPriority.Normal;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.EnableSsl = true;
                smtp.Credentials = new NetworkCredential("*****@*****.**", "projecthada");
                smtp.Send(mail);

                Response.Redirect("..//Account/Login.aspx");
            }
            else
            {
                SameUserfailure.Text = "This UserName already exists.";
            }
        }