private void Mostrar_cargo() { using (Ncargo nca = new Ncargo()) { cbocargo.DataSource = nca.Getall(); cbocargo.DisplayMember = "nombre_cargo"; cbocargo.ValueMember = "idcargo"; } }
private void totxtcargo_KeyPress(object sender, KeyPressEventArgs e) { if (!String.IsNullOrWhiteSpace(totxtcargo.Text)) { if (e.KeyChar == Convert.ToChar(Keys.Enter)) { using (Ncargo nca = new Ncargo()) { nca.state = EntityState.Guardar; nca.nombre_cargo = totxtcargo.Text.Trim(); nca.descripcion = ""; nca.SaveChanges(); } totxtcargo.Text = ""; contextmenu.Close(); Mostrar_cargo(); } } }