예제 #1
0
        private void button6_Click(object sender, EventArgs e)
        {
            this.Hide();
            DeleteUser f1 = new DeleteUser();

            f1.ShowDialog();
            this.Close();
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Click Yes to Delete User from Database", "WARNING!!!", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                string connectionString = "SERVER=" +
                                          DBConnect.SERVER + ";" + "DATABASE=" +
                                          DBConnect.DATABASE_NAME + ";" + "UID=" +
                                          DBConnect.USER_NAME + ";" + "PASSWORD="******";" + "SslMode=" +
                                          DBConnect.SslMode + ";";
                MySqlConnection myConnection = new MySqlConnection(connectionString);
                try
                {
                    {
                        String query =
                            "DELETE FROM users WHERE UserID = " + tbuserid.Text + "";

                        myConnection.Open();
                        MySqlCommand     cmd   = new MySqlCommand(query, myConnection);
                        MySqlDataAdapter sqlDA = new MySqlDataAdapter(cmd);
                        cmd.ExecuteNonQuery();
                    }
                    MessageBox.Show("User " + tbuserid.Text + " Deleted!");
                    this.Hide();
                    DeleteUser f1 = new DeleteUser();
                    f1.ShowDialog();
                    this.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("User Not Deleted, Please try again");
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                //
            }
        }