private void txt_CodigoBarra_TextChanged(object sender, EventArgs e)
        {
            int b = 0;

            if (txt_CodigoBarra.Text.Length > 7)
            {
                string    CodigoBarra = txt_CodigoBarra.Text;
                cArticulo art         = new cArticulo();
                DataTable trdo        = art.GetArticulo("", CodigoBarra, "");
                if (trdo.Rows.Count > 0)
                {
                    if (trdo.Rows[0]["CodArticulo"].ToString() != "")
                    {
                        b = 1;
                        txtCodigo.Text           = trdo.Rows[0]["CodArticulo"].ToString();
                        txt_Nombre.SelectedValue = txtCodigo.Text;
                        txt_CodigoBarra.Text     = trdo.Rows[0]["CodigoBarra"].ToString();
                        txt_Codigo.Text          = trdo.Rows[0]["Codigo"].ToString();
                        txt_Stock.Text           = trdo.Rows[0]["Stock"].ToString();
                    }
                }
                if (b == 1)
                {
                    PuedeAgregar     = false;
                    txtCantidad.Text = "1";
                    txtCantidad.Focus();
                }
            }
        }
        private void LlenarComboArticulo()
        {
            cFunciones fun = new cFunciones();
            cArticulo  art = new cArticulo();
            // DataTable trdo = art.GetTodosArticulos();
            DataTable trdo = art.GetTodosArticulosJuguetes();

            txt_Nombre.DataSource    = trdo;
            txt_Nombre.ValueMember   = "CodArticulo";
            txt_Nombre.DisplayMember = "Nombre";
            AutoCompleteStringCollection coleccion = new AutoCompleteStringCollection();

            foreach (DataRow r in trdo.Rows)
            {
                coleccion.Add(r["Nombre"].ToString());
            }

            /*
             * cJuguete jug = new cJuguete();
             * DataTable tbJuguete = jug.GetTodosJuguetes();
             * foreach (DataRow r in tbJuguete.Rows)
             * {
             *  coleccion.Add(r["Nombre"].ToString());
             * }
             */
            txt_Nombre.AutoCompleteCustomSource = coleccion;
            txt_Nombre.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            txt_Nombre.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            txt_Nombre.SelectedIndex            = -1;
        }
Example #3
0
        private void CargarArticulosGrilla()
        {
            cArticulo  articulo = new cArticulo();
            MiObjetoDB db       = new MiObjetoDB();

            db.LlenarCBoxDB(ddlArticuloGrilla, articulo.getTodosLosArticulos(), "DESCRIPCION", "COD_ARTICULO");
        }
Example #4
0
        private void ConsultasDeArticulosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            cArticulo cArticulo = new cArticulo();

            cArticulo.MdiParent     = this;
            cArticulo.StartPosition = FormStartPosition.CenterScreen;
            cArticulo.Show();
        }
Example #5
0
        public void GrabarDetalleCompra(SqlConnection con, SqlTransaction Transaccion, Int32 CodCompra)
        {
            Int32  CodArticulo = 0;
            int    Cantidad    = 0;
            Double Costo       = 0;
            Double Descueneto  = 0;
            Double Subtotal    = 0;
            int    Libreria    = 0;
            Double PorEfe      = 0;
            Double PorTar      = 0;

            cJuguete              jug        = new Clases.cJuguete();
            cArticulo             objArt     = new cArticulo();
            cDetalleCompra        detalle    = new cDetalleCompra();
            cDetalleCompraJuguete detalleJug = new cDetalleCompraJuguete();
            cArticulo             art        = new cArticulo();

            //string Col = "CodArticulo;Nombre;Cantidad;Precio;Descuento;Subtotal";
            for (int i = 0; i < tbCompra.Rows.Count; i++)
            {
                Libreria    = Convert.ToInt32(tbCompra.Rows[i]["Libreria"]);
                CodArticulo = Convert.ToInt32(tbCompra.Rows[i]["CodArticulo"].ToString());
                Cantidad    = Convert.ToInt32(tbCompra.Rows[i]["Cantidad"].ToString());
                art.ActualizarStock(con, Transaccion, CodArticulo, Cantidad);
                Costo      = fun.ToDouble(tbCompra.Rows[i]["Precio"].ToString());
                Descueneto = fun.ToDouble(tbCompra.Rows[i]["Descuento"].ToString());
                Subtotal   = fun.ToDouble(tbCompra.Rows[i]["Subtotal"].ToString());
                if (tbCompra.Rows[i]["PorEfe"].ToString() != "0")
                {
                    PorEfe = Convert.ToDouble(tbCompra.Rows[i]["PorEfe"].ToString());
                }

                if (tbCompra.Rows[i]["PorTar"].ToString() != "0")
                {
                    PorTar = Convert.ToDouble(tbCompra.Rows[i]["PorTar"].ToString());
                }

                if (Libreria == 1)
                {
                    detalle.Insertar(con, Transaccion, CodCompra, CodArticulo, Cantidad, Costo, Descueneto, Subtotal);
                    art.ActualizarCosto(con, Transaccion, CodArticulo, Costo);
                    if (PorEfe > 0 || PorTar > 0)
                    {
                        art.ActualizarPorcentajes(con, Transaccion, CodArticulo, PorEfe, PorTar);
                    }
                }
                if (Libreria == 0)
                {
                    jug.ActualizarCosto(con, Transaccion, CodArticulo, Costo);
                    detalleJug.Insertar(con, Transaccion, CodCompra, CodArticulo, Cantidad, Costo, Descueneto, Subtotal);
                    if (PorEfe > 0 || PorTar > 0)
                    {
                        jug.ActualizarPorcentajes(con, Transaccion, CodArticulo, PorEfe, PorTar);
                    }
                }
            }
        }
Example #6
0
        private void BuscarLibreriaxCodigoBarra()
        {
            int b = 0;

            if (txt_CodigoBarra.Text.Length > 7)
            {
                string    CodigoBarra = txt_CodigoBarra.Text;
                cArticulo art         = new cArticulo();
                DataTable trdo        = art.GetArticuloxCodigoBarra(CodigoBarra);
                if (trdo.Rows.Count > 0)
                {
                    if (trdo.Rows[0]["CodArticulo"].ToString() != "")
                    {
                        b = 1;
                        txtCodigo.Text           = trdo.Rows[0]["CodArticulo"].ToString();
                        txt_Nombre.SelectedValue = txtCodigo.Text;
                        txt_CodigoBarra.Text     = trdo.Rows[0]["CodigoBarra"].ToString();
                        txt_Codigo.Text          = trdo.Rows[0]["Codigo"].ToString();
                        txt_Stock.Text           = trdo.Rows[0]["Stock"].ToString();
                        txtPrecio.Text           = trdo.Rows[0]["Costo"].ToString();
                        txtPrecio.Text           = trdo.Rows[0]["Costo"].ToString();
                        txtPorEfe.Text           = trdo.Rows[0]["PorEfe"].ToString();
                        txtPorTar.Text           = trdo.Rows[0]["PorTar"].ToString();
                        if (trdo.Rows[0]["Costo"].ToString() != "")
                        {
                            Double Costo = Math.Round(Convert.ToDouble(trdo.Rows[0]["Costo"]), 0);
                            txtPrecio.Text = Costo.ToString();
                            CalcularPrecioTarjetaEfectivo(Costo);
                        }


                        if (txtPorEfe.Text != "")
                        {
                            txtPorEfe.Text = fun.SepararDecimales(txtPorEfe.Text);
                        }

                        if (txtPorTar.Text != "")
                        {
                            txtPorTar.Text = fun.SepararDecimales(txtPorTar.Text);
                        }
                    }
                }
                if (b == 1)
                {
                    PuedeAgregar     = false;
                    txtCantidad.Text = "";
                    txtCantidad.Focus();
                }
            }
        }
Example #7
0
        private void BuscarArticuloxCodigo(Int32 CodArt)
        {
            int       Operacion = Convert.ToInt32(CmbTipoOperacion.SelectedValue);
            cArticulo art       = new cArticulo();
            DataTable trdo      = art.GetArticuloxCodArt(CodArt);

            if (trdo.Rows.Count > 0)
            {
                txtCodigo.Text  = trdo.Rows[0]["CodArticulo"].ToString();
                txt_Codigo.Text = trdo.Rows[0]["Codigo"].ToString();
                txt_Nombre.Text = trdo.Rows[0]["Nombre"].ToString();
                // txt_CodigoBarra.Text = trdo.Rows[0]["CodigoBarra"].ToString();
                txt_Stock.Text   = trdo.Rows[0]["Stock"].ToString();
                txtPrecio.Text   = trdo.Rows[0]["PrecioEfectivo"].ToString();
                txtCantidad.Text = "1";
                //  if (txtPrecio.Text != "")
                //      txtPrecio.Text = txtPrecio.Text.Replace(",", ".");
                if (Operacion == 1)
                {
                    txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                }
                if (Operacion == 2)
                {
                    txtPrecio.Text = trdo.Rows[0]["PrecioTarjeta"].ToString();
                    Double Precio = Convert.ToDouble(trdo.Rows[0]["PrecioTarjeta"].ToString());
                    Precio            = Precio - 0.10 * Precio;
                    txtDescuento.Text = Precio.ToString();
                }

                if (Operacion == 3)
                {
                    txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                }
                if (txtPrecio.Text != "")
                {
                    Double Precio = Convert.ToDouble(txtPrecio.Text);
                    Precio         = Math.Round(Precio, 0);
                    txtPrecio.Text = Precio.ToString();
                }

                if (txtDescuento.Text != "")
                {
                    Double Precio = Convert.ToDouble(txtDescuento.Text);
                    Precio            = Math.Round(Precio, 0);
                    txtDescuento.Text = Precio.ToString();
                }
                txtCantidad.Focus();
            }
        }
Example #8
0
        private void txt_Codigo_TextChanged(object sender, EventArgs e)
        {
            int Operacion = 0;

            if (txt_Codigo.Text.Length < 3)
            {
                return;
            }
            Operacion = Convert.ToInt32(CmbTipoOperacion.SelectedValue);
            string    Codigo = txt_Codigo.Text;
            cArticulo art    = new cArticulo();
            DataTable trdo   = art.GetArticulo("", "", Codigo);

            if (trdo.Rows.Count > 0)
            {
                txtCodigo.Text       = trdo.Rows[0]["CodArticulo"].ToString();
                txt_Nombre.Text      = trdo.Rows[0]["Nombre"].ToString();
                txt_CodigoBarra.Text = trdo.Rows[0]["CodigoBarra"].ToString();
                // txt_Codigo.Text = trdo.Rows[0]["Codigo"].ToString();
                txt_Stock.Text = trdo.Rows[0]["Stock"].ToString();
                if (Operacion == 1)
                {
                    txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                }
                if (Operacion == 2)
                {
                    txtPrecio.Text = trdo.Rows[0]["PrecioTarjeta"].ToString();
                }
                if (Operacion == 3)
                {
                    txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                }
            }
            if (txtPrecio.Text != "")
            {
                Double Precio = Convert.ToDouble(txtPrecio.Text);
                Precio         = Math.Round(Precio, 0);
                txtPrecio.Text = Precio.ToString();
            }

            if (txtDescuento.Text != "")
            {
                Double Precio = Convert.ToDouble(txtDescuento.Text);
                Precio            = Math.Round(Precio, 0);
                txtDescuento.Text = Precio.ToString();
            }
        }
        private void txt_Codigo_TextChanged(object sender, EventArgs e)
        {
            if (txt_Codigo.Text.Length < 4)
            {
                return;
            }
            string    Codigo = txt_Codigo.Text;
            cArticulo art    = new cArticulo();
            DataTable trdo   = art.GetArticulo("", "", Codigo);

            if (trdo.Rows.Count > 0)
            {
                if (trdo.Rows[0]["CodArticulo"].ToString() != "")
                {
                    txtCodigo.Text          = trdo.Rows[0]["CodArticulo"].ToString();
                    txt_Nombre.Text         = trdo.Rows[0]["Nombre"].ToString();
                    txt_CodigoBarra.Text    = trdo.Rows[0]["CodigoBarra"].ToString();
                    txt_Codigo.Text         = trdo.Rows[0]["Codigo"].ToString();
                    txt_Stock.Text          = trdo.Rows[0]["Stock"].ToString();
                    txt_Costo.Text          = trdo.Rows[0]["Costo"].ToString();
                    txt_PrecioEfectivo.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                    txt_PrecioTarjeta.Text  = trdo.Rows[0]["PrecioTarjeta"].ToString();
                }
            }
            else
            {/*
              * txt_Nombre.Text = "";
              * txt_CodigoBarra.Text = "";
              * txt_Stock.Text = "";
              * txtCodigo.Text = "";
              * txt_Costo.Text = "";
              * txt_PrecioEfectivo.Text = "";
              * txt_PrecioTarjeta.Text = "";*/
            }
            if (txt_PrecioEfectivo.Text != "")
            {
                Double Efectivo = Convert.ToDouble(txt_PrecioEfectivo.Text.Replace(".", ","));
                txt_PrecioEfectivo.Text = Math.Round(Efectivo, 0).ToString();
            }

            if (txt_PrecioTarjeta.Text != "")
            {
                Double Efectivo = Convert.ToDouble(txt_PrecioTarjeta.Text.Replace(".", ","));
                txt_PrecioTarjeta.Text = Math.Round(Efectivo, 0).ToString();
            }
        }
Example #10
0
        private void txt_Codigo_TextChanged(object sender, EventArgs e)
        {
            if (txt_Codigo.Text.Length < 3)
            {
                txt_Nombre.Text      = "";
                txt_CodigoBarra.Text = "";
                // txt_Codigo.Text = "";
                txt_Stock.Text = "";
                return;
            }
            string    Codigo = txt_Codigo.Text;
            cArticulo art    = new cArticulo();
            DataTable trdo   = art.GetArticulo("", "", Codigo);

            if (trdo.Rows.Count > 0)
            {
                if (trdo.Rows[0]["CodArticulo"].ToString() != "")
                {
                    txtCodigo.Text       = trdo.Rows[0]["CodArticulo"].ToString();
                    txt_Nombre.Text      = trdo.Rows[0]["Nombre"].ToString();
                    txt_CodigoBarra.Text = trdo.Rows[0]["CodigoBarra"].ToString();
                    // txt_Codigo.Text = trdo.Rows[0]["Codigo"].ToString();
                    txt_Stock.Text = trdo.Rows[0]["Stock"].ToString();
                }
                else
                {
                    txt_Nombre.Text      = "";
                    txt_CodigoBarra.Text = "";
                    txt_Stock.Text       = "";
                }
            }
            else
            {
                txt_Nombre.Text      = "";
                txt_CodigoBarra.Text = "";
                txt_Stock.Text       = "";
            }
        }
        public void GrabarDetalleCompra(SqlConnection con, SqlTransaction Transaccion, Int32 CodCompra)
        {
            Int32          CodArticulo = 0;
            int            Cantidad    = 0;
            Double         Costo       = 0;
            Double         Descueneto  = 0;
            Double         Subtotal    = 0;
            cArticulo      objArt      = new cArticulo();
            cDetalleCompra detalle     = new cDetalleCompra();
            cArticulo      art         = new cArticulo();

            //string Col = "CodArticulo;Nombre;Cantidad;Precio;Descuento;Subtotal";
            for (int i = 0; i < tbCompra.Rows.Count; i++)
            {
                CodArticulo = Convert.ToInt32(tbCompra.Rows[i]["CodArticulo"].ToString());
                Cantidad    = Convert.ToInt32(tbCompra.Rows[i]["Cantidad"].ToString());
                art.ActualizarStock(con, Transaccion, CodArticulo, Cantidad);
                Costo      = fun.ToDouble(tbCompra.Rows[i]["Precio"].ToString());
                Descueneto = fun.ToDouble(tbCompra.Rows[i]["Descuento"].ToString());
                Subtotal   = fun.ToDouble(tbCompra.Rows[i]["Subtotal"].ToString());
                detalle.Insertar(con, Transaccion, CodCompra, CodArticulo, Cantidad, Costo, Descueneto, Subtotal);
            }
        }
        private void txt_CodigoBarra_TextChanged(object sender, EventArgs e)
        {
            int b         = 0;
            int Operacion = 0;

            if (CmbTipoOperacion.SelectedIndex > 0)
            {
                Operacion = Convert.ToInt32(CmbTipoOperacion.SelectedValue);
            }
            if (txt_CodigoBarra.Text.Length < 5)
            {
                return;
            }
            string    Codigo = txt_CodigoBarra.Text;
            cArticulo art    = new cArticulo();
            cJuguete  jug    = new cJuguete();

            if (radioJugueteria.Checked == true)
            {
                DataTable trdo = jug.GetArticulo("", Codigo, "");
                if (trdo.Rows.Count > 0)
                {
                    b = 1;
                    txtCodigo.Text           = trdo.Rows[0]["CodArticulo"].ToString();
                    txt_Nombre.SelectedValue = trdo.Rows[0]["CodArticulo"].ToString();
                    txt_CodigoBarra.Text     = trdo.Rows[0]["CodigoBarra"].ToString();
                    txt_Nombre.Text          = trdo.Rows[0]["Nombre"].ToString();
                    txt_Stock.Text           = trdo.Rows[0]["Stock"].ToString();


                    if (Operacion == 1)
                    {
                        txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                    }
                    if (Operacion == 2)
                    {
                        txtPrecio.Text = trdo.Rows[0]["PrecioTarjeta"].ToString();
                        Double Precio = Convert.ToDouble(trdo.Rows[0]["PrecioTarjeta"].ToString());
                        Precio            = Precio - 0.10 * Precio;
                        txtDescuento.Text = Precio.ToString();
                    }

                    if (Operacion == 3)
                    {
                        txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                    }

                    if (txtPrecio.Text != "")
                    {
                        Double Precio = Convert.ToDouble(txtPrecio.Text);
                        Precio         = Math.Round(Precio, 0);
                        txtPrecio.Text = Precio.ToString();
                    }

                    if (txtDescuento.Text != "")
                    {
                        Double Precio = Convert.ToDouble(txtDescuento.Text);
                        Precio            = Math.Round(Precio, 0);
                        txtDescuento.Text = Precio.ToString();
                    }

                    if (b == 1)
                    {
                        PuedeAgregar = false;
                        txtCantidad.Focus();
                    }
                }
            }

            if (radioLibreria.Checked == true)
            {
                DataTable trdo = art.GetArticulo("", Codigo, "");
                if (trdo.Rows.Count > 0)
                {
                    b = 1;
                    txtCodigo.Text           = trdo.Rows[0]["CodArticulo"].ToString();
                    txt_Nombre.SelectedValue = trdo.Rows[0]["CodArticulo"].ToString();
                    txt_CodigoBarra.Text     = trdo.Rows[0]["CodigoBarra"].ToString();
                    txt_Nombre.Text          = trdo.Rows[0]["Nombre"].ToString();
                    txt_Stock.Text           = trdo.Rows[0]["Stock"].ToString();


                    if (Operacion == 1)
                    {
                        txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                    }
                    if (Operacion == 2)
                    {
                        txtPrecio.Text = trdo.Rows[0]["PrecioTarjeta"].ToString();
                        Double Precio = Convert.ToDouble(trdo.Rows[0]["PrecioTarjeta"].ToString());
                        Precio            = Precio - 0.10 * Precio;
                        txtDescuento.Text = Precio.ToString();
                    }

                    if (Operacion == 3)
                    {
                        txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                    }

                    if (txtPrecio.Text != "")
                    {
                        Double Precio = Convert.ToDouble(txtPrecio.Text);
                        Precio         = Math.Round(Precio, 0);
                        txtPrecio.Text = Precio.ToString();
                    }

                    if (txtDescuento.Text != "")
                    {
                        Double Precio = Convert.ToDouble(txtDescuento.Text);
                        Precio            = Math.Round(Precio, 0);
                        txtDescuento.Text = Precio.ToString();
                    }

                    if (b == 1)
                    {
                        PuedeAgregar = false;
                        txtCantidad.Focus();
                    }
                }
            }
        }
        private void txt_CodigoBarra_TextChanged(object sender, EventArgs e)
        {
            cFunciones fun = new cFunciones();

            if (txt_CodigoBarra.Text.Length > 5)
            {
                string    CodigoBarra = txt_CodigoBarra.Text;
                cArticulo art         = new cArticulo();
                DataTable trdo        = art.GetArticuloxCodigoBarra(CodigoBarra);
                if (trdo.Rows.Count > 0)
                {
                    if (trdo.Rows[0]["CodArticulo"].ToString() != "")
                    {
                        txtCodigo.Text          = trdo.Rows[0]["CodArticulo"].ToString();
                        txt_Nombre.Text         = trdo.Rows[0]["Nombre"].ToString();
                        txt_CodigoBarra.Text    = trdo.Rows[0]["CodigoBarra"].ToString();
                        txt_Codigo.Text         = trdo.Rows[0]["Codigo"].ToString();
                        txt_Stock.Text          = trdo.Rows[0]["Stock"].ToString();
                        txt_Costo.Text          = trdo.Rows[0]["Costo"].ToString();
                        txt_PrecioEfectivo.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                        txt_PrecioTarjeta.Text  = trdo.Rows[0]["PrecioTarjeta"].ToString();
                        txt_PorEfe.Text         = trdo.Rows[0]["PorEfe"].ToString();
                        txt_PorTar.Text         = trdo.Rows[0]["PorTar"].ToString();
                        if (txt_Costo.Text != "")
                        {
                            txt_Costo.Text = fun.SepararDecimales(txt_Costo.Text);
                        }

                        if (txt_PorTar.Text != "")
                        {
                            txt_PorTar.Text = fun.SepararDecimales(txt_PorTar.Text);
                        }

                        if (txt_PorEfe.Text != "")
                        {
                            txt_PorEfe.Text = fun.SepararDecimales(txt_PorEfe.Text);
                        }
                    }
                }
                else
                {/*
                  * txtCodigo.Text = "";
                  * txt_Nombre.Text = "";
                  * txt_Stock.Text = "";
                  * txt_Costo.Text = "";
                  * txt_PrecioEfectivo.Text = "";
                  * txt_PrecioTarjeta.Text = "";
                  * txt_Codigo.Text = "";*/
                }
            }
            if (txt_PrecioEfectivo.Text != "")
            {
                Double Efectivo = Convert.ToDouble(txt_PrecioEfectivo.Text.Replace(".", ","));
                txt_PrecioEfectivo.Text = Math.Round(Efectivo, 0).ToString();
            }

            if (txt_PrecioTarjeta.Text != "")
            {
                Double Efectivo = Convert.ToDouble(txt_PrecioTarjeta.Text.Replace(".", ","));
                txt_PrecioTarjeta.Text = Math.Round(Efectivo, 0).ToString();
            }
        }
Example #14
0
        public void cArticuloMenuItem_Click(object sender, RoutedEventArgs e)
        {
            cArticulo ca = new cArticulo();

            ca.Show();
        }
Example #15
0
        private void ConsultarButton_Click(object sender, RoutedEventArgs e)
        {
            cArticulo ca = new cArticulo();

            ca.Show();
        }
Example #16
0
        private void txt_CodigoBarra_TextChanged(object sender, EventArgs e)
        {
            int b         = 0;
            int Operacion = 0;

            if (CmbTipoOperacion.SelectedIndex > 0)
            {
                Operacion = Convert.ToInt32(CmbTipoOperacion.SelectedValue);
            }
            if (txt_CodigoBarra.Text.Length < 5)
            {
                return;
            }
            string    Codigo = txt_CodigoBarra.Text;
            cArticulo art    = new cArticulo();
            DataTable trdo   = art.GetArticulo("", Codigo, "");

            if (trdo.Rows.Count > 0)
            {
                b = 1;
                txtCodigo.Text           = trdo.Rows[0]["CodArticulo"].ToString();
                txt_Nombre.SelectedValue = trdo.Rows[0]["CodArticulo"].ToString();
                txt_CodigoBarra.Text     = trdo.Rows[0]["CodigoBarra"].ToString();
                txt_Nombre.Text          = trdo.Rows[0]["Nombre"].ToString();
                txt_Stock.Text           = trdo.Rows[0]["Stock"].ToString();
                PuedeAgregar             = false;

                if (Operacion == 1)
                {
                    txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                }
                if (Operacion == 2)
                {
                    txtPrecio.Text = trdo.Rows[0]["PrecioTarjeta"].ToString();
                    Double Precio = Convert.ToDouble(trdo.Rows[0]["PrecioTarjeta"].ToString());
                    Precio            = Precio - 0.10 * Precio;
                    txtDescuento.Text = Precio.ToString();
                }

                if (Operacion == 3)
                {
                    txtPrecio.Text = trdo.Rows[0]["PrecioEfectivo"].ToString();
                }

                if (txtPrecio.Text != "")
                {
                    Double Precio = Convert.ToDouble(txtPrecio.Text);
                    Precio         = Math.Round(Precio, 0);
                    txtPrecio.Text = Precio.ToString();
                }

                if (txtDescuento.Text != "")
                {
                    Double Precio = Convert.ToDouble(txtDescuento.Text);
                    Precio            = Math.Round(Precio, 0);
                    txtDescuento.Text = Precio.ToString();
                }

                if (b == 1)
                {
                    PuedeAgregar = false;
                    txtCantidad.Focus();
                    //txtCantidad.Text = "1";

                    /*
                     * Principal.NombreTablaSecundario = "Cantidad";
                     * FrmCantidad form = new FrmCantidad();
                     * form.FormClosing += new FormClosingEventHandler(form_FormClosing);
                     * form.ShowDialog();
                     */
                }
            }
        }
        private void consultararticulo_Click(object sender, RoutedEventArgs e)
        {
            cArticulo consulta = new cArticulo();

            consulta.ShowDialog();
        }
        private void btnAplicar_Click(object sender, EventArgs e)
        {
            if (txtPorcentajeCosto.Text == "")
            {
                Mensaje("Debe ingresar un porcentaje de costo");
                return;
            }
            if (txtPorEfe.Text.Trim() == "")
            {
                Mensaje("Debe ingresar un porcentaje");
                return;
            }
            if (Grilla.Rows.Count < 2)
            {
                Mensaje("Debe buscar articulos");
                return;
            }
            int    Can = Grilla.Rows.Count - 1;
            string msj = "Confirma aplicar el  " + txtPorEfe.Text;

            msj = msj + " a los siguientes " + Can.ToString() + " Articulos ";
            var result = MessageBox.Show(msj, "InformaciĆ³n",
                                         MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question);

            // If the no button was pressed ...
            if (result == DialogResult.No)
            {
                return;
            }
            int IncluyeTodos = 0;

            if (chkIncluyeTodos.Checked == true)
            {
                IncluyeTodos = 1;
            }

            Double PorCosto       = 0;
            Double PorEfe         = 0;
            Double PorTar         = 0;
            Double Costo          = 0;
            Double PrecioEfectivo = 0;
            Double PrecioTarjeta  = 0;

            PorEfe   = Convert.ToDouble(txtPorEfe.Text);
            PorTar   = Convert.ToDouble(txtPorTar.Text);
            PorCosto = Convert.ToDouble(txtPorcentajeCosto.Text);
            Double    PorEfeGrilla = 0;
            Double    PorTarGrilla = 0;
            Int32     CodArticulo  = 0;
            cArticulo art          = new cArticulo();

            for (int i = 0; i < Grilla.Rows.Count - 1; i++)
            {
                CodArticulo = Convert.ToInt32(Grilla.Rows[i].Cells[0].Value.ToString());
                Costo       = Convert.ToDouble(Grilla.Rows[i].Cells[5].Value.ToString());
                if (Grilla.Rows[i].Cells[8].Value.ToString() != "")
                {
                    PorEfeGrilla = Convert.ToDouble(Grilla.Rows[i].Cells[8].Value.ToString());
                }
                else
                {
                    PorEfeGrilla = 0;
                }

                if (Grilla.Rows[i].Cells[9].Value.ToString() != "")
                {
                    PorTarGrilla = Convert.ToDouble(Grilla.Rows[i].Cells[9].Value.ToString());
                }
                else
                {
                    PorTarGrilla = 0;
                }
                Costo          = Costo + Costo * PorCosto / 100;
                PrecioEfectivo = Costo + Costo * PorEfe / 100;
                PrecioTarjeta  = Costo + Costo * PorTar / 100;
                if (IncluyeTodos == 0)
                {
                    if (PorEfeGrilla > 0)
                    {
                        PrecioEfectivo = Costo + Costo * PorEfeGrilla / 100;
                    }
                }
                if (IncluyeTodos == 0)
                {
                    if (PorTarGrilla > 0)
                    {
                        PrecioTarjeta = Costo + Costo * PorTarGrilla / 100;
                    }
                }
                art.ActualizarMontosArticulos(CodArticulo, Costo, PrecioEfectivo, PrecioTarjeta);
            }
            Mensaje("Datos grabados correctamente");
            Buscar();
        }