Esempio n. 1
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();
            }
        }