コード例 #1
0
 private void saveKin()
 {
     foreach (DataGridViewRow dgvr in dataGridViewKin.Rows)
     {
         if (Convert.ToInt32(dgvr.Cells[4].Value) == 0)
         {
             structParentsTalc = new StructParentsTalc();
         }
         else
         {
             int id = Convert.ToInt32(dgvr.Cells[4].Value);
             structParentsTalc = DBobjects.Entities.StructParentsTalc.FirstOrDefault(p => p.idStructParentsTalc == id);
         }
         if (Convert.ToBoolean(dgvr.Cells[3].Value) == true)
         {
             structParentsTalc.idTalkParents = talkParents.idTalkPar;
             structParentsTalc.idKin         = Convert.ToInt32(dgvr.Cells[0].Value);
             if (DBobjects.Entities.StructParentsTalc.Where(p => p.idStructParentsTalc == structParentsTalc.idStructParentsTalc).Count() == 0)
             {
                 DBobjects.Entities.StructParentsTalc.Add(structParentsTalc);
             }
             DBobjects.Entities.SaveChanges();
         }
         else if (structParentsTalc.idStructParentsTalc != 0 && Convert.ToBoolean(dgvr.Cells[3].Value) == false)
         {
             deleteStructParents();
         }
     }
 }
コード例 #2
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Удалить?", "Сообщение", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
     {
         foreach (DataGridViewRow dgvr in dataGridViewKin.Rows)
         {
             int id = Convert.ToInt32(dgvr.Cells[4].Value);
             structParentsTalc = DBobjects.Entities.StructParentsTalc.FirstOrDefault(p => p.idStructParentsTalc == id);
             if (talkParents != null)
             {
                 deleteStructParents();
             }
         }
         DeletePrivTalk();
         filldgvTalcParent();
     }
 }