コード例 #1
0
        private void lbSentmail_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.lbSentmailAgain.Show();
            this.lbSentmail.Hide();
            System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.From = new System.Net.Mail.MailAddress("*****@*****.**");
            if (this.tbEmail.Text == "")
            {
                FError f = new FError("Enter your mail", "Message");
                f.StartPosition = FormStartPosition.CenterScreen;
                f.ShowDialog();
            }
            else
            {
                mail.To.Add(this.tbEmail.Text);
                mail.Subject = "Confirm account";
                code         = random_Digit().ToString();
                mail.Body    = code + " is your confirm code ";
                SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

                smtp.EnableSsl   = true;
                smtp.Credentials = new NetworkCredential("*****@*****.**", "phiphucthe");

                try
                {
                    smtp.Send(mail);
                }

                catch (SmtpException ex)
                {
                    MessageBox.Show("Can't sent your mail");
                }
            }
        }
コード例 #2
0
        public bool Signup(string a, string b, string c)
        {
            if (a.Length < 6 || b.Length < 8)
            {
                FError f = new FError("Password must have more than 7 characters and Username must has more than 5 character", "Message");
                f.StartPosition = FormStartPosition.CenterScreen;
                f.ShowDialog();
                return(false);
            }
            if (findUser(a) == true)
            {
                FError f = new FError("Username were used", "Message");
                f.StartPosition = FormStartPosition.CenterScreen;
                f.ShowDialog();
                return(false);
            }
            if (checkEmail(c) == true)
            {
                FError f = new FError("Email were used", "Message");
                f.StartPosition = FormStartPosition.CenterScreen;
                f.ShowDialog();
                return(false);
            }
            SqlConnection connection = new SqlConnection(connString);

            try
            {
                string statement = "insert into USERINFO(username, hashPass,email) values ("
                                   + "'" + a + "'," + "'" + HashPassword(b) + "','" + c + "')";
                connection.Open();
                SqlCommand command = new SqlCommand(statement, connection);
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                FError f = new FError("Connection or data reader failed", "Error");
                f.StartPosition = FormStartPosition.CenterScreen;
                f.ShowDialog();
                return(false);
            }
            finally
            {
                connection.Close();
            }
            return(true);
        }
コード例 #3
0
 private void btnSignup_Click(object sender, EventArgs e)
 {
     if (Data.CheckForInternetConnection())
     {
         if (this.tbCode.Text != code)
         {
             FError f = new FError(" Code confirm was wrong", "Message");
             f.StartPosition = FormStartPosition.CenterScreen;
             f.ShowDialog();
         }
         else if (!tbxRepeatPass.Text.Equals(tbxPass.Text))
         {
             FError f = new FError("Password and repeat password are not match ", "Message");
             f.StartPosition = FormStartPosition.CenterScreen;
             f.ShowDialog();
         }
         else if (tbEmail.Text == "" || tbEmail.Text.IndexOf("@gmail.com") == -1)
         {
             FError f = new FError("Email is not valid", "Message");
             f.StartPosition = FormStartPosition.CenterScreen;
             f.ShowDialog();
         }
         else
         {
             LoginActivity lg = new LoginActivity();
             if (lg.Signup(tbxUsername.Text, tbxPass.Text, tbEmail.Text))
             {
                 MessageBox.Show("Sign up succesfully!", "Congratulation!");
                 this.Hide();
                 this.Close();
             }
         }
     }
     else
     {
         FError f = new FError("Turn on your Internet connection!", "Error");
         f.Show();
     }
 }
コード例 #4
0
 private void btConfirm_Click(object sender, EventArgs e)
 {
     if (Data.CheckForInternetConnection())
     {
         if (code == tbCode.Text)
         {
             pnNewPass.Show();
             this.lblUserName.Text = "Hello " + login.CheckUserNameFromMail(tbEmail.Text) + " !";
             Data.username         = login.CheckUserNameFromMail(tbEmail.Text);
         }
         else
         {
             FError f = new FError(" Code confirm was wrong", "Message");
             f.StartPosition = FormStartPosition.CenterScreen;
             f.ShowDialog();
         }
     }
     else
     {
         FError f = new FError("Turn on your Internet connection!", "Error");
         f.Show();
     }
 }
コード例 #5
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            this.btnSend.Enabled = false;
            System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.From = new System.Net.Mail.MailAddress("*****@*****.**");
            try
            {
                mail.To.Add("*****@*****.**");
                mail.Subject = "Report";

                mail.Body = tbReport.Text + "\n from user: "******"smtp.gmail.com", 587);

                smtp.EnableSsl   = true;
                smtp.Credentials = new NetworkCredential("*****@*****.**", "phiphucthe");

                try
                {
                    smtp.Send(mail);
                }

                catch (SmtpException ex)
                {
                    MessageBox.Show("Can't sent your mail");
                }
            }
            catch
            {
                FError f = new FError("Your gmail was wrong", "Message");
                f.StartPosition = FormStartPosition.CenterScreen;
                f.ShowDialog();
            }
            finally
            {
                this.Close();
            }
        }