コード例 #1
0
        public DataTable cargarVentaDetalle(int idVenta)
        {
            DataTable dt = new DataTable();

            VentasDetalle_BLL ventaDetalleBLL = new VentasDetalle_BLL();

            dt = ventaDetalleBLL.cargarVentaDetalle(idVenta);

            lblNombreCliente.Text  = dt.Rows[0]["nombreCliente"].ToString();
            lblCodigoCliente.Text  = dt.Rows[0]["codigoCliente"].ToString();
            lblIDVenta.Text        = dt.Rows[0]["idVenta"].ToString();
            lblFecha.Text          = dt.Rows[0]["fechaVenta"].ToString().Substring(0, 10);
            lblNombreProducto.Text = dt.Rows[0]["nombreProducto"].ToString();
            lblTotalVenta.Text     = dt.Rows[0]["totalVenta"].ToString();

            return(dt);
        }
コード例 #2
0
        public void agregarVenta(int idCliente)
        {
            DataTable         dtdt            = new DataTable();
            Productos_BLL     productoBLL     = new Productos_BLL();
            Ventas_BLL        ventaBLL        = new Ventas_BLL();
            VentasDetalle_BLL ventaDetalleBLL = new VentasDetalle_BLL();
            Existencias_BLL   existenciasBLL  = new Existencias_BLL();

            DateTime fechaVenta       = DateTime.Now;
            string   codigoProducto   = ddlCodigo.SelectedValue;
            int      cantidadProducto = int.Parse(txtCantidad.Text);

            dtdt = productoBLL.cargarProductos();
            double aux        = double.Parse(dtdt.Rows[0]["precioUnitario"].ToString());
            double subtotal   = (aux) * (int.Parse(txtCantidad.Text));
            double IVA        = ((aux) * (int.Parse(txtCantidad.Text))) * 0.16;
            double totalVenta = subtotal + IVA;

            lblSubtotal.Text = Convert.ToString(subtotal);
            lblIVA.Text      = Convert.ToString(IVA);
            lblTotal.Text    = Convert.ToString(totalVenta);



            int idProducto = int.Parse(dtdt.Rows[0]["idProducto"].ToString());

            idProducto = ddlCodigo.SelectedIndex;

            ventaBLL.agregarVenta(idCliente, fechaVenta, totalVenta);
            dtdt = ventaBLL.cargarVenta(idCliente);

            int idVenta = int.Parse(dtdt.Rows[0]["idVenta"].ToString());

            ventaDetalleBLL.agregarVentaDetalle(idVenta, idProducto, cantidadProducto);

            ClientScript.RegisterStartupScript(this.Page.GetType(), "alerta", "alert('Venta agregada exitosamente')", true);

            existenciasBLL.restarExistencia(cantidadProducto, idProducto);

            //DataTable dt = new DataTable();
            //dt = (DataTable)ViewState["dtVentaCliente"];
            //dt.Rows.Add(fechaVenta, codigoProducto, cantidadProducto, totalVenta);
            //grdVentaCliente.DataSource = dt;
            //grdVentaCliente.DataBind();
        }