public void EditarContenedor(Contenedor objContenedor) { BDParacasEntities context = new BDParacasEntities(); Contenedor objContenedorSel = context.Contenedor.FirstOrDefault(X => X.ContenedorId == objContenedor.ContenedorId); objContenedorSel.Codigo = objContenedor.Codigo; objContenedorSel.Embarcadero = objContenedor.Embarcadero; objContenedorSel.PesoManifiesto = objContenedor.PesoManifiesto; objContenedorSel.AgenteAduana = objContenedor.AgenteAduana; objContenedorSel.TipoMovimiento = objContenedor.TipoMovimiento; objContenedorSel.Tara = objContenedor.Tara; objContenedorSel.TamanoContenedorId = objContenedor.TamanoContenedorId; objContenedorSel.TipoContenedorId = objContenedor.TipoContenedorId; objContenedorSel.NumeroViaje = objContenedor.NumeroViaje; objContenedorSel.EIR = objContenedor.EIR; objContenedorSel.Estado = objContenedor.Estado; objContenedorSel.PrecintoAduanero = objContenedor.PrecintoAduanero; objContenedorSel.Precinto1 = objContenedor.Precinto1; objContenedorSel.Precinto2 = objContenedor.Precinto2; objContenedorSel.Precinto3 = objContenedor.Precinto3; objContenedorSel.Ubicacion = objContenedor.Ubicacion; objContenedorSel.NaveId = objContenedor.NaveId; objContenedorSel.FechaIzaje = objContenedor.FechaIzaje; objContenedorSel.FechaBarco = objContenedor.FechaBarco; objContenedorSel.FechaMuelle = objContenedor.FechaMuelle; objContenedorSel.Autorizacion = objContenedor.Autorizacion; objContenedorSel.Fecha = objContenedor.Fecha; context.SaveChanges(); }
public void RegistrarContenedor(Contenedor objContenedor) { BDParacasEntities context = new BDParacasEntities(); context.Contenedor.Add(objContenedor); 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; } ContenedorBC objContenedorBC = new ContenedorBC(); Contenedor objContenedor = new Contenedor(); objContenedor.Codigo = txtCodigo.Text.ToUpper(); objContenedor.Embarcadero = txtEmbarcadero.Text.ToUpper(); objContenedor.PesoManifiesto = Convert.ToDecimal(txtPesoManifiesto.Text.ToString()); objContenedor.AgenteAduana = txtAgenteAduanas.Text; objContenedor.Autorizacion = Convert.ToInt32(txtReserva.Text.ToString()); if (cbTipoMovimiento.SelectedIndex==0) { objContenedor.TipoMovimiento = "IMP"; } else if (cbTipoMovimiento.SelectedIndex == 1) { objContenedor.TipoMovimiento = "EXP"; } objContenedor.Tara =Convert.ToDecimal(txtTara.Text.ToString()); objContenedor.TamanoContenedorId = Convert.ToInt32(cbTamanioContenedor.SelectedValue.ToString()); objContenedor.TipoContenedorId = Convert.ToInt32(cbTipoContenedor.SelectedValue.ToString()); objContenedor.NumeroViaje = txtNumViaje.Text; objContenedor.EIR = txtEIR.Text; objContenedor.Estado =Convert.ToInt16(cbEstado.SelectedIndex); objContenedor.PrecintoAduanero = txtPrecintoAduanero.Text; objContenedor.Precinto1 = txtPrecinto1.Text; objContenedor.Precinto2 = txtPrecinto2.Text; objContenedor.Precinto3 = txtPrecinto3.Text; objContenedor.Ubicacion = txtUbicacion.Text.ToUpper(); objContenedor.NaveId = NaveId; objContenedor.Fecha = DateTime.Now; objContenedor.FechaIzaje = dtpFechaIzaje.Value.Date + dtpHoraIzaje.Value.TimeOfDay; objContenedor.FechaBarco = dtpFechaBarco.Value.Date + dtpHoraBarco.Value.TimeOfDay; objContenedor.FechaMuelle = dtpFechaMuelle.Value.Date + dtpHoraMuelle.Value.TimeOfDay; if (Modo == TypeMode.Registrar) { objContenedorBC.RegistrarContenedor(objContenedor); MessageBox.Show(MensajeRespuesta, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Modo == TypeMode.Editar) { objContenedor.ContenedorId = ContenedorId; objContenedorBC.EditarContenedor(objContenedor); MessageBox.Show(MensajeRespuesta, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } MiDelegado(); this.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnRegistrar_Click(object sender, EventArgs e) { if (!ValidarComponentes()) return; if (MessageBox.Show("¿Está seguro de registrar un Pesaje?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } if (chkHabRegCont.Checked) { ContenedorBC objContenedorBC = new ContenedorBC(); Contenedor objContenedor = new Contenedor(); objContenedor.Codigo = txtExpNumContenedor.Text.ToUpper(); objContenedor.Embarcadero = txtExpEmbarcadero.Text.ToUpper(); objContenedor.PesoManifiesto = Convert.ToDecimal(txtExpPesoManifiesto.Text.ToString()); objContenedor.AgenteAduana = txtExpAgenteAduanas.Text; objContenedor.Autorizacion = Convert.ToInt32(txtExpReserva.Text.ToString()); objContenedor.TipoMovimiento = "EXP"; objContenedor.Tara = Convert.ToDecimal(txtExpTara.Text.ToString()); objContenedor.TamanoContenedorId = Convert.ToInt32(cbTamanio.SelectedValue.ToString()); objContenedor.TipoContenedorId = Convert.ToInt32(cbTipoContenedor.SelectedValue.ToString()); objContenedor.NumeroViaje = txtExpNumViaje.Text; objContenedor.EIR = txtExpEIR.Text; objContenedor.Estado = 1; objContenedor.PrecintoAduanero = txtExpPrecintoAduanero.Text; objContenedor.Precinto1 = txtExpPrecinto1.Text; objContenedor.Precinto2 = txtExpPrecinto2.Text; objContenedor.Precinto3 = txtExpPrecinto3.Text; objContenedor.Ubicacion = txtExpUbicacion.Text.ToUpper(); objContenedor.NaveId = NaveId; objContenedor.Fecha = DateTime.Now; objContenedor.FechaIzaje = dtpExpIzajeFec.Value.Date + dtpExpIzajeHor.Value.TimeOfDay; objContenedor.FechaBarco = dtpExpBarcoFec.Value.Date + dtpExpBarcoHor.Value.TimeOfDay; objContenedor.FechaMuelle = dtpExpMuelleFec.Value.Date + dtpExpMuelleHor.Value.TimeOfDay; objContenedorBC.RegistrarContenedor(objContenedor); } PesajeBC objPesajeBC = new PesajeBC(); Pesaje objPesaje = new Pesaje(); objPesaje.UsuarioId = UsuarioId; objPesaje.ConductorId = ConductorId; objPesaje.VehiculoId = VehiculoId; objPesaje.AutorizacionId = AutorizacionId; objPesaje.Observacion = txtObservacion.Text.Trim().ToUpper(); objPesaje.Fecha = DateTime.Today; objPesaje.Estado = 1; objPesaje.Bruto = Convert.ToDecimal(txtPeso.Text.ToString()); objPesaje.Neto = Convert.ToDecimal(txtPesoAutorizacion.Text.ToString()); objPesaje.NaveId = NaveId; objPesaje.Tarja =Convert.ToInt32(nudTarja.Value.ToString()); objPesaje.Bultos = Convert.ToInt32(lblNroBultos.Text.ToString()); objPesaje.HoraGancho = DateTime.Now; objPesaje.CodContenedor = cbContenedor.SelectedValue.ToString(); if (txtTipo.Text == "EXPORTACION") objPesaje.Tipo = "EXP"; else objPesaje.Tipo = "IMP"; objPesajeBC.RegistrarPesaje(objPesaje); GuiaRemisionBC objGuiaRemisionBC = new GuiaRemisionBC(); PesajeId = objPesajeBC.BuscarUltimoIdPesaje(); objGuiaRemisionBC.ActualizarIdGuiaRemision(PesajeId); MessageBox.Show("Se registró satisfactoriamente el Pesaje", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Dispose(); }