using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Data.OleDb;

namespace TobbAblak
{
    public partial class Admin : Form
    {
        OleDbCommand cm;
        OleDbDataAdapter da;
        DataTable dt;

        public Admin()
        {
            InitializeComponent();
            dt = new DataTable();
            da = new OleDbDataAdapter("select * from login", BD.co);
            da.Fill(dt);
            dgv.DataSource = dt;
            dgv.Refresh();
        }

        private void Admin_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)        
        {
            if (dgv.SelectedRows.Count > 0)
            {
                int x = dgv.SelectedRows[0].Index;
                string s = dgv.Rows[x].Cells[0].Value.ToString();

                if (s != "1")
                {
                    string t = "delete from login where id=" + s + ";";
                    cm = new OleDbCommand(t, BD.co);
                    if (cm.ExecuteNonQuery() != 0)
                    {
                        dt.Clear();
                        da.Fill(dt);
                        dgv.Refresh();
                    }
                    else
                        MessageBox.Show("Nem tudtam torolni!");
                }
                else
                    MessageBox.Show("Adminisztratort nem lehet törölni!");

            }


        }
    }
}
