public VSeniarPresupuesto(int pIdCliente, int pPresupuestoId)
        {
            var cont  = new ControladorFachada();
            var contP = new ControladorPresupuesto();

            iCliente     = cont.BuscarCliente(pIdCliente);
            iPresupuesto = cont.BuscarPresupuesto(pPresupuestoId);
            seniaDto     = contP.PresupuestoTieneSenia(pPresupuestoId);
            InitializeComponent();


            this.nombreClienteLabel.Text     = iCliente.ToString();
            this.cantidadProductosLabel.Text = iPresupuesto.Lineas.Count.ToString();
            this.totalLabel.Text             = iPresupuesto.TotalVenta().ToString();
            if (seniaDto != null)
            {
                this.dateTimePicker1.Value  = seniaDto.ValidoHasta;
                this.fechaDeSeniaLabel.Text = seniaDto.Fecha.ToString();
                this.montoSeniaTextBox.Text = seniaDto.Monto.ToString();
                this.PorcentajeSeña.Text    = ((Convert.ToDouble(montoSeniaTextBox.Text) * 100) / Convert.ToDouble(this.totalLabel.Text)).ToString();
            }
            else
            {
                this.fechaDeSeniaLabel.Text = DateTime.Now.ToString();
            }
            montoSeniaTextBox.TextChanged += new System.EventHandler(this.montoSeniaTextBox_HasChanged);
        }
Esempio n. 2
0
        public static void PDFPresupuesto(Presupuesto pPresupuesto)
        {
            string template_file = prefix + "TemplatePresupuesto.html";


            string doc     = File.ReadAllText(template_file);
            string headers = "<tr>  <th>Nombre</th> <th>Cantidad</th> <th>Precio unitario</th> <th>Subtotal</th> </tr>";
            string lista   = "";

            foreach (var linea in pPresupuesto.Lineas)
            {
                using (var repo = new Repositorio())
                {
                    string NombreProducto      = repo.LineaPresupuestos.Include("Producto").Where(l => l.Id == linea.Id).First().Producto.Nombre;
                    double PrecioVentaProducto = repo.LineaPresupuestos.Include("Producto").Where(l => l.Id == linea.Id).First().Producto.PrecioVenta();
                    lista += $"<tr> <td> {NombreProducto} </td> <th> {linea.Cantidad} </td> <td> {PrecioVentaProducto} </td> <td> {linea.Subtotal} </td></tr>";
                }
            }

            doc = doc.Replace("[]", headers);
            doc = doc.Replace("{}", lista);
            doc = doc.Replace("PesosTotal", pPresupuesto.TotalVenta().ToString());
            File.WriteAllText(temp_file, doc);
            System.Diagnostics.Process.Start(temp_file);
        }