/// <summary> /// Lista los vuelos de un boleto /// </summary> /// <param name="id_boleto"></param> /// <returns></returns> public List <BoletoVuelo> M05ListarVuelosBoleto(int id_boleto) { List <BoletoVuelo> listavuelos = new List <BoletoVuelo>(); try { SqlConnection con = new SqlConnection(_connexionString); con.Open(); String sql = "SELECT bol_fk_vuelo FROM Boleto_Vuelo WHERE bol_fk_boleto =" + id_boleto + ""; System.Diagnostics.Debug.WriteLine(sql); SqlCommand cmd = new SqlCommand(sql, con); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { BoletoVuelo datosVuelo = MBuscarDatosVuelo(Int32.Parse(reader["bol_fk_vuelo"].ToString())); listavuelos.Add(datosVuelo); } } cmd.Dispose(); con.Close(); int inte = listavuelos.Count; return(listavuelos); } catch (SqlException) { return(null); } }
/// <summary> /// Busca los datos del vuelo /// </summary> /// <param name="id"></param> /// <returns></returns> public BoletoVuelo MBuscarDatosVuelo(int id) { BoletoVuelo vuelo = null; try { SqlConnection con = new SqlConnection(_connexionString); con.Open(); String sql = "SELECT vue_fecha_despegue, vue_fecha_aterrizaje, vue_fk_ruta FROM Vuelo WHERE vue_id =" + id + ""; System.Diagnostics.Debug.WriteLine(sql); SqlCommand cmd = new SqlCommand(sql, con); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { RutaBoleto rut = MBuscarDatosRuta(Int32.Parse(reader["vue_fk_ruta"].ToString())); vuelo = new BoletoVuelo(id, reader.GetDateTime(reader.GetOrdinal("vue_fecha_despegue")), reader.GetDateTime(reader.GetOrdinal("vue_fecha_aterrizaje")), Int32.Parse(reader["vue_fk_ruta"].ToString()), rut._origen, rut._destino, rut._nomOrigen, rut._nomDestino); } } cmd.Dispose(); con.Close(); return(vuelo); } catch (SqlException) { return(vuelo); } }
public ActionResult generarBoardingPass(CDetalleBoleto model) { BoletoVuelo lista1 = null; BoletoVuelo lista2 = null; String tipo = model._tipoBoardingPass; int compara1 = String.Compare(tipo, "Seleccione"); if (compara1 != 0) { int id_bol = model._bol_id; //manejadorSQL_Check modificar = new manejadorSQL_Check(); // OBTENGO EL /LOS VUELOS DEL BOLETO Command <List <Entidad> > comando = FabricaComando.consultarM05listaVuelos(model._bol_id); List <Entidad> lista = comando.ejecutar(); //List<BoletoVuelo> lista = modificar.M05ListarVuelosBoleto(model._bol_id); lista1 = (BoletoVuelo)lista[0]; if (lista.Count == 2) { lista2 = (BoletoVuelo)lista[1]; } // PRIMERO VEO SI ES IDA O IDA Y VUELTA //int ida_vuelta = modificar.MBuscarIdaVuelta(model._bol_id); Command <int> comando2 = FabricaComando.mostrarM05idaVuelta(model._bol_id); int ida_vuelta = comando2.ejecutar(); // EL BOLETO ES IDA 1 // EL BOLETO ES IDA Y VUELTA 2 // DATOS PARA INSERTAR EN PASE DE ABORDAJE CBoardingPass pase2 = new CBoardingPass(); BoardingPass pase; if (ida_vuelta == 1) { pase = (BoardingPass)FabricaEntidad.InstanciarBoardingPass(lista1._id, lista1._fechaPartida, lista1._fechaLlegada, lista1._fechaPartida.TimeOfDay.ToString(), lista1._ruta._origen, lista1._ruta._destino, lista1._ruta._nomOrigen, lista1._ruta._nomDestino, model._bol_id, "A12", model._primer_nombre, model._primer_apellido); } else { int compara = String.Compare(tipo, "Ida"); if (compara == 0) { pase = (BoardingPass)FabricaEntidad.InstanciarBoardingPass(lista1._id, lista1._fechaPartida, lista1._fechaLlegada, lista1._fechaPartida.TimeOfDay.ToString(), lista1._ruta._origen, lista1._ruta._destino, lista1._ruta._nomOrigen, lista1._ruta._nomDestino, model._bol_id, "A12", model._primer_nombre, model._primer_apellido); } else { pase = (BoardingPass)FabricaEntidad.InstanciarBoardingPass(lista2._id, lista2._fechaPartida, lista2._fechaLlegada, lista2._fechaPartida.TimeOfDay.ToString(), lista2._ruta._origen, lista2._ruta._destino, lista2._ruta._nomOrigen, lista2._ruta._nomDestino, model._bol_id, "A12", model._primer_nombre, model._primer_apellido); } } //int resultado1 = modificar.MConteoBoarding(pase._boleto, pase._vuelo); Command <int> comando3 = FabricaComando.conteoM05Boarding(pase._boleto, pase._vuelo); int resultado1 = comando3.ejecutar(); if (resultado1 == 0) { // HACER EL INSERT DE PASE DE ABORDAJE Command <int> comando4 = FabricaComando.crearM05CrearBoarding(pase); int resultado = comando4.ejecutar(); //int resultado = modificar.CrearBoardingPass(pase2); } // TENGO QUE BUSCAR EL ID DEL PASE DE ABORDAJE CREADO Command <int> comando5 = FabricaComando.IdM05paseAbordaje(pase._boleto, pase._vuelo); //int num_boarding = modificar.IdBoardingPass(pase._boleto, pase._vuelo); int num_boarding = comando5.ejecutar(); pase._id = num_boarding; // TENGO QUE INSTANCIAR AL MODELO DE VER BOARDING PASS return(PartialView("M05_VerBoardingPass", pase)); } else { //Creo el codigo de error de respuesta (OJO: AGREGAR EL USING DE SYSTEM.NET) Response.StatusCode = (int)HttpStatusCode.BadRequest; //Agrego mi error String error = "Debe indicar el vuelo a asociar"; //Retorno el error return(Json(error)); } }
List <Entidad> IDAOBoleto.M05ListarVuelosIdaBD(string fecha_ida, string fecha_vuelta, int id_origen, int id_destino, string tipo) { List <Entidad> listavuelos = new List <Entidad>(); try { IDAOBoleto ver = (IDAOBoleto)FabricaDAO.instanciarDaoBoleto(); SqlConnection con = new SqlConnection(_connexionString); con.Open(); //Busco la capacidad del avion del vuelo, segun el tipo de boleto String sql = "SELECT v.vue_id as id,v.vue_fecha_despegue as despegue,v.vue_fecha_aterrizaje as aterrizaje,r.rut_id as id_ruta,r.rut_FK_lugar_origen as id_origen,r.rut_FK_lugar_destino as id_destino,lo.lug_nombre as nombre_origen,ld.lug_nombre as nombre_destino FROM Vuelo v, Ruta r, Lugar lo, Lugar ld WHERE v.vue_fk_ruta=r.rut_id AND r.rut_fk_lugar_origen = lo.lug_id AND r.rut_fk_lugar_destino = ld.lug_id AND r.rut_FK_lugar_origen=" + id_origen + "AND r.rut_FK_lugar_destino=" + id_destino + " AND v.vue_fecha_despegue >= '" + fecha_ida + "' AND v.vue_fecha_despegue <= DATEADD(day, 1, '" + fecha_ida + "')"; System.Diagnostics.Debug.WriteLine(sql); SqlCommand cmd = new SqlCommand(sql, con); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Random rnd = new Random(); //Tengo que ver en cada vuelo que la cantidad de fk_vuelo en Boleto_Vuelo sea menor que la capacidad del tipo de boleto en el avion int cant_bol_vue = 0; //Cantidad de fk_vuelo en Boleto_Vuelo int cap = 0; //capacidad del tipo de boleto en el aviĆ³n //Si tipo de boleto = Turista entonces busco cap turista, si es ejecutivo cap ejecutivo y si es vip cap vip //Obtengo el id del vuelo System.Diagnostics.Debug.WriteLine("METODO DE LISTAR VUELOS IDA"); int id_vuelo = Int32.Parse(reader["id"].ToString()); //Obtengo cantidad de fk_vuelo en Boleto_vuelo cant_bol_vue = BuscarCantBolVue(id_vuelo); cap = ver.MConteoCapacidad(id_vuelo, tipo); System.Diagnostics.Debug.WriteLine("Capacidad en tipo " + tipo + " : " + cap); if (cant_bol_vue < cap) { BoletoVuelo vuelo = new BoletoVuelo(Int32.Parse(reader["id"].ToString()), reader.GetDateTime(reader.GetOrdinal("despegue")), reader.GetDateTime(reader.GetOrdinal("aterrizaje")), Int32.Parse(reader["id_ruta"].ToString()), Int32.Parse(reader["id_origen"].ToString()), Int32.Parse(reader["id_destino"].ToString()), reader.GetString(reader.GetOrdinal("nombre_origen")), reader.GetString(reader.GetOrdinal("nombre_destino")), rnd.Next(300, 1001), tipo, fecha_vuelta); listavuelos.Add(vuelo); } else { System.Diagnostics.Debug.WriteLine("CAPACIDAD MAXIMA ALCANZADA EN EL AVION PARA BOLETOS DEL TIPO: " + tipo); } } } cmd.Dispose(); con.Close(); return(listavuelos); } catch (SqlException) { return(null); } }