protected void MostrarImagen() { EN.ENVehiculo vehiculo = new ENVehiculo(); DataSet dsMatricula = new DataSet(); dsMatricula = vehiculo.ObtenerMatriculaReserva(comboMarcas.Text, comboModelos.Text,comboCategorias.Text); string matricula; if (dsMatricula.Tables["Reserva"].Rows.Count >0) { matricula = dsMatricula.Tables["Reserva"].Rows[0][0].ToString(); ImagenCoche.ImageUrl = "Imagenes/ImagenesReserva/fotosCoches/" + matricula + ".jpg"; ImagenCoche.Height = 190; ImagenCoche.Width = 270; } }
protected void Page_Load(object sender, EventArgs e) { //////////////////////LOAD NORMAL DE RESERVAS/////////////////////////////// Posterior.ValueToCompare = System.DateTime.Today.AddDays(-1).ToString(); if (comboCategorias.Items.Count == 0) { DataSet ds = new DataSet(); EN.ENVehiculo envehiculo = new ENVehiculo(); ds = envehiculo.ObtenerCategorias(); for (int i = 0; i < ds.Tables["Categoria"].Rows.Count; i++) { comboCategorias.Items.Add(ds.Tables["Categoria"].Rows[i][0].ToString()); } //MARCAS comboMarcas.Items.Clear(); ds = envehiculo.ObtenerMarcas(comboCategorias.Text.ToString()); for (int i = 0; i < ds.Tables["Marcas"].Rows.Count; i++) { comboMarcas.Items.Add(ds.Tables["Marcas"].Rows[i][0].ToString()); } //MODELOS comboModelos.Items.Clear(); ds = envehiculo.ObtenerModelosVehiculos(comboCategorias.Text.ToString(), comboMarcas.Text.ToString()); for (int i = 0; i < ds.Tables["Modelos"].Rows.Count; i++) { comboModelos.Items.Add(ds.Tables["Modelos"].Rows[i][0].ToString()); } } ///////////////////////////RESERVAS COCHES/////////////////////// if (!Page.IsPostBack)//SOLO ENTRA SI ES LA PRIMERA VEZ QUE SE CARGA LA PAGINA { EN.ENCliente enCliente = new ENCliente(); EN.ENVehiculo enVehi = new ENVehiculo(); if (Session["Usuario"] != null) { enCliente.DNI = Session["Usuario"].ToString(); if (Session["ReservaRapida"] == "Habitual") { Session["ReservaRapida"] = null; string matricula = ""; char[] separadores = { '|', ',' }; string[] favorito = enCliente.ReservaFavorita().Split(separadores); DataSet dsMatricula = new DataSet(); //Marca,Modelo,FK_Categoria dsMatricula = enVehi.ObtenerMatriculaReserva(favorito[0], favorito[1], favorito[2]); matricula = dsMatricula.Tables["Reserva"].Rows[0][0].ToString(); RellenarCocheReserva(matricula); } if (Session["ReservaRapida"] == "Ultima") { Session["ReservaRapida"] = null; enCliente.DNI = Session["Usuario"].ToString(); RellenarCocheReserva(enCliente.UltimaReserva()); } } else { errorRegistrado.Visible = true; } /////////////////////////////FECHAS////////////////////////// if (Session["FechaInicioIndex"] != null && Session["FechaFinIndex"] != null) { IndexTextFechaInicio.Text = Session["FechaInicioIndex"].ToString(); IndexTextFechaFin.Text = Session["FechaFinIndex"].ToString(); Session["FechaInicioIndex"] = null; Session["FechaFinIndex"] = null; } } ////MOSTRAR IMAGENES DE COCHES// MostrarImagen(); }
protected void ReservabotonConsulta_Click(object sender, EventArgs e) { DataSet dsMatricula = new DataSet(); EN.ENReservas enRe = new EN.ENReservas(); EN.ENVehiculo enVe = new ENVehiculo(); EN.ENCliente cli = new ENCliente(); DataSet dscli = new DataSet(); if (Session["Usuario"] != null) { dscli = cli.ObtenerDatosClienteConDni(Session["Usuario"].ToString()); enRe.Cliente = dscli.Tables["Cliente"].Rows[0][0].ToString(); if (!CompareValidatorFechas.IsValid || !CustomValidator1.IsValid || !Posterior.IsValid)//algo mal { } else { dsMatricula = enVe.ObtenerMatriculaReserva(comboMarcas.Text, comboModelos.Text, comboCategorias.Text); if (dsMatricula.Tables["Reserva"].Rows.Count > 0) { enRe.Matricula = dsMatricula.Tables["Reserva"].Rows[0][0].ToString(); enVe.Matricula = dsMatricula.Tables["Reserva"].Rows[0][0].ToString(); enVe.ObtenerDatosVehiculos(); enVe.Estado = "Reservado"; enVe.EditarVehiculo(); } enRe.Conductores = Int32.Parse(conductores.Text); enRe.FechaFin = Convert.ToDateTime(IndexTextFechaFin.Text); enRe.FechaInicio = Convert.ToDateTime(IndexTextFechaInicio.Text); enRe.Modelo = comboModelos.Text; enRe.Activa = true; enRe.AnyadirReserva(); } } }