Exemplo n.º 1
0
        private void CargarDatos()
        {
            dtvReceta.Rows.Clear();
            int id;

            id = Int32.Parse(txtIdProd.Text);
            using (RestauranteBDEntities1 bd = new RestauranteBDEntities1())
            {
                productosVenta = bd.ProductosVenta.Where(idProdV => idProdV.idProductoV == id).First();
                txtNombre.Text = productosVenta.nombre.ToString();

                var JoinReceta = from recetass in bd.Recetas
                                 from productosCompra in bd.ProductosCompra
                                 where recetass.idProductoV == id
                                 where recetass.idProductoC == productosCompra.idProductoC
                                 select new
                {
                    ID       = recetass.idReceta,
                    IDPROD   = productosCompra.idProductoC,
                    NOMBRE   = productosCompra.nombre,
                    CANTIDAD = recetass.cantidadProdIngrediente
                };

                foreach (var iterar in JoinReceta)
                {
                    dtvReceta.Rows.Add(iterar.ID, iterar.IDPROD, iterar.NOMBRE, iterar.CANTIDAD);
                }
            }
        }
Exemplo n.º 2
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     productosVentaBindingSource.EndEdit();
     productosVenta = (ProductosVenta)productosVentaBindingSource.Current;
     cProductosVenta.eliminarProductoV(productosVenta);
     cargarDatos();
 }
Exemplo n.º 3
0
        private void txtBusqueda_KeyUp(object sender, KeyEventArgs e)
        {
            if (txtBusqueda.Text == "")
            {
                if (e.KeyCode == Keys.Enter)
                {
                    btnBuscar.PerformClick();
                }
            }
            else if (e.KeyCode == Keys.Enter)
            {
                using (RestauranteBDEntities1 bd = new RestauranteBDEntities1())
                {
                    ProductosVenta prod = new ProductosVenta();

                    int Buscar     = int.Parse(txtBusqueda.Text);
                    var buscarProd = from producto in bd.ProductosVenta
                                     where producto.idProductoV == Buscar && producto.estado == "Activo"
                                     select producto;

                    if (buscarProd.Count() > 0)
                    {
                        prod = bd.ProductosVenta.Where(idProducto => idProducto.idProductoV == Buscar).First();
                        var listaProd = from recetas in bd.Recetas
                                        where recetas.idProductoV == prod.idProductoV
                                        select recetas;
                        if (listaProd.Count() > 0)
                        {
                            Categorias categorias = new Categorias();
                            categorias = bd.Categorias.Where(VerificarId => VerificarId.idCategoria == prod.idCategoria).First();
                            if (categorias.estado == "Activo")
                            {
                                txtCodigoProd.Text = Convert.ToString(prod.idProductoV);
                                txtNombreProd.Text = Convert.ToString(prod.nombre);
                                txtPrecio.Text     = Convert.ToString(prod.precio);
                                nupCantidad.Focus();
                                txtBusqueda.Text = "";
                                intentos         = 2;
                            }
                            else
                            {
                                MessageBox.Show("¡La categoria del Producto ingresado ha sido eliminada!", "Actualize Producto", MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("¡El codigo del Producto ingresado aun no tiene Receta!", "Ingrese Receta", MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("¡El producto no se encuentra en los Registros!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtBusqueda.Text = "";
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void btnReceta_Click(object sender, EventArgs e)
        {
            ProductosVenta productosV = new ProductosVenta();

            productosV = (ProductosVenta)productosVentaBindingSource1.Current;
            frmRecetas frmReceta = new frmRecetas(productosV);

            frmReceta.MdiParent = this.MdiParent;
            frmReceta.Show();
        }
Exemplo n.º 5
0
 private void productosVentaDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     productosVenta = (ProductosVenta)productosVentaBindingSource1.Current;
     productosVentaBindingSource.DataSource = productosVenta;
     idProductoVTextBox.Visible             = true;
     IdProductoVlabel.Visible = true;
     btnGuardar.Enabled       = false;
     btnModificar.Enabled     = true;
     btnEliminar.Enabled      = true;
 }
Exemplo n.º 6
0
        internal void eliminarProductoV(ProductosVenta PV)
        {
            IDbConnection     con        = Conexion.Conexion.Conectar();
            String            consulta   = "sp_eliminarProductoVenta";
            DynamicParameters parametros = new DynamicParameters();

            parametros.Add("@idProductoV", PV.idProductoV, DbType.Int32);
            con.Open();
            con.Execute(consulta, parametros, commandType: CommandType.StoredProcedure);
            con.Close();
        }
Exemplo n.º 7
0
        internal void guardarProductoV(ProductosVenta PV)
        {
            IDbConnection     con        = Conexion.Conexion.Conectar();
            String            consulta   = "sp_nuevoProductoVenta";
            DynamicParameters parametros = new DynamicParameters();

            parametros.Add("@nombre", PV.nombre, DbType.String);
            parametros.Add("@precio", PV.precio, DbType.Decimal);
            parametros.Add("@categoria", PV.categoria, DbType.String);
            con.Open();
            con.Execute(consulta, parametros, commandType: CommandType.StoredProcedure);
            con.Close();
        }
Exemplo n.º 8
0
        internal void actualizarReceta(Recetas R, ProductosVenta PV)
        {
            IDbConnection     con        = Conexion.Conexion.Conectar();
            String            consulta   = "sp_modificarReceta";
            DynamicParameters parametros = new DynamicParameters();

            parametros.Add("@idProductoV", PV.idProductoV, DbType.Int32);
            parametros.Add("@idProductoC", R.idProductoC, DbType.Int32);
            parametros.Add("@cantidad", R.cantidadEstimada, DbType.String);
            con.Open();
            con.Execute(consulta, parametros, commandType: CommandType.StoredProcedure);
            con.Close();
        }
Exemplo n.º 9
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (nombreTextBox.Text.Equals("") || precioTextBox.Text.Equals("0") || categoriaTextBox.Text.Equals(""))
     {
         MessageBox.Show("Ingrese todos los campos para Continuar");
     }
     else
     {
         productosVentaBindingSource.EndEdit();
         productosVenta = (ProductosVenta)productosVentaBindingSource.Current;
         cProductosVenta.guardarProductoV(productosVenta);
         cargarDatos();
     }
 }
Exemplo n.º 10
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("¿Estás seguro que quieres eliminar?, \n¡la acción no se podrá deshacer!", "Confirmar", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.OK)
            {
                using (RestauranteBDEntities1 bd = new RestauranteBDEntities1())
                {
                    String id = lblCodigo.Text;

                    prod                 = bd.ProductosVenta.Find(int.Parse(id));
                    prod.estado          = "Inactivo";
                    bd.Entry(prod).State = System.Data.Entity.EntityState.Modified;
                    bd.SaveChanges();
                }

                MessageBox.Show("¡Producto eliminado con éxito!", "Completado", MessageBoxButtons.OK, MessageBoxIcon.None);
                this.Close();
            }
        }
Exemplo n.º 11
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("¿Estás seguro que quieres editar?, \n¡la acción no se podrá deshacer!", "Confirmar", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.OK)
            {
                using (RestauranteBDEntities1 bd = new RestauranteBDEntities1())
                {
                    String id2 = lblCodigo.Text;
                    int    idC = int.Parse(id2);

                    prod             = bd.ProductosVenta.Where(VerificarID => VerificarID.idProductoV == idC).First();
                    prod.nombre      = txtNombreProd.Text;
                    prod.precio      = decimal.Parse(txtPrecioProd.Text);
                    prod.idCategoria = int.Parse(categ);

                    bd.Entry(prod).State = System.Data.Entity.EntityState.Modified;
                    bd.SaveChanges();
                }

                MessageBox.Show("¡Producto editado con éxito!", "Completado", MessageBoxButtons.OK, MessageBoxIcon.None);
                this.Close();
            }
        }
Exemplo n.º 12
0
 internal void guardarProductoV(ProductosVenta PV)
 {
     mProductoVenta.guardarProductoV(PV);
 }
Exemplo n.º 13
0
 internal void eliminarReceta(Recetas R, ProductosVenta PV)
 {
     mRecetas.eliminarReceta(R, PV);
 }
Exemplo n.º 14
0
 internal void actualizarReceta(Recetas R, ProductosVenta PV)
 {
     mRecetas.actualizarReceta(R, PV);
 }
Exemplo n.º 15
0
 internal void guardarReceta(Recetas R, ProductosVenta PV)
 {
     mRecetas.guardarReceta(R, PV);
 }
Exemplo n.º 16
0
 internal void actualizarProductoV(ProductosVenta PV)
 {
     mProductoVenta.actualizarProductoV(PV);
 }
Exemplo n.º 17
0
 internal void eliminarProductoV(ProductosVenta PV)
 {
     mProductoVenta.eliminarProductoV(PV);
 }
Exemplo n.º 18
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                decimal precioCon;
                if (txtNombreProd.Text.Equals("") || txtPrecioProd.Text.Equals(""))
                {
                    MessageBox.Show("¡Complete todos los campos para continuar!", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (decimal.TryParse(txtPrecioProd.Text, out precioCon) == false)
                    {
                        MessageBox.Show("¡Ingrese correctamente el precio!");
                    }
                    else
                    {
                        string nombre = txtNombreProd.Text;
                        using (RestauranteBDEntities1 bd = new RestauranteBDEntities1())
                        {
                            var listaPV = from producto in bd.ProductosVenta
                                          where producto.nombre.Equals(nombre) && producto.estado == "Activo"
                                          select producto;

                            if (listaPV.Count() > 0)
                            {
                                MessageBox.Show("¡El Producto ya existe!", "Advertencia",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Warning);
                            }
                            else
                            {
                                var listaProveedor = from producto in bd.ProductosVenta
                                                     where producto.nombre.Equals(nombre) && producto.estado == "Inactivo"
                                                     select producto;

                                if (listaProveedor.Count() > 0)
                                {
                                    prod             = bd.ProductosVenta.Where(VerificarNombre => VerificarNombre.nombre == nombre).First();
                                    prod.precio      = decimal.Parse(txtPrecioProd.Text);
                                    prod.idCategoria = int.Parse(categ);
                                    prod.estado      = "Activo";

                                    bd.Entry(prod).State = System.Data.Entity.EntityState.Modified;
                                    bd.SaveChanges();
                                    MessageBox.Show("¡Producto insertado con éxito!", "Completado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.Close();
                                    listado.dtvProductos.Rows.Clear();
                                    listado.btnActualizar.PerformClick();
                                }
                                else
                                {
                                    prod.nombre      = txtNombreProd.Text;
                                    prod.precio      = decimal.Parse(txtPrecioProd.Text);
                                    prod.idCategoria = int.Parse(categ);
                                    prod.estado      = "Activo";

                                    int idCat = int.Parse(categ);
                                    categoria                 = bd.Categorias.Where(Id => Id.idCategoria == idCat).First();
                                    categoria.estado          = "Activo";
                                    bd.Entry(categoria).State = System.Data.Entity.EntityState.Modified;
                                    bd.SaveChanges();

                                    bd.ProductosVenta.Add(prod);
                                    bd.SaveChanges();

                                    MessageBox.Show("¡Producto insertado con éxito!", "Completado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.Close();
                                    listado.dtvProductos.Rows.Clear();
                                    listado.CargarDatos();
                                    listado.btnActualizar.PerformClick();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("¡Verifique la lista desplegable!", "Verificación", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 19
0
 public frmRecetas(ProductosVenta productosV)
 {
     InitializeComponent();
     this.productosV = productosV;
 }