public AltaReservas(EN.ENReservas enRe, string texto)
        {
            InitializeComponent();
            editar = editar2 = true;
            DataSet dsCli = new DataSet();
            EN.ENVehiculo enVe = new EN.ENVehiculo();
            EN.ENReservas enRes = new EN.ENReservas();
            DataSet dsRes = new DataSet();

            enCliente.DNI = enRe.Cliente;
            aux = enRe;
            dsCli = enCliente.ObtenerDatosClienteConDni(enRe.Cliente.ToString());
            enVe.Matricula = enRe.Matricula;
            enVe.ObtenerDatosVehiculos();

            string nombre = dsCli.Tables["Cliente"].Rows[0][1].ToString();
            string apellidos = dsCli.Tables["Cliente"].Rows[0][2].ToString();
            string dni = dsCli.Tables["Cliente"].Rows[0][0].ToString();
            string telf = dsCli.Tables["Cliente"].Rows[0][3].ToString();
            string direc = dsCli.Tables["Cliente"].Rows[0][5].ToString();
            provincias = dsCli.Tables["Cliente"].Rows[0][6].ToString();
            ciudades = dsCli.Tables["Cliente"].Rows[0][7].ToString();
            string sexo = dsCli.Tables["Cliente"].Rows[0][9].ToString();
            enCliente.Sexo = sexo;

            TLabelNombre.Text = "Nombre: " + nombre + "Apellidos: " + apellidos;
            TLabelDNI.Text = "DNI: " + dni + "Telf: " + telf;
            TLabelDirec.Text = "Direccion: " + direc;
            TButtonBuscarCliente.Visible = false;
            TLabelNombre.Visible = true;
            TLabelDirec.Visible = true;
            TLabelDNI.Visible = true;
            TRectangleShapeCliente.Visible = true;
            TButtonEditar.Visible = true;
            TButtonReserva.Text = texto;

            TComboBoxConductores.SelectedIndex = TComboBoxConductores.FindStringExact(enRe.Conductores.ToString());
            TDateTimePickerFechaFin.Value = enRe.FechaFin;
            TDateTimePickerFechaInicio.Value = enRe.FechaInicio;
            TComboBoxCategoria.Items.Add(enVe.Categoria);
            TComboBoxCategoria.SelectedIndex = 0;
            TComboBoxMarca.Items.Add(enVe.Marca);
            TComboBoxMarca.SelectedIndex = 0;
            TComboBoxModelo.Items.Add(enVe.Modelo);
            TComboBoxModelo.SelectedIndex = 0;
            TComboBoxMatricula.Items.Add(enVe.Matricula);
            TComboBoxMatricula.SelectedIndex = 0;
        }
        private void TRadioButtonUltimoCoche_CheckedChanged(object sender, EventArgs e)
        {
            if (TRadioButtonUltimoCoche.Checked == true)
            {
                EN.ENVehiculo enVe = new EN.ENVehiculo();

                enVe.Matricula = enCliente.UltimaReserva();
                enVe.ObtenerDatosVehiculos();

                TComboBoxCategoria.SelectedIndex = TComboBoxCategoria.FindStringExact(enVe.Categoria);
                if (TComboBoxMarca.FindStringExact(enVe.Marca) == -1 && TComboBoxMatricula.Text != "")
                {
                    MessageBox.Show("No hay modelos disponibles, se ha escogido un modelo de igual categoría", "No hay modelos disponibles", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (TComboBoxMarca.FindStringExact(enVe.Marca) > -1 && TComboBoxMatricula.Text != "")
                {
                    TComboBoxMarca.SelectedIndex = TComboBoxMarca.FindStringExact(enVe.Marca);
                    if (TComboBoxModelo.FindStringExact(enVe.Modelo) < 0)
                    {
                        MessageBox.Show("No hay modelos disponibles, se ha escogido un modelo de igual categoría y marca","No hay modelos disponibles",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    }
                    else
                    {
                        TComboBoxModelo.SelectedIndex = TComboBoxModelo.FindStringExact(enVe.Modelo);
                        MessageBox.Show("Se ha escogido el vehiculo " + enVe.Marca + " " + enVe.Modelo + ".","Vehículo favorito seleccionado",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("No hay modelos disponibles de la misma categoría","No hay modelos disponibles",MessageBoxButtons.OK,MessageBoxIcon.Information);
                }
            }
        }
 private void TComboBoxModelo_TextChanged(object sender, EventArgs e)
 {
     EN.ENVehiculo enVe = new EN.ENVehiculo();
     DataSet dsVe = new DataSet();
     dsVe = enVe.ObtenerMatriculas2(TComboBoxMarca.Text.ToString(), TComboBoxModelo.Text.ToString());
     RellenarMatriculas(dsVe);
     if (TComboBoxModelo.Text == "")
     {
         err2.SetError(TComboBoxMatricula, "Falta seleccionar vehículo");
     }
     else
     {
         err2.Clear();
     }
 }
 private void TComboBoxCategoria_TextChanged(object sender, EventArgs e)
 {
     EN.ENVehiculo enVe = new EN.ENVehiculo();
     DataSet dsVe = new DataSet();
     dsVe = enVe.ObtenerMarcas(TComboBoxCategoria.Text.ToString());
     RellenarMarcas(dsVe);
     if (TComboBoxMarca.Text == "")
     {
         err2.SetError(TComboBoxMatricula, "Falta seleccionar vehículo");
         TComboBoxMatricula.DataSource = null;
         TComboBoxModelo.DataSource = null;
     }
     else
     {
         if (enFa.ExisteCat(TComboBoxCategoria.Text.ToString()) && enCliente.Nombre != null)
         {
             enFa.Categoria = TComboBoxCategoria.Text.ToString();
             enFa.ObtenerPrecio();
             TTextBoxPrecio.Text = enFa.PrecioTotal.ToString();
         }
         err2.Clear();
     }
 }
        private void TButtonReserva_Click(object sender, EventArgs e)
        {
            if (!Comprobar_OK())
            {
                MessageBox.Show(mens, "Error en los datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                EN.ENReservas enRe = new EN.ENReservas();
                EN.ENVehiculo enVe = new EN.ENVehiculo();
                enVe.Matricula = TComboBoxMatricula.Text.ToString();
                enRe.Cliente = enCliente.DNI;
                enRe.Conductores = Int32.Parse(TComboBoxConductores.Text);
                enRe.FechaFin = TDateTimePickerFechaFin.Value;
                enRe.FechaInicio = TDateTimePickerFechaInicio.Value;
                enRe.Matricula = TComboBoxMatricula.Text.ToString();
                enRe.Modelo = TComboBoxModelo.Text.ToString();
                enRe.Activa = true;
                enRe.NumRes = aux.NumRes;

                if (TButtonReserva.Text == "Realizar Reserva")
                {
                    enRe.AnyadirReserva();
                    MessageBox.Show("Reserva realizada con éxito", "Nueva Reserva", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    enRe.EditarReserva();
                    MessageBox.Show("Cambios guardados con éxito", "Editar Reserva", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                enVe.ObtenerDatosVehiculos();
                enVe.Estado = "Reservado";
                enVe.EditarVehiculo();
                ImprimirReserva FPrint = new ImprimirReserva(enCliente,enRe,enVe,enRe.NumeroUltimaReserva(),enFa.PrecioTotal,TLabelTarifa.Text.ToString());
                FPrint.Show();
                FPrint.Imprimir();

                Close();
            }
        }
        private void TDataGridBuscarFacturas_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[e.ColumnIndex].ColumnIndex.ToString() == "0") // la columna 0 es el checkbox de eliminiar
                {
                    string numRes = TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[2].Value.ToString();

                    if (arraynumRes.Count == 0)
                    {
                        arraynumRes.Add(numRes);
                    }
                    else
                    {
                        bool esta = false;
                        for (int i = 0; i < arraynumRes.Count; i++)
                        {
                            if (arraynumRes[i].ToString() == numRes)
                            {
                                arraynumRes.RemoveAt(i);//para borrarlo de la array porque esto quiere decir que lo hemos deseleccionado
                                esta = true;
                            }
                        }
                        if (esta == false)
                            arraynumRes.Add(numRes);
                    }
                }
                else if (TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Duplicar")
                {
                    EN.ENFacturacion enFa = new EN.ENFacturacion();
                    EN.ENVehiculo enVe = new EN.ENVehiculo();
                    EN.ENCliente enCli = new EN.ENCliente();

                    enFa.Factura = Int32.Parse(TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[2].Value.ToString());
                    enFa.Cliente = TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[3].Value.ToString();
                    enFa.Vehiculo = TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[4].Value.ToString();
                    enFa.Conductores = Int32.Parse(TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[5].Value.ToString());
                    enFa.Tiempo = Int32.Parse(TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[6].Value.ToString());
                    enFa.Tarifa = TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[7].Value.ToString();
                    enFa.DiaFacturacion = Convert.ToDateTime(TDataGridBuscarFacturas.Rows[e.RowIndex].Cells[9].Value.ToString());

                    enVe.Matricula = enFa.Vehiculo;
                    enCli.DNI = enFa.Cliente;
                    enVe.ObtenerDatosVehiculos();
                    enCli.RellenarCliente();

                    ImprimirFactura Fp = new ImprimirFactura(enCli, enVe, enFa, enFa.Factura);
                    Fp.BackgroundImage = AlquilerCoches.Properties.Resources.es_sello_duplicado;
                    Fp.BackgroundImageLayout = ImageLayout.Stretch;
                    Fp.Show();
                    Fp.Imprimir();

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error no hay valores en esta fila");
            }
        }