private void Agregar()
        {
            if (txtCodigo.Text == "")
            {
                Mensaje("Debe ingresar un articulo");
                return;
            }
            if (txtCantidad.Text == "")
            {
                Mensaje("Debe ingresar una cantidad");
                return;
            }

            if (txtPrecio.Text == "")
            {
                Mensaje("Debe ingresar un precio");
                return;
            }
            Boolean Des = false;

            if (chkDescuento.Visible == true)
            {
                if (chkDescuento.Checked == true)
                {
                    Des = true;
                }
            }
            //string Col = "CodArticulo;Nombre;Precio;Cantidad;Subtotal";
            Int32  CodArticulo = Convert.ToInt32(txtCodigo.Text);
            int    Cantidad    = Convert.ToInt32(txtCantidad.Text);
            Double Precio      = 0;

            if (Des == false)
            {
                Precio = Convert.ToDouble(txtPrecio.Text);
            }
            if (Des == true)
            {
                Precio = Convert.ToDouble(txtDescuento.Text);
            }
            Double Subtotal = Precio * Cantidad;
            string Nombre   = txt_Nombre.Text;

            if (fun.Buscar(tbVenta, "CodArticulo", CodArticulo.ToString()) == true)
            {
                Mensaje("Ya se ha ingresado el articulo");
                return;
            }
            int Libreria = 1;

            if (radioJugueteria.Checked == true)
            {
                Libreria = 0;
            }

            string Val = CodArticulo + ";" + Nombre;

            Val = Val + ";" + Precio.ToString();
            Val = Val + ";" + Cantidad.ToString();
            Val = Val + ";" + Subtotal.ToString();
            Val = Val + ";" + Indice.ToString();
            Val = Val + ";" + Libreria;

            tbVenta = fun.AgregarFilas(tbVenta, Val);
            Indice  = Indice + 1;
            //Grilla.Sort(Grilla.Columns[3]), ListSortDirection.Ascending)
            if (tbVenta.Rows.Count > 1)
            {
                Grilla.Sort(Grilla.Columns[5], ListSortDirection.Descending);
            }
            Grilla.DataSource         = tbVenta;
            Grilla.Columns[0].Visible = false;
            Grilla.Columns[5].Visible = false;
            Grilla.Columns[1].Width   = 370;
            Double Total = fun.TotalizarColumna(tbVenta, "Subtotal");

            txtTotal.Text             = Total.ToString();
            txtTotalConDescuento.Text = Total.ToString();
            txtCodigo.Text            = "";
            txt_Codigo.Text           = "";
            txt_CodigoBarra.Text      = "";
            txt_Stock.Text            = "";
            txtPrecio.Text            = "";
            txtCantidad.Text          = "";
            txt_Nombre.Text           = "";
            // Valida = false;
            txt_CodigoBarra.Focus();
            Grilla.Refresh();
            if (tbVenta.Rows.Count > 0)
            {
                for (int i = 0; i < Grilla.Rows.Count - 1; i++)
                {
                    if (i == 0)
                    {
                        Grilla.Rows[0].Selected = true;
                    }
                    else
                    {
                        Grilla.Rows[i].Selected = false;
                    }
                }
            }
            //
        }
示例#2
0
        private void Agregar()
        {
            if (txtCodigo.Text == "")
            {
                Mensaje("Debe ingresar un articulo");
                return;
            }
            if (txtCantidad.Text == "")
            {
                Mensaje("Debe ingresar una cantidad");
                return;
            }

            if (txtPrecio.Text == "")
            {
                Mensaje("Debe ingresar un precio");
                return;
            }

            string Codigo = txtCodigo.Text;

            if (fun.Buscar(tbCompra, "CodArticulo", Codigo) == true)
            {
                Mensaje("Ya se ha ingresado el articulo");
                return;
            }
            int    Libreria = 0;
            string Nombre   = "";

            if (chkLibreria.Checked == true)
            {
                Nombre   = txt_Nombre.Text;
                Libreria = 1;
            }
            else
            {
                Nombre   = txtNombreJuguete.Text;
                Libreria = 0;
            }


            Int32  Cantidad  = Convert.ToInt32(txtCantidad.Text);
            Double Precio    = fun.ToDouble(txtPrecio.Text);
            Double Descuento = 0;
            Double Efectivo  = 0;
            Double Tarjeta   = 0;

            if (txtEfectivo.Text != "")
            {
                Efectivo = Convert.ToDouble(txtEfectivo.Text);
            }
            if (txtTarjeta.Text != "")
            {
                Tarjeta = Convert.ToDouble(txtTarjeta.Text);
            }
            Double PorEfe = 0;
            Double PorTar = 0;

            if (txtPorEfe.Text != "")
            {
                PorEfe = Convert.ToDouble(txtPorEfe.Text);
            }

            if (txtPorTar.Text != "")
            {
                PorTar = Convert.ToDouble(txtPorTar.Text);
            }
            Indice = Indice + 1;
            Double SubTotal = Cantidad * Precio;
            string Val      = Codigo + ";" + Nombre;

            Val               = Val + ";" + Cantidad.ToString();
            Val               = Val + ";" + Precio.ToString();
            Val               = Val + ";" + Descuento.ToString();
            Val               = Val + ";" + Efectivo.ToString().Replace(",", ".");
            Val               = Val + ";" + Tarjeta.ToString().Replace(",", ".");
            Val               = Val + ";" + SubTotal;
            Val               = Val + ";" + Libreria;
            Val               = Val + ";" + PorEfe;
            Val               = Val + ";" + PorTar;
            Val               = Val + ";" + Indice.ToString();
            tbCompra          = fun.AgregarFilas(tbCompra, Val);
            Grilla.DataSource = tbCompra;
            CalcularTotal();
            LimpiarArticulo();
            fun.AnchoColumnas(Grilla, "0;40;10;10;0;10;10;10;0;5;5;0");
            txt_Codigo.Focus();
            if (tbCompra.Rows.Count > 1)
            {
                Grilla.Sort(Grilla.Columns[11], ListSortDirection.Descending);
            }
        }