Ejemplo n.º 1
0
        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (txtBucarProducto.Text.Equals(""))
            {
                if (e.KeyChar == 13)
                {
                    btnBuscar.PerformClick();
                    e.Handled = true;
                }
            }
            else
            {
                if (e.KeyChar == 13)
                {
                    ClsDProductos prod     = new ClsDProductos();
                    var           busqueda = prod.BuscarProducto(Convert.ToInt32(txtBucarProducto.Text));

                    if (busqueda.Count < 1)
                    {
                        MessageBox.Show("El codigo no existe");
                        txtBucarProducto.Text = "";
                    }

                    foreach (var iteracion in busqueda)
                    {
                        txtId.Text             = iteracion.idProducto.ToString();
                        txtNombreProducto.Text = iteracion.nombreProducto;
                        txtPrecio.Text         = iteracion.precioProducto.ToString();
                        txtCantidad.Text       = "1";
                        txtCantidad.Focus();
                        txtBucarProducto.Text = "";
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            ClsDProductos VProductos = new ClsDProductos();

            using (sistema_ventasEntities1 db = new sistema_ventasEntities1())
            {
                VProductos.EliminarProducto(Convert.ToInt32(dtgProductos.CurrentRow.Cells[0].Value.ToString()));
                load();
            }
        }
Ejemplo n.º 3
0
        void cargardatos()
        {
            var ClsDProductos = new ClsDProductos();

            dtgProductos.Rows.Clear();

            foreach (var listarDatos in ClsDProductos.MostrarProducto(txtBuscarProducto.Text))
            {
                dtgProductos.Rows.Add(listarDatos.idProducto, listarDatos.nombreProducto, listarDatos.precioProducto);
            }
        }
Ejemplo n.º 4
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            ClsDProductos VProductos = new ClsDProductos();

            using (sistema_ventasEntities1 db = new sistema_ventasEntities1())
            {
                tb_producto producto = new tb_producto();
                producto.nombreProducto = txtProducto.Text;
                producto.precioProducto = txtPrecio.Text;
                producto.estadoProducto = txtEstado.Text;
                VProductos.GuardarProducto(producto);
                load();
            }
        }
Ejemplo n.º 5
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            ClsDProductos VProductos = new ClsDProductos();

            using (sistema_ventasEntities1 db = new sistema_ventasEntities1())
            {
                tb_producto producto = new tb_producto();
                producto.idProducto     = Convert.ToInt32(dtgProductos.CurrentRow.Cells[0].Value.ToString());
                producto.nombreProducto = txtProducto.Text;
                producto.precioProducto = txtPrecio.Text;
                producto.estadoProducto = txtEstado.Text;
                VProductos.ActualizarProducto(producto);
                load();
            }
        }
Ejemplo n.º 6
0
        private void txtCantidad_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                e.Handled = true;
                btnAgregar.PerformClick();
                txtBucarProducto.Focus();
            }
            else
            {
                e.Handled = true;
                ClsDProductos cls      = new ClsDProductos();
                var           busqueda = cls.BuscarProducto(Convert.ToInt32(txtBucarProducto.Text));


                foreach (var iteracion in busqueda)
                {
                    txtId.Text             = iteracion.idProducto.ToString();
                    txtNombreProducto.Text = iteracion.nombreProducto;
                    txtPrecio.Text         = iteracion.precioProducto.ToString();
                }
            }
        }