public static void SaveSeguroViajero(ref SeguroViajeroDTO seguroViajero) { SqlCommand command; if (seguroViajero.IsNew) { command = GetDbSprocCommand("usp_SegurosViajeros_Insert"); command.Parameters.Add(CreateOutputParameter("@IDSeguroViajero", SqlDbType.Int)); } else { command = GetDbSprocCommand("usp_SegurosViajeros_Update"); command.Parameters.Add(CreateParameter("@IDSeguroViajero", seguroViajero.IdSeguroViajero)); } command.Parameters.Add(CreateParameter("@Comision", seguroViajero.Comision)); command.Parameters.Add(CreateParameter("@Descripcion", seguroViajero.Descripcion, 50)); command.Parameters.Add(CreateParameter("@Monto", seguroViajero.Monto)); command.Parameters.Add(CreateParameter("@NumeroCompra", seguroViajero.NumeroCompra)); command.Parameters.Add(CreateParameter("@TipoSeguroViajero", seguroViajero.TipoSeguroViajero)); // Run the command. command.Connection.Open(); command.ExecuteNonQuery(); command.Connection.Close(); // If this is a new record, let's set the ID so the object // will have it. if (seguroViajero.IsNew) { seguroViajero.IdSeguroViajero = (int)command.Parameters["@IDSeguroViajero"].Value; } }
internal override DTOBase PopulateDTO(SqlDataReader reader) { SeguroViajeroDTO seguroViajero = new SeguroViajeroDTO(); // IdSeguroViajero if (!reader.IsDBNull(Ord_IdSeguroViajero)) { seguroViajero.IdSeguroViajero = reader.GetInt32(Ord_IdSeguroViajero); } // Comision if (!reader.IsDBNull(Ord_Comision)) { seguroViajero.Comision = reader.GetInt32(Ord_Comision); } // Monto if (!reader.IsDBNull(Ord_Monto)) { seguroViajero.Monto = reader.GetFloat(Ord_Monto); } // TipoSeguroViajero if (!reader.IsDBNull(Ord_TipoSeguroViajero)) { seguroViajero.TipoSeguroViajero = reader.GetInt32(Ord_TipoSeguroViajero); } // NumeroCompra if (!reader.IsDBNull(Ord_NumeroCompra)) { seguroViajero.NumeroCompra = reader.GetInt32(Ord_NumeroCompra); } // Descripcion if (!reader.IsDBNull(Ord_Descripcion)) { seguroViajero.Descripcion = reader.GetString(Ord_Descripcion); } return(seguroViajero); }
public static void SaveReserva(ref ReservaDTO reserva) { SqlCommand command = null; decimal montoReserva = 0; foreach (ReservaDetalleDTO reservaDetalle in reserva.DetallesReserva) { montoReserva += reservaDetalle.Monto; } reserva.Monto = montoReserva; try { command = GetDbSprocCommand("usp_Reserva_Insert"); command.Parameters.Add(CreateOutputParameter("@IDReserva", SqlDbType.Int)); command.Parameters.Add(CreateParameter("@Comprada", reserva.Comprada)); command.Parameters.Add(CreateParameter("@Efectuada", reserva.Efectuada)); command.Parameters.Add(CreateParameter("@FechaReserva", reserva.FechaReserva)); command.Parameters.Add(CreateParameter("@Idcliente", reserva.IdCliente)); command.Parameters.Add(CreateParameter("@IdDocumentoViaje", reserva.IdDocumentoViaje)); command.Parameters.Add(CreateParameter("@IdEmpleado", reserva.IdEmpleado)); command.Parameters.Add(CreateParameter("@IdSeguroViajero", reserva.IdSeguroViajero)); command.Parameters.Add(CreateParameter("@IdServicioAlojamiento", reserva.IdServicioAlojamiento)); command.Parameters.Add(CreateParameter("@IdServicioTraslado", reserva.IdServicioTraslado)); command.Parameters.Add(CreateParameter("@IdTipoDocumento", reserva.IdTipoDocumento)); command.Parameters.Add(CreateParameter("@Monto", reserva.Monto)); command.Parameters.Add(CreateParameter("@NumeroDocumento", reserva.NumeroDocumento, 8)); command.Parameters.Add(CreateParameter("@NumeroReserva", reserva.NumeroReserva)); command.Connection.Open(); command.Transaction = command.Connection.BeginTransaction(); command.ExecuteNonQuery(); // If this is a new record, let's set the ID so the object // will have it. if (reserva.IsNew) { reserva.IdReserva = (int)command.Parameters["@IDReserva"].Value; } foreach (ReservaDetalleDTO reservaDetalle in reserva.DetallesReserva) { ServicioAlojamientoDTO servicioAlojamiento = reservaDetalle.ServicioAlojamiento; if (servicioAlojamiento != null) { command.Parameters.Clear(); command.CommandText = "usp_ServicioAlojamiento_Insert"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(CreateOutputParameter("@idServicioAlojamiento", SqlDbType.Int)); command.Parameters.Add(CreateParameter("@categoria", servicioAlojamiento.CategoriaDTO, 50)); command.Parameters.Add(CreateParameter("@comision", servicioAlojamiento.comisionDTO)); command.Parameters.Add(CreateParameter("@descripcion", servicioAlojamiento.descripcionDTO, 50)); command.Parameters.Add(CreateParameter("@fechaDesde", servicioAlojamiento.fechaDesdeDTO)); command.Parameters.Add(CreateParameter("@fechaHasta", servicioAlojamiento.fechaHastaDTO)); command.Parameters.Add(CreateParameter("@fechaVencReserva", servicioAlojamiento.fechaVencReservaDTO)); command.Parameters.Add(CreateParameter("@monto", servicioAlojamiento.montoDTO)); command.Parameters.Add(CreateParameter("@numeroReserva", servicioAlojamiento.numeroReservaDTO, 10)); command.Parameters.Add(CreateParameter("@idAlojamiento", servicioAlojamiento.idAlojamientoDTO)); command.Parameters.Add(CreateParameter("@numeroVenta", servicioAlojamiento.numeroVentaDTO)); command.Parameters.Add(CreateParameter("@tipoDocumento", servicioAlojamiento.tipoDocumentoDTO)); command.Parameters.Add(CreateParameter("@numeroDocumento", servicioAlojamiento.numeroDocumentoDTO, 8)); command.Parameters.Add(CreateParameter("@numeroCompra", servicioAlojamiento.numeroCompraDTO)); command.ExecuteNonQuery(); reservaDetalle.IdServicioAlojamiento = (int)command.Parameters["@idServicioAlojamiento"].Value; } SeguroViajeroDTO seguroViajero = reservaDetalle.Seguro; if (seguroViajero != null) { command.Parameters.Clear(); command.CommandText = "usp_SeguroViajero_Insert"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(CreateOutputParameter("@idSeguroViajero", SqlDbType.Int)); command.Parameters.Add(CreateParameter("@comision", seguroViajero.Comision)); command.Parameters.Add(CreateParameter("@monto", seguroViajero.Monto)); command.Parameters.Add(CreateParameter("@tipoSeguroViajero", seguroViajero.TipoSeguroViajero)); command.Parameters.Add(CreateParameter("@numeroCompra", seguroViajero.NumeroCompra)); command.Parameters.Add(CreateParameter("@descripcion", seguroViajero.Descripcion, 50)); command.ExecuteNonQuery(); reservaDetalle.IdSeguroViajero = (int)command.Parameters["@idSeguroViajero"].Value; } ServicioTrasladoDTO servicioTraslado = reservaDetalle.ServicioTraslado; if (servicioTraslado != null) { command.Parameters.Clear(); command.CommandText = "usp_ServicioTraslado_Insert"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(CreateOutputParameter("@idServicioTraslado", SqlDbType.Int)); command.Parameters.Add(CreateParameter("@comision", servicioTraslado.comisionDTO)); command.Parameters.Add(CreateParameter("@destino", servicioTraslado.destinoDTO)); command.Parameters.Add(CreateParameter("@fechaSalida", servicioTraslado.fechaSalidaDTO)); command.Parameters.Add(CreateParameter("@fechaRegreso", servicioTraslado.fechaLlegadaDTO)); command.Parameters.Add(CreateParameter("@monto", servicioTraslado.montoDTO)); command.Parameters.Add(CreateParameter("@numeroReserva", servicioTraslado.numeroReservaDTO, 10)); command.Parameters.Add(CreateParameter("@origen", servicioTraslado.origenDTO)); command.Parameters.Add(CreateParameter("@idCompaniaAerea", servicioTraslado.idCompaniaAereaDTO)); command.Parameters.Add(CreateParameter("@idEmpresaColectivos", servicioTraslado.idEmpresaColectivoDTO)); command.Parameters.Add(CreateParameter("@numeroCompra", servicioTraslado.numeroCompraDTO)); command.Parameters.Add(CreateParameter("@numeroVenta", servicioTraslado.numeroVentaDTO)); command.Parameters.Add(CreateParameter("@tipoDocumento", servicioTraslado.tipoDocumentoDTO)); command.Parameters.Add(CreateParameter("@numeroDocumento", servicioTraslado.numeroDocumentoDTO, 8)); command.ExecuteNonQuery(); reservaDetalle.IdServicioTraslado = (int)command.Parameters["@idServicioTraslado"].Value; } command.Parameters.Clear(); command.CommandText = "usp_ReservaDetalle_Insert"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(CreateOutputParameter("@IDDetalleReserva", SqlDbType.Int)); command.Parameters.Add(CreateParameter("@Comprada", reservaDetalle.Comprada)); command.Parameters.Add(CreateParameter("@Efectuada", reservaDetalle.Efectuada)); command.Parameters.Add(CreateParameter("@IdDocumentoViaje", reservaDetalle.IdDocumentoViaje)); command.Parameters.Add(CreateParameter("@IdReserva", reserva.IdReserva)); command.Parameters.Add(CreateParameter("@IdSeguroViajero", reservaDetalle.IdSeguroViajero)); command.Parameters.Add(CreateParameter("@IdServicioAlojamiento", reservaDetalle.IdServicioAlojamiento)); command.Parameters.Add(CreateParameter("@IdServicioTraslado", reservaDetalle.IdServicioTraslado)); command.Parameters.Add(CreateParameter("@IdTipoDocumento", reservaDetalle.IdTipoDocumento)); command.Parameters.Add(CreateParameter("@Monto", reservaDetalle.Monto)); command.Parameters.Add(CreateParameter("@IdPasajero", reservaDetalle.IdPasajero)); command.Parameters.Add(CreateParameter("@NumeroDocumento", reservaDetalle.NumeroDocumento, 8)); command.ExecuteNonQuery(); } // Run the command. command.Transaction.Commit(); command.Connection.Close(); } catch (Exception e) { if (command != null) { command.Transaction.Rollback(); } throw e; } }
protected void btnAceptar_Click1(object sender, EventArgs e) { ReservaDetalleDTO detalle = new ReservaDetalleDTO(); ServicioTrasladoDTO servicioTraslado = new ServicioTrasladoDTO(); DateTime fechaSalida = CommonBase.DateTime_NullValue; DateTime fechaLlegada = CommonBase.DateTime_NullValue; if (Session["detalles"] != null) { detalles = (List <ReservaDetalleDTO>)Session["detalles"]; } detalle.IdPasajero = Convert.ToInt32(gvPasajeros.SelectedDataKey.Value); detalle.Pasajero = PasajeroManager.GetPasajeroByID(detalle.IdPasajero); detalle.IdTipoDocumento = Convert.ToInt32(ddlDocumentoViaje.SelectedValue); detalle.Monto = decimal.Parse(txtMontoDetalle.Text); servicioTraslado.IsNew = true; servicioTraslado.destinoDTO = Int32.Parse(ddlDestino.SelectedValue); servicioTraslado.origenDTO = Int32.Parse(ddlOrigen.SelectedValue); if (txtFechaSalida.Text != "" && !DateTime.TryParseExact(txtFechaSalida.Text, "dd/MM/yyyy", new CultureInfo("es-AR"), DateTimeStyles.None, out fechaSalida)) { DangerMessage.Visible = true; LblDanger.Text = "El formato de la fecha de salida debe ser dd/MM/yyyy."; return; } if (txtFechaRegreso.Text != "" && !DateTime.TryParseExact(txtFechaRegreso.Text, "dd/MM/yyyy", new CultureInfo("es-AR"), DateTimeStyles.None, out fechaLlegada)) { DangerMessage.Visible = true; LblDanger.Text = "El formato de la fecha de regreso debe ser dd/MM/yyyy."; return; } servicioTraslado.fechaSalidaDTO = fechaSalida; servicioTraslado.fechaLlegadaDTO = fechaLlegada; servicioTraslado.idCompaniaAereaDTO = Convert.ToInt32(ddlTransporte.SelectedValue); detalle.ServicioTraslado = servicioTraslado; if (ddlAlojamiento.SelectedValue != "") { DateTime fechaDesdeAlojamiento = CommonBase.DateTime_NullValue; DateTime fechaHastaAlojamiento = CommonBase.DateTime_NullValue; ServicioAlojamientoDTO alojamiento = new ServicioAlojamientoDTO(); alojamiento.IsNew = true; alojamiento.idAlojamientoDTO = Int32.Parse(ddlAlojamiento.SelectedValue); if (txtFechaDesdeAlojamiento.Text != "" && !DateTime.TryParseExact(txtFechaDesdeAlojamiento.Text, "dd/MM/yyyy", new CultureInfo("es-AR"), DateTimeStyles.None, out fechaDesdeAlojamiento)) { DangerMessage.Visible = true; LblDanger.Text = "El formato de la fecha desde del alojamiento debe ser dd/MM/yyyy."; return; } if (txtFechaHastaAlojamiento.Text != "" && !DateTime.TryParseExact(txtFechaHastaAlojamiento.Text, "dd/MM/yyyy", new CultureInfo("es-AR"), DateTimeStyles.None, out fechaHastaAlojamiento)) { DangerMessage.Visible = true; LblDanger.Text = "El formato de la fecha hasta del alojamiento debe ser dd/MM/yyyy."; return; } alojamiento.fechaDesdeDTO = fechaDesdeAlojamiento; alojamiento.fechaHastaDTO = fechaHastaAlojamiento; detalle.Alojamiento = alojamiento; } if (ddlTipoSeguro.SelectedValue != "") { SeguroViajeroDTO seguro = new SeguroViajeroDTO(); seguro.IsNew = true; if (Int32.Parse(ddlTipoSeguro.SelectedValue) > 0) { seguro.TipoSeguroViajero = Int32.Parse(ddlTipoSeguro.SelectedValue); } if (txtObservaciones.Text != "") { seguro.Descripcion = txtObservaciones.Text; } } detalles.Add(detalle); gvDetalleReserva.DataSource = detalles; gvDetalleReserva.DataBind(); LimpiarCamposDetalle(); reservaDetalleSection.Visible = false; reservaSection.Visible = true; Session["detalles"] = detalles; }