예제 #1
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);
                    }
                }
            }
        }
예제 #2
0
        private void txt_CodigoBarra_TextChanged(object sender, EventArgs e)
        {
            cFunciones fun = new cFunciones();

            if (txt_CodigoBarra.Text.Length > 5)
            {
                string    CodigoBarra = txt_CodigoBarra.Text;
                cJuguete  art         = new Clases.cJuguete();
                DataTable trdo        = art.GetJuguetexCodBarra(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_PorEfe.Text != "")
                        {
                            txt_PorEfe.Text = fun.SepararDecimales(txt_PorEfe.Text);
                        }

                        if (txt_PorTar.Text != "")
                        {
                            txt_PorTar.Text = fun.SepararDecimales(txt_PorTar.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();
            }
        }
예제 #3
0
        private void BuscarJuguetexCodigoBarra()
        {
            int b = 0;

            if (txt_CodigoBarra.Text.Length > 7)
            {
                string    CodigoBarra = txt_CodigoBarra.Text;
                cJuguete  art         = new Clases.cJuguete();
                DataTable trdo        = art.GetJuguetexCodBarra(CodigoBarra);
                if (trdo.Rows.Count > 0)
                {
                    if (trdo.Rows[0]["CodArticulo"].ToString() != "")
                    {
                        b = 1;
                        txtCodigo.Text        = trdo.Rows[0]["CodArticulo"].ToString();
                        txtNombreJuguete.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();
                        txtPrecio.Text        = trdo.Rows[0]["Costo"].ToString();
                        txtPorEfe.Text        = trdo.Rows[0]["PorEfe"].ToString();
                        txtPorTar.Text        = trdo.Rows[0]["PorTar"].ToString();
                        if (txtPrecio.Text != "")
                        {
                            txtPrecio.Text = fun.SepararDecimales(txtPrecio.Text);
                        }
                        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();
                }
            }
        }
        private void Grabar()
        {
            int            TipoOp = Convert.ToInt32(CmbTipoOperacion.SelectedValue);
            SqlTransaction Transaccion;
            SqlConnection  con = new SqlConnection(cConexion.GetConexion());

            con.Open();
            Transaccion = con.BeginTransaction();
            DateTime Fecha           = Convert.ToDateTime(txtFecha.Text);
            Int32?   CodCliente      = null;
            Double   ImporteEfectivo = 0;
            Double   ImporteTarjeta  = 0;
            cCliente cli             = new cCliente();
            Int32    CodVenta        = 0;
            Int32?   CodTarjeta      = null;

            if (TipoOp == 2)
            {
                ImporteTarjeta = Convert.ToDouble(txtTotal.Text);
                CodTarjeta     = Convert.ToInt32(CmbTarjeta.SelectedValue);
            }

            if (TipoOp == 1)
            {
                ImporteEfectivo = Convert.ToDouble(txtTotal.Text);
            }
            if (TipoOp == 3)
            {
                ImporteEfectivo = Convert.ToDouble(txtTotal.Text);
            }

            Int32  CodArticulo       = 0;
            Double Precio            = 0;
            Int32  Cantidad          = 0;
            Double Subtotal          = 0;
            Double Descuento         = 0;
            Double PorDescuento      = 0;
            Double TotalConDescuento = 0;
            int    Libreria          = 0;

            if (txtPordescuento.Text != "")
            {
                PorDescuento = Convert.ToDouble(txtPordescuento.Text);
            }

            if (txtTotalDescuento.Text != "")
            {
                Descuento = Convert.ToDouble(txtTotalDescuento.Text);
            }

            if (txtTotalConDescuento.Text != "")
            {
                TotalConDescuento = Convert.ToDouble(txtTotalConDescuento.Text);
            }

            cArticulo objArt = new Clases.cArticulo();
            string    Cupon  = txtCupon.Text;
            // string Col = "CodArticulo;Nombre;Precio;Cantidad;Subtotal";
            cVenta   venta = new cVenta();
            cJuguete jug   = new Clases.cJuguete();

            try
            {
                CodVenta = venta.InsertarVenta(con, Transaccion, ImporteEfectivo,
                                               Fecha, ImporteEfectivo, ImporteTarjeta
                                               , CodTarjeta, CodCliente, Cupon, Descuento, PorDescuento, TotalConDescuento);
                for (int i = 0; i < tbVenta.Rows.Count; i++)
                {
                    CodArticulo = Convert.ToInt32(tbVenta.Rows[i]["CodArticulo"].ToString());
                    Precio      = Convert.ToDouble(tbVenta.Rows[i]["Precio"].ToString());
                    Cantidad    = Convert.ToInt32(tbVenta.Rows[i]["Cantidad"].ToString());
                    Subtotal    = Convert.ToDouble(tbVenta.Rows[i]["Subtotal"].ToString());
                    Libreria    = Convert.ToInt32(tbVenta.Rows[i]["Libreria"].ToString());
                    if (Libreria == 1)
                    {
                        venta.InsertarDetalleVenta(con, Transaccion, CodVenta, Cantidad, Precio, CodArticulo, Subtotal);
                        objArt.ActualizarStockResta(con, Transaccion, CodArticulo, Cantidad);
                    }
                    else
                    {
                        venta.InsertarDetalleVentaJuguete(con, Transaccion, CodVenta, Cantidad, Precio, CodArticulo, Subtotal);
                        jug.ActualizarStockResta(con, Transaccion, CodArticulo, Cantidad);
                    }
                }
                Transaccion.Commit();
                con.Close();
                Mensaje("Datos grabados correctamente");
                Limpiar();
            }
            catch (Exception exa)
            {
                Transaccion.Rollback();
                con.Close();
                Mensaje("Hubo un error en el proceso de grabacion");
                Mensaje(exa.Message);
            }
        }