protected void Page_Load(object sender, EventArgs e) { this.nuevaConexion = new ConexionDesconectada(); if (!IsPostBack) { nuevaConexion.copiarBaseDatos(); this.nuevaConexion.llenarCombo(ref this.CategoryID, "Categories", "CategoryID", "CategoryName"); this.nuevaConexion.llenarCombo(ref this.SupplierID, "Suppliers", "SupplierID", "CompanyName"); this.nuevaConexion.desconectar(); int id = int.Parse(Request.QueryString["ProductoID"]); Product productos = obj.obtenerProductoPorID(id); if (productos != null) { this.ProductID.Value = productos.ProductID.ToString(); this.ProductName.Text = productos.ProductName.ToString(); this.SupplierID.SelectedValue = productos.SupplierID.ToString(); this.CategoryID.SelectedValue = productos.CategoryID.ToString(); this.QuantityPerUnit.Text = productos.QuantityPerUnit.ToString(); this.UnitPrice.Text = productos.UnitPrice.ToString(); this.UnitsInStock.Text = productos.UnitsInStock.ToString(); this.UnitsOnOrder.Text = productos.UnitsInStock.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { this.nuevaConexion = new ConexionDesconectada(); if (!IsPostBack) { nuevaConexion.copiarBaseDatos(); this.nuevaConexion.llenarCombo(ref this.CategoryID, "Categories", "CategoryID", "CategoryName"); this.nuevaConexion.llenarCombo(ref this.SupplierID, "Suppliers", "SupplierID", "CompanyName"); object[] datosRetornados = this.nuevaConexion.getDataRow(int.Parse(Request.QueryString["ProductoID"])); this.nuevaConexion.desconectar(); if (datosRetornados != null) { this.ProductID.Value = datosRetornados[0].ToString(); this.ProductName.Text = datosRetornados[1].ToString(); this.SupplierID.SelectedValue = datosRetornados[2].ToString(); this.CategoryID.SelectedValue = datosRetornados[3].ToString(); this.QuantityPerUnit.Text = datosRetornados[4].ToString(); this.UnitPrice.Text = datosRetornados[5].ToString(); this.UnitsInStock.Text = datosRetornados[6].ToString(); this.UnitsOnOrder.Text = datosRetornados[7].ToString(); } } }
protected void btnBuscar_Click(object sender, EventArgs e) { this.nuevaConexion = new ConexionDesconectada(); this.nuevaConexion.copiarBaseDatos(); this.nuevaConexion.cargarProductosEnTabla(ref GridView1, this.ddlCategorias.SelectedValue, this.ddlProveedor.SelectedValue); this.nuevaConexion.desconectar(); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int index = Convert.ToInt32(e.CommandArgument); GridViewRow filaSeleccionada = this.GridView1.Rows[index]; TableCell celdaIDProducto = filaSeleccionada.Cells[2]; if (e.CommandName == "Seleccionar") { Response.Redirect("EditarRegistro.aspx?ProductoID=" + celdaIDProducto.Text); } else if (e.CommandName == "Eliminar") { this.nuevaConexion = new ConexionDesconectada(); this.nuevaConexion.copiarBaseDatos(); if (this.nuevaConexion.eliminarProducto(int.Parse(celdaIDProducto.Text)) < 1) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "error_msg", "alert('Error al eliminar el producto');", true); } else { nuevaConexion.desconectar(); Response.Redirect("Default.aspx"); } } }
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { this.nuevaConexion = new ConexionDesconectada(); this.nuevaConexion.copiarBaseDatos(); this.GridView1.PageIndex = e.NewPageIndex; this.nuevaConexion.cargarProductosEnTabla(ref GridView1, this.ddlCategorias.SelectedValue, this.ddlProveedor.SelectedValue); this.nuevaConexion.desconectar(); }
protected void Page_Load(object sender, EventArgs e) { this.nuevaConexion = new ConexionDesconectada(); if (!IsPostBack) { nuevaConexion.copiarBaseDatos(); this.nuevaConexion.llenarCombo(ref this.CategoryID, "Categories", "CategoryID", "CategoryName"); this.nuevaConexion.llenarCombo(ref this.SupplierID, "Suppliers", "SupplierID", "CompanyName"); this.nuevaConexion.desconectar(); } }
protected void Page_Load(object sender, EventArgs e) { this.nuevaConexion = new ConexionDesconectada(); if (!IsPostBack) { this.nuevaConexion.copiarBaseDatos(); this.nuevaConexion.llenarCombo(ref this.ddlCategorias, "Categories", "CategoryID", "CategoryName"); this.nuevaConexion.llenarCombo(ref this.ddlProveedor, "Suppliers", "SupplierID", "CompanyName"); this.ddlCategorias.Items.Insert(0, new ListItem("Ver Todos", "0")); this.ddlProveedor.Items.Insert(0, new ListItem("Ver Todos", "0")); this.nuevaConexion.cargarProductosEnTabla(ref this.GridView1, "0", "0"); this.nuevaConexion.desconectar(); } }
protected void btnModificar_Click(object sender, EventArgs e) { this.nuevaConexion = new ConexionDesconectada(); this.nuevaConexion.copiarBaseDatos(); object[] datosActualizados = new object[7] { this.ProductName.Text, this.SupplierID.SelectedValue, this.CategoryID.SelectedValue, this.QuantityPerUnit.Text, this.UnitPrice.Text, this.UnitsInStock.Text, this.UnitsOnOrder.Text }; int filasActualizadas = this.nuevaConexion.actualizarProducto(int.Parse(this.ProductID.Value.ToString()), datosActualizados); this.nuevaConexion.desconectar(); if (filasActualizadas > 0) { Response.Redirect("Default.aspx"); } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "error_msg", "alert('Error al modificar el producto');", true); } }