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 ClassLibrary3;
namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Operation Operation = new Operation("data source =.; initial catalog = TestDB;integrated security = True");
        private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = Operation.Select("Employee");
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            string code = string.Empty;

            for(int i=0;i<dataGridView1.Rows.Count;i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value != null && (bool)dataGridView1.Rows[i].Cells[0].Value == true)
                    code += dataGridView1.Rows[i].Cells[1].Value.ToString() + ",";
            }
            if (code.Length > 0)
            {
                code = code.Remove(code.Length - 1, 1);
                //Operation.DeleteMultiRows("Employee", "ID", code);
                Operation.DeleteMultiRowsSP( "ID", code, "DeleteMultiEmp");
                dataGridView1.DataSource = Operation.Select("Employee");
            }

        }
    }
}
