Esempio n. 1
0
        public static VentaEntidadMostrar DevolverVentaCabecera(int id_venta)
        {
            VentaEntidadMostrar ventaCabeceraEntidad = new VentaEntidadMostrar();

            using (SqlConnection cn = new SqlConnection(ConfiguracionApp.Default.ConexionVentasSql))
            {
                cn.Open();
                string     sql = @"SELECT [Ced_Cli]
                                  ,[Nom_Cli]
                                  ,[Ape_Cli]
                                  ,[Dir_Cli]
                                  ,[Tel_Cli]
                                  ,[Ced_Emp]
                                  ,[Nom_Emp]
                                  ,[Ape_Emp]
                                  ,[Id_Ven]
                                  ,[Fec_Ven]
                                  ,[Por_Gan_Ven]
                                  ,[Total]
                              FROM [dbo].[View_Cabecera]
                              WHERE [Id_Ven] = @id_Venta";
                SqlCommand cmd = new SqlCommand(sql, cn);
                cmd.Parameters.AddWithValue("@id_Venta", id_venta);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ventaCabeceraEntidad = TraducirCabeceraEntidad(reader);
                }
            }
            return(ventaCabeceraEntidad);
        }
Esempio n. 2
0
        private static VentaEntidadMostrar TraducirCabeceraEntidad(IDataReader reader)
        {
            VentaEntidadMostrar ms = new VentaEntidadMostrar();

            ms.Id         = Convert.ToInt32(reader["Id_Ven"]);
            ms.FechaVenta = Convert.ToDateTime(reader["Fec_Ven"]);
            ms.Nombre     = Convert.ToString(reader["Nom_Cli"]);
            ms.Apellido   = Convert.ToString(reader["Ape_Cli"]);
            ms.Cedula     = Convert.ToString(reader["Ced_Cli"]);
            ms.Direccion  = Convert.ToString(reader["Dir_Cli"]);
            ms.Telefono   = Convert.ToString(reader["Tel_Cli"]);
            ms.Total      = Convert.ToDouble(reader["Total"]);
            ms.Ganancia   = Convert.ToDouble(reader["Por_Gan_Ven"]);
            return(ms);
        }
        private void printDocumentVenta_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            int x = 5, y = 5;

            currentVentaCabecera = VentaNegocio.DevolverVentaCabecera(id_venta);
            currentVentaDetalle  = VentaNegocio.DevolverVentaDetalle(id_venta);


            Pen blackPen = new Pen(Color.Black, 3);


            Font fuenteCabecera  = new Font("Arial", 14, FontStyle.Bold);
            Font fuenteCabecera2 = new Font("Arial", 10, FontStyle.Bold);
            Font fuenteCabecera3 = new Font("Times New Roman", 8, FontStyle.Bold);
            Font fuenteDetalle   = new Font("Times New Roman", 8, FontStyle.Regular);

            //MessageBox.Show(e.PageSettings.PaperSize.ToString()); //1100 875
            e.Graphics.DrawString("COMPROBANTE DE VENTA", fuenteCabecera, Brushes.DarkBlue, x + 50, y += 10);
            Image imagen = Properties.Resources.logo1;

            e.Graphics.DrawImage(imagen, x + 325, y, 50, 30);
            e.Graphics.DrawString("ACRIVIDRIO'S", fuenteCabecera2, Brushes.Black, x + 103, y         += 20);
            e.Graphics.DrawString("Ruc: 001 340 230 1001", fuenteCabecera2, Brushes.Black, x + 95, y += 20);

            Barcode codigo = new Barcode();

            codigo.IncludeLabel = true;
            Image miCodigo = codigo.Encode(BarcodeLib.TYPE.CODE128, currentVentaCabecera.Cedula + "-" + currentVentaCabecera.Id, Color.Black, Color.White, 400, 100);

            e.Graphics.DrawImage(miCodigo, x, y += 30, miCodigo.Width, miCodigo.Height);
            //Datos cabecera
            e.Graphics.DrawString("Cedula: " + currentVentaCabecera.Cedula, fuenteDetalle, Brushes.Black, x, y += 100);
            e.Graphics.DrawString("Cliente: " + currentVentaCabecera.Apellido + " " + currentVentaCabecera.Nombre, fuenteDetalle, Brushes.Black, x, y += 20);
            e.Graphics.DrawString("Dirección: " + currentVentaCabecera.Direccion, fuenteDetalle, Brushes.Black, x, y    += 20);
            e.Graphics.DrawString("Teléfono: " + currentVentaCabecera.Telefono, fuenteDetalle, Brushes.Black, x, y      += 20);
            e.Graphics.DrawString("Fecha Vemta: " + currentVentaCabecera.FechaVenta, fuenteDetalle, Brushes.Black, x, y += 20);
            //    //Datos detalle
            e.Graphics.DrawString("Producto", fuenteCabecera3, Brushes.Black, x, y += 40);
            e.Graphics.DrawString("Precio Unitario", fuenteCabecera3, Brushes.Black, x + 100, y);
            e.Graphics.DrawString("Cantidad", fuenteCabecera3, Brushes.Black, x + 200, y);
            e.Graphics.DrawString("Subtotal", fuenteCabecera3, Brushes.Black, x + 300, y);


            foreach (var item in currentVentaDetalle)
            {
                e.Graphics.DrawString(item.Nombre, fuenteDetalle, Brushes.Black, x, y += 20);
                e.Graphics.DrawString(item.Precio.ToString(), fuenteDetalle, Brushes.Black, x + 100, y);
                e.Graphics.DrawString(item.Cantidad.ToString(), fuenteDetalle, Brushes.Black, x + 200, y);
                e.Graphics.DrawString((item.Precio_Total).ToString(), fuenteDetalle, Brushes.Black, x + 300, y);
            }
            e.Graphics.DrawString("Subtotal".ToString(), fuenteDetalle, Brushes.Black, x + 200, y += 20);
            double subtotal = (currentVentaCabecera.Total - currentVentaCabecera.Ganancia) / 1.12;

            e.Graphics.DrawString(subtotal.ToString(), fuenteDetalle, Brushes.Black, x + 300, y);
            e.Graphics.DrawString("Iva".ToString(), fuenteDetalle, Brushes.Black, x + 200, y += 20);
            e.Graphics.DrawString((currentVentaCabecera.Total - currentVentaCabecera.Ganancia - subtotal).ToString(), fuenteDetalle, Brushes.Black, x + 300, y);
            e.Graphics.DrawString("Mano de obra".ToString(), fuenteDetalle, Brushes.Black, x + 200, y += 20);
            e.Graphics.DrawString(currentVentaCabecera.Ganancia.ToString(), fuenteDetalle, Brushes.Black, x + 300, y);

            e.Graphics.DrawString("Total".ToString(), fuenteDetalle, Brushes.Black, x + 200, y += 20);
            e.Graphics.DrawString(currentVentaCabecera.Total.ToString(), fuenteDetalle, Brushes.Black, x + 300, y);
            Rectangle rectangle = new Rectangle(0, 0, 400, y + 40);

            e.Graphics.DrawRectangle(blackPen, rectangle);
        }