public void EditarNave(Nave objNave) { BDParacasEntities context = new BDParacasEntities(); Nave objNaveSel = context.Nave.FirstOrDefault(X => X.NaveId == objNave.NaveId); objNaveSel.Nombre = objNave.Nombre; objNaveSel.PesoTotal = objNave.PesoTotal; context.SaveChanges(); }
private void btnRegistrar_Click(object sender, EventArgs e) { try { if (!ValidarComponentes()) return; if (MessageBox.Show(MensajePregunta, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } NaveBC objNaveBC = new NaveBC(); Nave objNave = new Nave(); objNave.Nombre = txtNombre.Text.ToUpper(); objNave.PesoTotal = nudPesoTotal.Value; objNave.Estado = 1; if (Modo == TypeMode.Registrar) { objNaveBC.RegistrarNave(objNave); MessageBox.Show(MensajeRespuesta, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Modo == TypeMode.Editar) { objNave.NaveId = NaveId; objNaveBC.EditarNave(objNave); MessageBox.Show(MensajeRespuesta, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } MiDelegado(); this.Dispose(); } catch (Exception) { MessageBox.Show("Disculpe, el sistema se encuentra fuera de servicio!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void RegistrarNave(Nave objNave) { BDParacasEntities context = new BDParacasEntities(); context.Nave.Add(objNave); context.SaveChanges(); }