Example #1
0
        private void btnSeleccionarIngrediente_Click(object sender, EventArgs e)
        {
            if (validarCampos())
            {
                //Asignamos los valores a la lista.
                if (lstvIngrediente.SelectedItems.Count > 0)
                {
                    int idIngrediente = Convert.ToInt16(lstvIngrediente.SelectedItems[0].Text);
                    foreach (tbIngredientes p in listaIngredientes)
                    {
                        if (idIngrediente == p.idIngrediente)
                        {
                            detalleProducto.cantidad      = float.Parse(txtCantidadIngrediente.Text.Trim());
                            detalleProducto.idIngrediente = p.idIngrediente;
                        }
                    }

                    recuperarDetalleProducto(detalleProducto);

                    this.Close();
                }
                else
                {
                    detalleProducto = null;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Recuperamos los ingredientes del formulario agregar ingrediente
        /// </summary>
        /// <param name="detalle"></param>
        private void recuperarDetalleProducto(tbDetalleProducto detalle)
        {
            detalleProducto = detalle;

            if (detalleProducto != null)
            {
                cargarDetalleProducto(detalleProducto);
            }
        }
Example #3
0
        void cargarDetalleProducto(tbDetalleProducto entidad)
        {
            if (bandera == 2)
            {
                entidad.idProducto = txtCodigoProducto.Text.Trim();
            }


            tbDetalleProducto entidadAux = ProductoIns.getDetalleProdByIngreProd(entidad.idIngrediente, entidad.idProducto);

            //Asignamos la nueva entidad a la coleccion.
            if (entidadAux != null)
            {
                if (entidadAux.id != null)
                {
                    entidadAux.cantidad = entidad.cantidad;
                    listaDetalleProduc.Add(entidadAux);
                }
                else
                {
                    listaDetalleProduc.Add(entidad);
                }
            }
            else
            {
                listaDetalleProduc.Add(entidad);
            }


            //Limpiamos los items en la lista.
            lstvDetalleProducto.Items.Clear();

            precioReal = 0.0F;

            foreach (tbDetalleProducto p in listaDetalleProduc)
            {
                ListViewItem itemNuevo = new ListViewItem();

                itemNuevo.Text = p.idIngrediente.ToString();

                //realizamos consulta para recuperar el nombre del ingrediente segun su ID
                tbIngredientes nombreIngrediente = ProductoIns.getNombrePorID(p.idIngrediente);

                itemNuevo.SubItems.Add(nombreIngrediente.nombre.Trim());

                itemNuevo.SubItems.Add(p.cantidad.ToString());

                lstvDetalleProducto.Items.Add(itemNuevo);


                //Llamamos el metodo para calcular el precio Real.
                calcularPrecioReal(p.idIngrediente, p.cantidad);
            }
        }
Example #4
0
 private void lstvDetalleProducto_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstvDetalleProducto.SelectedItems.Count > 0)
     {
         int select = Convert.ToInt16(lstvDetalleProducto.SelectedItems[0].Text.Trim());
         foreach (tbDetalleProducto ingrediente in listaDetalleProduc)
         {
             if (ingrediente.idIngrediente == select)
             {
                 quitarIngrediente = ingrediente;
             }
         }
     }
 }
Example #5
0
 /// <summary>
 /// Guardamos el nuevo detalle de producto.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public tbDetalleProducto GuardarDetalleProducto(tbDetalleProducto entity)
 {
     try
     {
         using (dbSisSodInaEntities context = new dbSisSodInaEntities())
         {
             context.tbDetalleProducto.Add(entity);
             context.SaveChanges();
             return(entity);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Example #6
0
 /// <summary>
 /// Borramos la informacion enviada de la base de datos.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public tbDetalleProducto EliminarDetalleProducto(tbDetalleProducto entity)
 {
     try
     {
         using (dbSisSodInaEntities context = new dbSisSodInaEntities())
         {
             context.Entry(entity).State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
             return(entity);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
         throw;
     }
 }
Example #7
0
        private void lstvDetalleProducto_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            // Al seleccionar un ingrediente, este pasa a ser almacenado en una variable global.
            if (lstvDetalleProducto.SelectedItems.Count > 0)
            {
                int temp = Convert.ToInt16(lstvDetalleProducto.SelectedItems[0].Text.Trim());

                // Recorremos la lista de Detalle Producto
                foreach (tbDetalleProducto item in listaDetalleProduc)
                {
                    // Comparamos cada uno de los items, si lo encuentro lo inngresa en la variables para proceder a eliminar.
                    if (item.idIngrediente == temp)
                    {
                        // Cargamos el item seleccionado en la variable para eliminar.
                        quitarIngrediente = item;
                    }
                }
            }
        }
Example #8
0
 /// <summary>
 /// Guardamos el detalle de producto nuevo.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public tbDetalleProducto guardarDetalleProducto(tbDetalleProducto entity)
 {
     return(productoIns.GuardarDetalleProducto(entity));
 }
Example #9
0
 /// <summary>
 /// Eliminamos el detalle del producto de la base de datos.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public tbDetalleProducto BorrarDetalleProducto(tbDetalleProducto entity)
 {
     return(productoIns.EliminarDetalleProducto(entity));
 }
Example #10
0
 private void frmAgregarIngredieteProducto_FormClosed(object sender, FormClosedEventArgs e)
 {
     //Asignamos nulo el campo porque se esta saliendo del formulario
     detalleProducto = null;
 }
Example #11
0
        private void btnCancelar_Click(object sender, EventArgs e)
        {
            detalleProducto = null;

            this.Close();
        }