コード例 #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            DetalleFacturaVenta dfv = (DetalleFacturaVenta)dtgVentaDetalle.CurrentRow.DataBoundItem;

            facturaventa.detalle_venta.Remove(dfv);
            ActualizarDataGrid();
        }
コード例 #2
0
        private void guardar()
        {
            FacturaVenta fv = new FacturaVenta();

            fv.idEmpleado = idEmpleado;
            fv.fecha      = DateTime.Now;
            fv.iva        = 12;
            fv.descuento  = 0;

            bd.FacturaVenta.Add(fv);
            bd.SaveChanges();



            int contador = 0;

            foreach (var item in dtgFactura.Rows)
            {
                if (dtgFactura.Rows[contador].Cells["Identificador"].Value.ToString().Equals("1"))
                {
                    try
                    {
                        DetalleFacturaVenta df = new DetalleFacturaVenta();
                        df.idFacturaVenta = idFactura;
                        df.cantidad       = Convert.ToDouble(dtgFactura.Rows[contador].Cells["Cantidad"].Value.ToString());
                        df.idProducto     = 1;
                        df.precio         = 0;

                        bd.DetalleFacturaVenta.Add(df);
                        bd.SaveChanges();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("");
                    }
                }
                else
                {
                    DetalleFacturaVenta df = new DetalleFacturaVenta();
                    df.idFacturaVenta = idFactura;
                    df.cantidad       = Convert.ToDouble(dtgFactura.Rows[contador].Cells[1].Value.ToString());
                    df.idPlato        = 1;
                    df.precio         = 0;
                    bd.DetalleFacturaVenta.Add(df);
                    bd.SaveChanges();
                }


                contador++;
            }
        }
コード例 #3
0
 public int GuardarDetalleFacturaVenta(DetalleFacturaVenta detalle)
 {
     using (var command = _connection.CreateCommand())
     {
         command.CommandText = @"PROYECTO_INSERTAR.pr_insertar_detalle_venta";
         command.CommandType = System.Data.CommandType.StoredProcedure;
         command.Parameters.Add("codigo_venta", OracleDbType.Int32).Value       = detalle.CodigoVenta;
         command.Parameters.Add("codigo_producto", OracleDbType.Varchar2).Value = detalle.CodigoProducto;
         command.Parameters.Add("cantidad", OracleDbType.Int32).Value           = detalle.CantidadProducto;
         command.Parameters.Add("precio", OracleDbType.Int32).Value             = detalle.Valorunitario;
         command.Parameters.Add("subtotal", OracleDbType.Int32).Value           = detalle.ValorSubTotal;
         var filas = command.ExecuteNonQuery();
         return(filas);
     }
 }
コード例 #4
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                DetalleFacturaVenta detalle = new DetalleFacturaVenta();
                detalle.CodigoVenta      = txtNumFactura.Text;
                detalle.CodigoProducto   = txtCodigoProd.Text;
                detalle.CantidadProducto = int.Parse(txtCantidad.Text);
                detalle.Valorunitario    = int.Parse(lblPrecioVenta.Text);
                detalle.ValorSubTotal    = Double.Parse(lblTotal.Text);
                Producto producto = new Producto();
                producto.CodigoProducto = txtCodigoProd.Text;
                producto.Cantidad       = int.Parse(txtCantidad.Text);

                productos.Add(producto);
                ventas.Add(detalle);
                dtgvFactura.DataSource = null;
            }
            catch { }


            foreach (DataGridViewRow row in dtgvFactura.Rows)
            {
                foreach (var item in ventas)
                {
                    row.Cells["codigoVenta"].Value      = item.CodigoVenta;
                    row.Cells["CodigoProducto"].Value   = item.CodigoProducto;
                    row.Cells["CantidadProducto"].Value = item.CantidadProducto;
                    row.Cells["Valorunitario"].Value    = item.Valorunitario;
                    row.Cells["ValorSubTotal"].Value    = item.ValorSubTotal;
                }
            }
            dtgvFactura.DataSource = ventas;
            int total = 0;

            foreach (DataGridViewRow row in dtgvFactura.Rows)
            {
                total += Convert.ToInt32(row.Cells["ValorSubTotal"].Value);
            }
            lblTotalFactura.Text = (total).ToString();
        }
コード例 #5
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            //DetalleFacturaVenta dv = new DetalleFacturaVenta();
            //dv.Libro = (Libro)cmbLibro.SelectedItem;
            //dv.Cantidad = Convert.ToInt32(txtCantidad.Text);
            //facturaventa.Nro_Factura = txtNroFactura.Text;
            //facturaventa.Nro_Timbrado = Convert.ToInt32(txtNroTimbrado.Text);
            //facturaventa.Ruc = txtCI.Text;
            //facturaventa.Razon_Social = txtNombre.Text;
            //facturaventa.Direccion = txtDireccion.Text;
            //facturaventa.Telefono = txtTelefono.Text;
            //if (rdbContado.Checked)
            //{
            //    facturaventa.Cond_Venta = "Contado";
            //}
            //else
            //{
            //    facturaventa.Cond_Venta = "Credito";
            //}
            //facturaventa.Fecha_Emision = dtpFechaEmision.Value;
            //facturaventa.detalle_venta.Add(dv);
            //FacturaVenta.Agregar(facturaventa);
            //MessageBox.Show("La Venta ha sido guardada con éxito");
            //Limpiar();

            //dtpFechaEmision.Value = System.DateTime.Now;
            //cmbLibro.SelectedItem = null;

            DetalleFacturaVenta dfv = new DetalleFacturaVenta();

            dfv.Cantidad = Convert.ToInt32(txtCantidad.Text);
            dfv.Precio   = Convert.ToInt32(txtPrecio.Text);
            dfv.SubTotal = Convert.ToInt32(txtSubTotal.Text);
            dfv.Libro    = (Libro)cmbLibro.SelectedItem;
            facturaventa.detalle_venta.Add(dfv);

            ActualizarDataGrid();

            LimpiarDetalle();
        }