private void btnEliminarB_Click(object sender, EventArgs e)
 {
     using (GobEntities con = new GobEntities())
     {
         String Id = dgvBeneficiadosB.CurrentRow.Cells[0].Value.ToString();
         Ben = con.Beneficiados.Find(int.Parse(Id));
         con.Beneficiados.Remove(Ben);
         con.SaveChanges();
     }
     CargarDatos();
 }
Beispiel #2
0
 private void btnGuardarI_Click(object sender, EventArgs e)
 {
     {
         using (GobEntities con = new GobEntities())
         {
             Ben.Id     = Convert.ToInt32(txtIdI.Text);
             Ben.Nombre = txtNombreI.Text;
             Ben.Dui    = txtDuiI.Text;
             con.Beneficiados.Add(Ben);
             con.SaveChanges();
         }
         MessageBox.Show("Se han guardado los cambios");
     }
 }
 private void button1_Click(object sender, EventArgs e)
 {
     using (GobEntities con = new GobEntities())
     {
         String Id  = dgvBeneficiadosB.CurrentRow.Cells[0].Value.ToString();
         int    Idc = int.Parse(Id);
         Ben                  = con.Beneficiados.Where(VerificarID => VerificarID.Id == Idc).First();
         Ben.Nombre           = txtNombreB.Text;
         Ben.Dui              = txtDuiB.Text;
         Ben.Id               = Convert.ToInt32(txtIdB.Text);
         con.Entry(Ben).State = System.Data.Entity.EntityState.Modified;
         con.SaveChanges();
     }
     CargarDatos();
     MessageBox.Show("Se han guardado los cambios");
 }