protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["Id"] == null) { Response.Redirect("ListaCarros.aspx"); } else { bool disponibilidad = true; string idCarro = Request.QueryString["Id"].ToString(); VOCarro carro = BLLCarro.ConsultarCarro(idCarro); CargarFormulario(carro); disponibilidad = (bool)carro.Disponibilidad; if (disponibilidad) { lblCarro.ForeColor = System.Drawing.Color.Green; btnEliminar.Visible = true; } else { lblCarro.ForeColor = System.Drawing.Color.Red; btnEliminar.Visible = false; } } } }
public void CatalogoCarros() { ddlCarro.Items.Clear(); List <VOCarro> carros = BLLCarro.ConsultarCarros(true); foreach (VOCarro carro in carros) { ddlCarro.Items.Add(new ListItem(carro.Nombre, carro.IdCarro.ToString())); } }
protected void gvRentas_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = int.Parse(e.CommandArgument.ToString()); string idRenta = gvRentas.DataKeys[index].Values["IdRenta"].ToString(); string Carro = gvRentas.Rows[index].Cells[1].Text; string estado = "FINALIZADA"; BLLRenta.FinalizarRentas(estado, Convert.ToInt32(idRenta)); BLLCarro.ActualizarDisponibilidad(true, Convert.ToInt32(Carro)); Response.Redirect("Finalizadas.aspx"); } }
protected void btnEliminar_Click(object sender, EventArgs e) { try { BLLCarro.Eliminar(lblCarro.Text); LimpiarFormulario(); Response.Redirect("ListaCarros.aspx"); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, GetType(), "Mensaje de error", "alert('Se registro un error al realizar la operacion." + ex.Message + "');", true); } }
protected void btnGuardar_Click(object sender, EventArgs e) { try { VOCarro carro = new VOCarro(txtNombreCarro.Text, txtModeloCarro.Text, txtMarcaCarro.Text, txtMatriculaCarro.Text, Convert.ToInt32(txtAnioCarro.Text), Convert.ToDouble(txtPrecioCarro.Text), imgFotoCarro.ImageUrl, true); BLLCarro.Insertar(carro); LimpiarFormulario(); Response.Redirect("ListaCarros.aspx"); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, GetType(), "Mensaje de error", "alert('Se registro un error a realizar la operacion." + ex.Message + "');", true); } }
protected void btnGuardar_Click(object sender, EventArgs e) { try { DateTime prueba = DateTime.Now; VORenta renta = new VORenta(int.Parse(ddlCarro.SelectedValue), int.Parse(ddlCliente.SelectedValue), int.Parse(txtDuracion.Text), Convert.ToDateTime(FechaRenta.Value), "EN_RENTA" ); BLLRenta.InsertarRenta(renta); BLLCarro.ActualizarDisponibilidad(false, int.Parse(ddlCarro.SelectedValue)); LimpiarFormulario(); Response.Redirect("EnRenta.aspx"); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, GetType(), "Mensaje de error", "alert('Se registro un error al realizar la operacion." + ex.Message + "');", true); } }
public void CargarGrid() { gvCarros.DataSource = BLLCarro.ConsultarCarros(null); gvCarros.DataBind(); }