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

namespace telif
{
    public partial class frmdel : Form
    {
        public frmdel()
        {
            InitializeComponent();
        }

        private void frmdel_Load(object sender, EventArgs e)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            var q = db.Storedselectall();
            dataGridView1.DataSource = q;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            long? id=int.Parse(label1.Text);
            db.Storeddelete(@id);
            var q = db.Storedselectall();
            dataGridView1.DataSource = q;
        }

        private void dataGridView1_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
        {
            try
            {
                if (dataGridView1.RowCount > 1)
                {
                    label1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
                }
            }
            catch (Exception)
            {
            }
        }
    }
}
