Exemplo n.º 1
0
        /// <summary>
        /// Method remove pointed admin
        /// </summary>
        private void Remove_Admin()
        {
            // Check if row exists
            // Check if we try delete yourself
            if (Convert.ToString(Display_DataGridView.CurrentRow.Cells[0].Value.ToString()) != null || Display_DataGridView.CurrentRow.Cells[0].Value.ToString() != Classes.Session.Admin_Login)
            {
                // Prepare query
                string query = $"DELETE FROM admins WHERE login = '******'";

                // Create dialog to confirm our choice
                DialogResult confirm = MessageBox.Show($"Do you wont to delete {Display_DataGridView.CurrentRow.Cells[0].Value.ToString()}?", "Remove admin", MessageBoxButtons.YesNo);

                // if you're sure
                if (confirm == DialogResult.Yes)
                {
                    // Remove admin
                    Database.Delete(query);
                }
            }
            else
            {
                MessageBox.Show("You must select one row", "Delete admin error");
            }
        }