Пример #1
0
 private bool ValidarCliente()
 {
     if (txtcliente.Text.Trim() == String.Empty)
     {
         DocumentoErrorProvider.SetError(button1, "Seleccione un cliente");
         return(true);
     }
     return(false);
 }
Пример #2
0
        private bool ValidarProducto()
        {
            if (txtproducto.Text.Trim() == String.Empty)
            {
                DocumentoErrorProvider.SetError(button2, "Seleccione un producto");
                return(true);
            }

            return(false);
        }
Пример #3
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();
            }
        }
Пример #4
0
        private bool ValidarCantidad()
        {
            if (txtcantidad.Text.Trim() == String.Empty)
            {
                DocumentoErrorProvider.SetError(txtcantidad, "Ingrese cantidad de productos");
                return(true);
            }
            char[] testArr  = txtcantidad.Text.ToCharArray();
            bool   testBool = false;

            for (int i = 0; i < testArr.Length; i++)
            {
                if (!char.IsNumber(testArr[i]))
                {
                    testBool = true;
                }
            }
            if (testBool == true)
            {
                DocumentoErrorProvider.SetError(txtcantidad, "Cantidad Invalida");
                return(testBool);
            }
            return(false);
        }