Пример #1
0
        private void btn_register_Click(object sender, EventArgs e)
        {
            string pat = @"^([\w]+)@([\w]+)\.([\w]+)$";

            if (txt_name.Text == "" || txt_password.Text == "" || txt_email.Text == "")
            {
                MessageBox.Show("please fill mandatory fields!");
            }
            else if (txt_password.Text != txt_confirmPassword.Text)
            {
                MessageBox.Show("Password do not match!");
            }
            else if (Regex.IsMatch(txt_email.Text, pat))
            {
                using (SqlConnection con = new SqlConnection(connection))
                {
                    con.Open();
                    string     reg    = "INSERT INTO buger(name,email,password,role) VALUES ('" + txt_name.Text + "','" + txt_email.Text + "', '" + txt_password.Text + "', '" + combo_role.Text + "')";
                    SqlCommand sqlCmd = new SqlCommand(reg, con);
                    sqlCmd.ExecuteNonQuery();
                    MessageBox.Show("Registration is successfull");
                    try
                    {
                        SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                        client.EnableSsl             = true;
                        client.Timeout               = 10000;
                        client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        client.UseDefaultCredentials = false;
                        client.Credentials           = new NetworkCredential("*****@*****.**", "Cloud10080618");
                        MailMessage msg = new MailMessage();
                        msg.To.Add(txt_email.Text);
                        msg.From    = new MailAddress("*****@*****.**");
                        msg.Subject = "hi " + txt_name.Text;
                        msg.Body    = "You just register the bug tracker. Enjoying :)";
                        client.Send(msg);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    this.Hide();
                    if (combo_role.Text == "tester")
                    {
                        tester te = new tester(txt_name.Text);
                        te.Show();
                    }
                    else
                    {
                        developer de = new developer(txt_name.Text);
                        de.Show();
                    }
                }
            }
            else
            {
                MessageBox.Show("The email address is not valid!");
            }
        }
Пример #2
0
 /// <summary>
 /// tester login.
 /// </summary>
 /// <param name="sender">Event Sender</param>
 /// <param name="e">Event Arguments</param>
 /// <remarks>
 /// login will check the email and password. if there are,  tester can enter to tester form.
 /// </remarks>
 /// <example>
 /// <code>
 ///     using (SqlConnection con = new SqlConnection(connection))
 ///     {
 ///         SqlDataAdapter da = new SqlDataAdapter("Select name From [user] where email = '" + textBox1.Text + "' and password= '******'", con);
 ///         DataTable dt = new DataTable();
 ///         da.Fill(dt);
 ///
 ///         if (dt.Rows.Count == 1)
 ///         {
 ///             this.Hide();
 ///             tester tester = new tester(dt.Rows[0][0].ToString());
 ///             tester.Show();
 ///         }
 ///         else
 ///         {
 ///             MessageBox.Show("Please Check Your e-mail or password");
 ///         }
 /// </code>
 /// </example>
 private void btn_user_login_Click(object sender, EventArgs e)
 {
     using (SqlConnection con = new SqlConnection(connection))
     {
         SqlDataAdapter da = new SqlDataAdapter("Select name From buger where email = '" + textBox1.Text + "' and password= '******' and role = 'tester'", con);
         DataTable      dt = new DataTable();
         da.Fill(dt);
         if (dt.Rows.Count == 1)
         {
             this.Hide();
             tester tester = new tester(dt.Rows[0][0].ToString());
             tester.Show();
         }
         else
         {
             MessageBox.Show("Please Check Your e-mail or password");
         }
     }
 }