private void btn_Delete_Click(object sender, EventArgs e)
 {
     if (txt_Name.Text.Replace(" ", "") != "" || txt_LastName.Text.Replace(" ", "") != "")
     {
         DialogResult dr = MessageBox.Show("Do you Want To Delete This Row ?", "CRUD", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             DbDataContext dbdc   = new DbDataContext();
             var           Delete = dbdc.tbl_Students.Where(tbl_Students => tbl_Students.S_ID == int.Parse(S_ID)).Single();
             dbdc.tbl_Students.DeleteOnSubmit(Delete);
             dbdc.SubmitChanges();
             dgv_Data.DataSource = dbdc.tbl_Students;
             S_ID = "";
             Clear();
         }
     }
     else
     {
         if (txt_Name.Text.Replace(" ", "") != "")
         {
             MessageBox.Show("Please enter Student Name", "CRUD", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txt_Name.Focus();
         }
         else
         {
             MessageBox.Show("Please enter Student Lastname", "CRUD", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txt_LastName.Focus();
         }
     }
 }
 private void btn_Add_Click(object sender, EventArgs e)
 {
     if (txt_Name.Text.Replace(" ", "") != "" || txt_LastName.Text.Replace(" ", "") != "")
     {
         DialogResult dr = MessageBox.Show("Do you Want To Add ?", "CRUD", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             DbDataContext dbdc = new DbDataContext();
             tbl_Student   tbls = new tbl_Student()
             {
                 S_Name         = txt_Name.Text,
                 S_LastName     = txt_LastName.Text,
                 S_NationalCode = txt_NationalCode.Text
             };
             dbdc.tbl_Students.InsertOnSubmit(tbls);
             dbdc.SubmitChanges();
             dgv_Data.DataSource = dbdc.tbl_Students;
             S_ID = "";
             Clear();
         }
     }
     else
     {
         if (txt_Name.Text.Replace(" ", "") != "")
         {
             MessageBox.Show("Please enter Student Name", "CRUD", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txt_Name.Focus();
         }
         else
         {
             MessageBox.Show("Please enter Student Lastname", "CRUD", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txt_LastName.Focus();
         }
     }
 }