Esempio n. 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            List <ItemBE> Lista = new List <ItemBE>();

            Lista = oFacturaBL.GetDetalle();
            try
            {
                int i = dataGridView1.CurrentRow.Index;
                if (i < 0)
                {
                    return;
                }
                string Numitem  = dataGridView1.Rows[i].Cells[0].Value.ToString();
                int    iNumItem = Convert.ToInt32(Numitem);
                ItemBE oItem    = (from item in Lista.ToArray()
                                   where item.Item.Equals(iNumItem)
                                   select item).Single();

                //Boton Eliminar Detalle
                oFacturaBL.EliminarDetalle(oItem);

                //Actualizar DataGrid
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = oFacturaBL.GetDetalle();

                txtsubtotal.Text = oFacturaBL.SubTotal.ToString();
                txtigv.Text      = oFacturaBL.IGV.ToString();
                txttotal.Text    = oFacturaBL.Total.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("No existen items en el detalle");
                return;
            }
        }
Esempio n. 2
0
        public void modCantidad(int cantidad, string codproducto)
        {
            ItemBE oItemBE = new ItemBE();
            var    item    = (from p in oDetalle  where p.CodProducto == codproducto select p).Single();

            item.Cantidad = cantidad;
        }
Esempio n. 3
0
        //remover de la factura
        private void eliminarItemFactura()
        {
            //verificamos si existen detalles
            if (oFacturaBL.GetDetalle().Count() > 0)
            {
                int    i             = dataGridView1.CurrentRow.Index;
                string itemEliminar  = dataGridView1.Rows[i].Cells[0].Value.ToString();
                ItemBE oitemEliminar = (from item in oFacturaBL.GetDetalle().ToArray()
                                        where item.Item == Convert.ToInt32(itemEliminar)
                                        select item).Single();
                oFacturaBL.RetirarDetalle(oitemEliminar);
                if (oFacturaBL.GetDetalle().Count() > 0)
                {
                    int inicializa = 1;
                    oFacturaBL.GetDetalle().ForEach(list =>
                    {
                        list.Item   = inicializa;
                        inicializa += 1;
                    });
                }
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = oFacturaBL.GetDetalle();
            }
            else
            {
                MessageBox.Show("No hay Detalles a Retirar");
            }

            //List<ItemBE> itemIngresado = new List<ItemBE>();
            //itemIngresado = oFacturaBL.GetDetalle();

            //if (itemIngresado.Count > 0)
            //{
            //    int i = dataGridView1.CurrentRow.Index;
            //    string itemEliminar = dataGridView1.Rows[i].Cells[0].Value.ToString();
            //    ItemBE oitemEliminar = (from item in itemIngresado.ToArray()
            //                            where item.Item == Convert.ToInt32(itemEliminar)
            //                            select item).Single();
            //    itemIngresado.Remove(oitemEliminar);
            //    //actualizando las posiciones de los items
            //    int inicializa = 1;
            //    itemIngresado.ForEach(list =>
            //    {
            //        list.Item = inicializa;
            //        inicializa += 1;
            //    });

            //    //Actualizar DataGrid
            //    dataGridView1.DataSource = null;
            //    dataGridView1.DataSource = itemIngresado;


            //}
            //else
            //{
            //    MessageBox.Show("No hay Detalles a Retirar");
            //}
        }
Esempio n. 4
0
        public ItemBE ObtenerItem(List <ItemBE> oDetalle, String IdProducto)
        {
            ItemBE oItem = null;

            oItem = oDetalle.Find(
                delegate(ItemBE be){
                return(be.Producto.CodProducto == IdProducto);
            }
                );
            return(oItem);
        }
Esempio n. 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            //Validacion
            bool bFlag = false;

            DocumentoErrorProvider.Clear();
            bFlag = ValidarCliente();
            bFlag = ValidarProducto();
            bFlag = ValidarCantidad();

            if (!bFlag)
            {
                //Agregar Items
                ItemBE oItem = new ItemBE();
                oItem = oFacturaBL.ObtenerItem(oFacturaBL.GetDetalle(), otmpProducto.CodProducto);

                if (oItem == null)
                {
                    oFacturaBL.AgregarDetalle(new ItemBE()
                    {
                        Cantidad = Convert.ToInt32(txtcantidad.Text),
                        Precio   = Convert.ToDecimal(txtprecio.Text),
                        Producto = otmpProducto
                    });
                }
                else
                {
                    oFacturaBL.EliminarItem(oFacturaBL.GetDetalle(), otmpProducto.CodProducto);

                    oFacturaBL.AgregarDetalle(new ItemBE()
                    {
                        Cantidad = oItem.Cantidad + Convert.ToInt32(txtcantidad.Text),
                        Precio   = Convert.ToDecimal(txtprecio.Text),
                        Producto = otmpProducto
                    });
                }



                //Actualizar DataGrid
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = oFacturaBL.GetDetalle();


                txtsubtotal.Text = oFacturaBL.SubTotal.ToString();
                txtigv.Text      = oFacturaBL.IGV.ToString();
                txttotal.Text    = oFacturaBL.Total.ToString();
            }
        }
Esempio n. 6
0
        private void button3_Click(object sender, EventArgs e)
        {
            //Boton Agregar a Factura
            ItemBE oItemBE = new ItemBE
            {
                Cantidad = Convert.ToInt32(txtcantidad.Text),
                Precio   = Convert.ToDecimal(txtprecio.Text),
                Producto = otmpProducto
            };
            ValidationResults results = ItemBEValidator.Validate(oItemBE);

            if (!results.IsValid)
            {
                StringBuilder builder = new StringBuilder();
                builder.AppendLine("Customer is not valid:");
                foreach (ValidationResult result in results)
                {
                    builder.AppendLine(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            "{0}: {1}",
                            result.Key,
                            result.Message));
                }
                MessageBox.Show(
                    this,
                    builder.ToString(),
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            else
            {
                oFacturaBL.AgregarDetalle(oItemBE);
                //Actualizar DataGrid
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = oFacturaBL.GetDetalle();

                txtsubtotal.Text = oFacturaBL.SubTotal.ToString();
                txtigv.Text      = oFacturaBL.IGV.ToString();
                txttotal.Text    = oFacturaBL.Total.ToString();
            }
        }
Esempio n. 7
0
        public void AgregarDetalle(ItemBE oItem)
        {
            SubTotal += oItem.Total;

            ItemBE iProducto = null;

            if (oDetalle.Count > 0)
            {
                iProducto = (from item in oDetalle.ToArray()
                             where item.Producto.CodProducto == oItem.Producto.CodProducto
                             select item).SingleOrDefault();
            }

            if (iProducto != null)
            {
                iProducto.Cantidad += oItem.Cantidad;
            }
            else
            {
                oItem.Item = oDetalle.Count + 1;
                oDetalle.Add(oItem);
            }
            //La cantidad de productos que se va llenando
        }
Esempio n. 8
0
 public void AgregarDetalle(ItemBE oItem)
 {
     SubTotal  += oItem.Total;
     oItem.Item = oDetalle.Count + 1;
     oDetalle.Add(oItem);
 }
Esempio n. 9
0
        public ItemBE CarritoDeCompras(UsuarioBE user)
        {
            ItemBE result = null;

            return(result);
        }
Esempio n. 10
0
 public bool ModificarCarritoDeCompra(ItemBE item)
 {
     throw new NotImplementedException();
 }
Esempio n. 11
0
 public bool BorrarDelCarritoDeCompra(ItemBE item)
 {
     throw new NotImplementedException();
 }
Esempio n. 12
0
 public bool AgregarAlCarritoDeCompra(ItemBE item)
 {
     throw new NotImplementedException();
 }
Esempio n. 13
0
 public void EliminarDetalle(ItemBE oItem)
 {
     SubTotal  -= oItem.Total;
     oItem.Item = oDetalle.Count - 1;
     oDetalle.Remove(oItem);
 }
Esempio n. 14
0
 //metodo para actualizar el detalle
 public void ActualizarDetalle(ItemBE oItemActualizar)
 {
     SubTotal += oItemActualizar.Total;
 }
Esempio n. 15
0
 //metodo para eliminar el detalle
 public void RetirarDetalle(ItemBE oItemRetiro)
 {
     SubTotal        -= oItemRetiro.Total;
     oItemRetiro.Item = oDetalle.Count - 1;
     oDetalle.Remove(oItemRetiro);
 }