Beispiel #1
0
 private void btnRegister_Click(object sender, EventArgs e)
 {
     try
     {
         db.Close();
         db.Open();
         cmd = new MySqlCommand("Select *From user where username  ='******' AND email = '" + txtEmail.Text + "' AND secretanswer ='" + txtSecretanser.Text + "'", db);
         dr  = cmd.ExecuteReader();
         Ping      ping       = new Ping();
         PingReply pingStatus = ping.Send(IPAddress.Parse("216.58.209.14"));
         if (pingStatus.Status == IPStatus.Success)
         {
             if (dr.Read())
             {
                 if (txtUsername.Text.ToString() == dr["username"].ToString())
                 {
                     if (txtEmail.Text.ToString() == dr["email"].ToString())
                     {
                         if (txtSecretanser.Text.ToString() == dr["secretanswer"].ToString())
                         {
                             MessageBox.Show("Your Password : "******"password"].ToString());
                             db.Close();
                             Login log = new Login();
                             log.Show();
                             this.Close();
                         }
                     }
                 }
             }
         }
         else
         {
             MessageBox.Show("Check your Internet connection.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             db.Close();
         }
     }
     catch (MySqlException ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Beispiel #2
0
        private void Create(String username, String password, String email, String fullname, String secretanswer)
        {
            //check credential validity
            if (txtUsername.Text.Trim() != "" &&
                txtPassword.Text.Trim() != "" &&
                txtEmail.Text.Trim() != "" &&
                txtFullname.Text.Trim() != "" &&
                txtSecretanswer.Text.Trim() != "")
            {
                Ping ping = new Ping();
                // ping connectiın google
                PingReply pingStatus = ping.Send(IPAddress.Parse("216.58.209.14"));
                //Check whether the ping was successful (not needed for local db but why not
                if (pingStatus.Status == IPStatus.Success)
                {
                    try
                    {
                        //If all went ok, try inserting a new user entry into the database
                        db.Close();
                        db.Open();
                        cmd = new MySqlCommand("Insert Into user(username,password,email,fullname,secretanswer,status) Values ('"
                                               + username.Trim() + "','"
                                               + password.Trim() + "','"
                                               + email.Trim() + "','"
                                               + fullname.Trim() + "','"
                                               + secretanswer.Trim() + "','"
                                               + 0 + "')", db);


                        object result = null;
                        result = cmd.ExecuteNonQuery();
                        db.Close();
                        //If the result object isn't null, the process was successfull
                        if (result != null)
                        {
                            MessageBox.Show("successful", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtUsername.Text     = "";
                            txtPassword.Text     = "";
                            txtEmail.Text        = "";
                            txtFullname.Text     = "";
                            txtSecretanswer.Text = "";
                            this.Close();
                            Login log = new Login();
                            log.Show();
                            db.Close();
                        }
                        else
                        {
                            //The result object was null, the process was not sucessfull
                            MessageBox.Show("Could not add to add.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            db.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Take another email or username", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MessageBox.Show(ex.Message.ToString(), "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        db.Close();
                    }
                }
                else
                {
                    //If the pinging failed, display this
                    MessageBox.Show("Check your internet connection.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    db.Close();
                }
            }
            else
            {
                //If any of the provided credentials were empty
                MessageBox.Show("can not be empty.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                db.Close();
            }
        }
Beispiel #3
0
 private void Create(String username, String password, String email, String fullname, String secretanswer)
 {
     if (txtUsername.Text.Trim() != "" &&
         txtPassword.Text.Trim() != "" &&
         txtEmail.Text.Trim() != "" &&
         txtFullname.Text.Trim() != "" &&
         txtSecretanswer.Text.Trim() != "")
     {
         Ping      ping       = new Ping();
         PingReply pingStatus = ping.Send(IPAddress.Parse("216.58.209.14")); // ping connectiın google
         if (pingStatus.Status == IPStatus.Success)
         {
             try
             {
                 db.Close();
                 db.Open();
                 cmd = new MySqlCommand("Insert Into user(username,password,email,fullname,secretanswer,status) Values ('"
                                        + username.Trim() + "','"
                                        + password.Trim() + "','"
                                        + email.Trim() + "','"
                                        + fullname.Trim() + "','"
                                        + secretanswer.Trim() + "','"
                                        + 0 + "')", db);
                 object sonuc = null;
                 sonuc = cmd.ExecuteNonQuery();
                 db.Close();
                 if (sonuc != null)
                 {
                     MessageBox.Show("successful", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     txtUsername.Text     = "";
                     txtPassword.Text     = "";
                     txtEmail.Text        = "";
                     txtFullname.Text     = "";
                     txtSecretanswer.Text = "";
                     this.Close();
                     Login log = new Login();
                     log.Show();
                     db.Close();
                 }
                 else
                 {
                     MessageBox.Show("Could not add to add.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     db.Close();
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Take another email or username", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 MessageBox.Show(ex.Message.ToString(), "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 db.Close();
             }
         }
         else
         {
             MessageBox.Show("Check your internet connection.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             db.Close();
         }
     }
     else
     {
         MessageBox.Show("can not be empty.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         db.Close();
     }
 }