protected void btnBuscar_Click(object sender, EventArgs e) { try { string matricula = txtMatricula.Text; Vehiculos v = LVehiculo.Buscar(matricula); if (v == null) { ActivarAlta(); Session["Vehiculo"] = v; lblError.Text = "No existe el vehiculo."; } else if (v is Utilitarios) { throw new Exception("El Vehiculo pertenece a Utilitarios."); } else//si existe el auto { ActivarBajaModificacion(); Session["Vehiculo"] = v; txtAño.Text = Convert.ToString(v.Año); txtCosto.Text = v.Costo.ToString(); txtMarca.Text = v.Marca; txtMatricula.Text = v.Matricula; txtModelo.Text = v.Modelo; txtPuertas.Text = v.Puertas.ToString(); if (((Autos)v).Anclaje == "Cinturon") { rblAnclaje.Items[0].Selected = true; rblAnclaje.Items[1].Selected = false; rblAnclaje.Items[2].Selected = false; } else if (((Autos)v).Anclaje == "ISOFIX") { rblAnclaje.Items[0].Selected = false; rblAnclaje.Items[1].Selected = false; rblAnclaje.Items[2].Selected = true; } else if (((Autos)v).Anclaje == "Latch") { rblAnclaje.Items[0].Selected = false; rblAnclaje.Items[1].Selected = true; rblAnclaje.Items[2].Selected = false; } } } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnAgregar_Click(object sender, EventArgs e) { try { for (int i = 0; i < txtAño.Text.Length; i++) { if (!char.IsNumber(Convert.ToChar(txtAño.Text.Substring(i, 1)))) { throw new Exception("Error en año del vehiculo."); } } for (int i = 0; i < txtPuertas.Text.Length; i++) { if (!char.IsNumber(Convert.ToChar(txtPuertas.Text.Substring(i, 1)))) { throw new Exception("Error en Puertas del vehiculo."); } } for (int i = 0; i < txtCosto.Text.Length; i++) { if (!char.IsNumber(Convert.ToChar(txtCosto.Text.Substring(i, 1)))) { if (!char.IsPunctuation(Convert.ToChar(txtCosto.Text.Substring(i, 1)))) { throw new Exception("Error en Costo del vehiculo."); } } } for (int i = 0; i < txtCapacidad.Text.Length; i++) { if (!char.IsNumber(Convert.ToChar(txtCapacidad.Text.Substring(i, 1)))) { throw new Exception("Error en capacidad del vehiculo."); } } Utilitarios v = new Utilitarios(txtMatricula.Text, txtMarca.Text, txtModelo.Text, Convert.ToInt32(txtAño.Text), Convert.ToInt32(txtPuertas.Text), Convert.ToDecimal(txtCosto.Text), Convert.ToInt32(txtCapacidad.Text), rblTipo.SelectedItem.Text); LVehiculo.Agregar(v); ActivarBajaModificacion(); Limpiar(); lblError.Text = "Se dio de alta el Vehiculo."; } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnEliminar_Click(object sender, EventArgs e) { try { Vehiculos v = (Vehiculos)Session["Vehiculo"]; LVehiculo.Eliminar(v); Limpiar(); lblError.Text = "Eliminado correctamente."; } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnCosto_Click(object sender, EventArgs e) { try { Vehiculos v = LVehiculo.Buscar(txtMatricula.Text); if (v == null) { lblError.Text = "No existe el vehiculo."; } lblError.Text = "El Costo del alquiler es de " + (mvwFin.SelectedDate.Subtract(mvwInicio.SelectedDate).Days *v.Costo) + " Dolares."; } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnBuscar_Click(object sender, EventArgs e) { try { string matricula = txtMatricula.Text; Vehiculos v = LVehiculo.Buscar(matricula); if (v == null) { ActivarAlta(); Session["Vehiculo"] = v; lblError.Text = "No existe el vehiculo."; } else if (v is Autos) { throw new Exception("El Vehiculo no es utilitario."); } else { ActivarBajaModificacion(); Session["Vehiculo"] = v; txtAño.Text = Convert.ToString(v.Año); txtCosto.Text = v.Costo.ToString(); txtMarca.Text = v.Marca; txtMatricula.Text = v.Matricula; txtModelo.Text = v.Modelo; txtPuertas.Text = v.Puertas.ToString(); txtCapacidad.Text = ((Utilitarios)v).Capacidad.ToString();; if (((Utilitarios)v).Furgoneta_pickup == "Furgoneta") { rblTipo.Items[0].Selected = true; rblTipo.Items[1].Selected = false; } else if (((Utilitarios)v).Furgoneta_pickup == "Pick Up") { rblTipo.Items[0].Selected = false; rblTipo.Items[1].Selected = true; } } } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnBuscar_Click(object sender, EventArgs e) { try { LstDisponibles.Items.Clear(); List <Vehiculos> disponibles = LVehiculo.ListarDisponibles(Convert.ToDateTime(txtFechaI.Text), Convert.ToDateTime(txtFechaF.Text)); //recorre la lista y agrega los datos for (int i = 0; i < disponibles.Count; i++) { LstDisponibles.Items.Add("---------------------------------------------------------------------------------------------------------------------------------------"); LstDisponibles.Items.Add(disponibles[i].ToString()); } } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnModificar_Click(object sender, EventArgs e) { try { for (int i = 0; i < txtAño.Text.Length; i++) { if (!char.IsNumber(Convert.ToChar(txtAño.Text.Substring(i, 1)))) { throw new Exception("Error en año del vehiculo."); } } for (int i = 0; i < txtPuertas.Text.Length; i++) { if (!char.IsNumber(Convert.ToChar(txtPuertas.Text.Substring(i, 1)))) { throw new Exception("Error en Puertas del vehiculo."); } } for (int i = 0; i < txtCosto.Text.Length; i++) { if (!char.IsNumber(Convert.ToChar(txtCosto.Text.Substring(i, 1)))) { if (!char.IsPunctuation(Convert.ToChar(txtCosto.Text.Substring(i, 1)))) { throw new Exception("Error en Costo del vehiculo."); } } } Autos a = new Autos(txtMatricula.Text, txtMarca.Text, txtModelo.Text, Convert.ToInt32(txtAño.Text), Convert.ToInt32(txtPuertas.Text), Convert.ToDecimal(txtCosto.Text), rblAnclaje.SelectedItem.Text); LVehiculo.Modificar(a); Limpiar(); lblError.Text = "Modificado correctamente."; } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnAlquilar_Click(object sender, EventArgs e) { try { int cedula = Convert.ToInt32(txtCedula.Text); Vehiculos v = LVehiculo.Buscar(txtMatricula.Text); if (v == null) { lblError.Text = "No existe el vehiculo."; } Clientes c = LCliente.Buscar(cedula); if (c == null) { lblError.Text = "No existe el cliente."; } Alquiler a = new Alquiler(c, v, mvwInicio.SelectedDate, mvwFin.SelectedDate); LAlquiler.Alquilar(a); lblError.Text = "Se agrego alquiler con exito."; } catch (Exception ex) { lblError.Text = ex.Message; } }