protected void BtnRealizarAlquiler_Click(object sender, EventArgs e) { try { if ((TBClienteAlquiler.Text == "") || (TBMatriculaAlquiler.Text == "") || (TBInicioAlquiler.Text == "") || (TBFinAlquiler.Text == "")) { LblErrorAlquiler.ForeColor = System.Drawing.Color.Red; LblErrorAlquiler.Text = "Se deben completar todos los campos requeridos"; } else { Cliente oCliente = Logica.LogicaCliente.Buscar(Convert.ToInt32(TBClienteAlquiler.Text)); Vehiculo oVehiculo = Logica.LogicaVehiculo.Buscar(TBMatriculaAlquiler.Text); DateTime oFechaIni = CalInicioAlquiler.SelectedDate; DateTime oFechaFin = CalFinAlquiler.SelectedDate; if (oCliente == null) { LblErrorAlquiler.ForeColor = System.Drawing.Color.Red; LblErrorAlquiler.Text = "El cliente ingresado no existe en la base de datos"; } else if (oVehiculo == null) { LblErrorAlquiler.ForeColor = System.Drawing.Color.Red; LblErrorAlquiler.Text = "El vehículo ingresado no existe en la base de datos"; } else { int oCosto = (oFechaFin.Subtract(oFechaIni)).Days * oVehiculo.CostoAlquiler; Alquiler unAlquiler = new Alquiler(oCliente, oVehiculo, oFechaIni, oFechaFin, oCosto); LogicaAlquiler.Consultar_Alquiler(unAlquiler); LblErrorAlquiler.ForeColor = System.Drawing.Color.Blue; LblErrorAlquiler.Text = "El costo del alquiler será de $" + unAlquiler.Costo + ". ¿Desea confirmar el alquiler?"; TBClienteAlquiler.Enabled = false; TBMatriculaAlquiler.Enabled = false; CalInicioAlquiler.Enabled = false; CalFinAlquiler.Enabled = false; BtnRealizarAlquiler.Enabled = false; BtnConfirmarAlquiler.Enabled = true; BtnCancelarAlquiler.Enabled = true; } } } catch (Exception ex) { LblErrorAlquiler.ForeColor = System.Drawing.Color.Red; LblErrorAlquiler.Text = ex.Message; } }
protected void BtnConfirmarAlquiler_Click(object sender, EventArgs e) { try { Cliente oCliente = Logica.LogicaCliente.Buscar(Convert.ToInt32(TBClienteAlquiler.Text)); Vehiculo oVehiculo = Logica.LogicaVehiculo.Buscar(TBMatriculaAlquiler.Text); DateTime oFechaIni = CalInicioAlquiler.SelectedDate; DateTime oFechaFin = CalFinAlquiler.SelectedDate; if (oCliente == null) { LblErrorAlquiler.ForeColor = System.Drawing.Color.Red; LblErrorAlquiler.Text = "El cliente ingresado no existe en la base de datos"; } else if (oVehiculo == null) { LblErrorAlquiler.ForeColor = System.Drawing.Color.Red; LblErrorAlquiler.Text = "El vehículo ingresado no existe en la base de datos"; } else { int oCosto = (oFechaFin.Subtract(oFechaIni)).Days * oVehiculo.CostoAlquiler; Alquiler unAlquiler = new Alquiler(oCliente, oVehiculo, oFechaIni, oFechaFin, oCosto); LogicaAlquiler.Confirmar_Alquiler(unAlquiler); LblErrorAlquiler.ForeColor = System.Drawing.Color.Blue; LblErrorAlquiler.Text = "El alquiler se realizó correctamente"; BtnConfirmarAlquiler.Enabled = false; BtnCancelarAlquiler.Enabled = false; BtnOkAlquiler.Visible = true; } } catch (Exception ex) { LblErrorAlquiler.ForeColor = System.Drawing.Color.Red; LblErrorAlquiler.Text = ex.Message; } }