Example #1
0
 private void btnGTSDelete_Click(object sender, EventArgs e)
 {
     if (dataGridView1.CurrentRow != null)
     {
         int            grId    = Int32.Parse(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString());
         int            subjId  = Int32.Parse(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[1].Value.ToString());
         GroupToSubject current = context.GroupsToSubjects.Find(grId, subjId);
         context.GroupsToSubjects.Remove(current);
         context.SaveChanges();
         btnGroupToSubject.PerformClick();
     }
 }
Example #2
0
        private void btnGTSCreate_Click(object sender, EventArgs e)
        {
            int            groupId = Int32.Parse(comboGTSGroup.SelectedValue.ToString());
            int            subjId  = Int32.Parse(comboGTSSubj.SelectedValue.ToString());
            GroupToSubject gts     = new GroupToSubject();

            gts.GroupId   = groupId;
            gts.SubjectId = subjId;
            try
            {
                context.GroupsToSubjects.Add(gts);
                context.SaveChanges();
            }
            catch (Exception)
            {
                MessageBox.Show("Row already exsists!");
            }
            btnGroupToSubject.PerformClick();
        }