private void dgvGroup_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
 {
     int id = 0;
     if (int.TryParse(e.Row.Cells[0].Value.ToString(), out id))
     {
         var db = new LINQDataContext();
         // Define the query expression.
         var cquery = (from classs in db.Group_ID_Lists
                       where classs.Group_ID == id
                       select classs).ToArray();
         if (cquery != null)
         {
             string query = @"DELETE From dbo.Group_ID_List Where Group_ID = {0}";
             db.ExecuteQuery<object>(query, id);
         }
         else
         {
             db.New_GroupsPerClassDeleteByGroupID(id);
             db.GroupsDelete(id);
         }
         db.Dispose();
     }
 }
Exemple #2
0
        private void dgvGroup_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            int id = 0;

            if (int.TryParse(e.Row.Cells[0].Value.ToString(), out id))
            {
                var db = new LINQDataContext();
                // Define the query expression.
                var cquery = (from classs in db.Group_ID_Lists
                              where classs.Group_ID == id
                              select classs).ToArray();
                if (cquery != null)
                {
                    string query = @"DELETE From dbo.Group_ID_List Where Group_ID = {0}";
                    db.ExecuteQuery <object>(query, id);
                }
                else
                {
                    db.New_GroupsPerClassDeleteByGroupID(id);
                    db.GroupsDelete(id);
                }
                db.Dispose();
            }
        }