Ejemplo n.º 1
0
        public static string InsertarProducto(string Nombre, string Precio, string Existencia)
        {
            BDProductos BD = new BDProductos();

            //Registrar
            if (registro == null)
            {
                bool respuesta = BD.InsertarProducto(Nombre, Precio, Existencia);

                if (respuesta == true)
                {
                    return("Correcto");
                    //registro = null;
                }
                return("Falso");
            }
            //Editar
            else
            {
                bool respuesta = BD.ActualizarProducto(Nombre, Precio, Existencia, int.Parse(registro.Rows[0]["Id"].ToString()));

                if (respuesta == true)
                {
                    return("Correcto");
                    //registro = null;
                }
                return("Falso");
            }
        }
Ejemplo n.º 2
0
        //CARGAR GRID UNIDADES
        public void CargarGrid()
        {
            try
            {
                registro = null;
                BDProductos BD        = new BDProductos();
                DataTable   Productos = BD.Grid();
                dgvProductos.DataSource = Productos;
                dgvProductos.DataBind();
            }

            catch (Exception)
            {
                return;
            }
        }
Ejemplo n.º 3
0
        //EDITAR PRODUCTO
        protected void dgvProductos_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string str = null;

            if (e.CommandName == "Editar")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = dgvProductos.Rows[index];

                str = row.Cells[0].Text;

                BDProductos BD = new BDProductos();
                //Consultar Producto mediante el Id

                registro           = BD.ProductoMedianteID(int.Parse(str));
                txtNombre.Text     = registro.Rows[0]["Nombre"].ToString();
                txtPrecio.Text     = registro.Rows[0]["Precio"].ToString();
                txtExistencia.Text = registro.Rows[0]["Existencia"].ToString();

                viewGrid.Visible   = false;
                viewCampos.Visible = true;

                //ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:message_info('Registro eliminado','');", true);
            }

            else if (e.CommandName == "Eliminar")//Eliminar producto
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = dgvProductos.Rows[index];

                str = row.Cells[0].Text;

                BDProductos BD = new BDProductos();
                BD.EliminarProducto(int.Parse(str));
                CargarGrid();
            }
        }