public void Grid_Load(object sender, EventArgs e)
        {
            ProductoCEN producto = new ProductoCEN();
            List<ProductoGV> productoGV = new List<ProductoGV>();
            IList<ProductoEN> lista;
            if (numericStock.Text == "")
            {
                dataGridViewStock.DataSource = productoGV;
            }
            else
            {
                lista = producto.BuscarPorStock(Convert.ToInt32(numericStock.Text));
                foreach (ProductoEN p in lista)
                {
                    productoGV.Add(new ProductoGV()
                    {
                        Id = p.Id,
                        Nombre = p.Nombre,
                        Descripcion = p.Descripcion,
                        Stock = p.Stock,
                    });
                }
                dataGridViewStock.DataSource = productoGV;
            }

            PedidoCEN pedido = new PedidoCEN();
            IList<PedidoEN> lista2;
            List<PedidoFiltrado> pedidoGV = new List<PedidoFiltrado>();

            lista2 =  pedido.ObtenerTodos(0, 0);

            foreach (PedidoEN p in lista2)
            {
                pedidoGV.Add(new PedidoFiltrado()
                {
                    Id = p.Id,
                    Fecha = p.Fecha,
                    Estado = p.Estado,
                });
            }

            dataGridViewPedidos.DataSource = pedidoGV;

            CopiaSeguridadCEN copiasseguridad = new CopiaSeguridadCEN();
            IList<CopiaSeguridadEN> lista3 = copiasseguridad.ObtenerTodas(0, 0);
            dataGridViewCS.DataSource = lista3;
        }
 private void Form_Load(object sender, EventArgs e)
 {
     // EmpresaGB
     labelNombreEmpresa.Text = Constantes._NOMBREEMPRESA;
     labelFechaInforme.Text = DateTime.Now.ToString();
     labelCiudadInforme.Text = Constantes._CIUDADEMPRESA;
     // ProveedorGB
     ProveedorEN p = new ProveedorCEN().ObtenerProveedor(Nif);
     if (p != null)
     {
         nifBox.Text = p.Id;
         nombreBox.Text = p.Nombre;
         emailBox.Text = p.Email;
         direccionBox.Text = p.Direccion;
         localidadBox.Text = p.Localidad;
         provinciaBox.Text = p.Provincia;
         telefonoBox.Text = p.Telefono;
         codigoPostalBox.Text = p.CodigoPostal;
         paisBox.Text = p.Pais;
         descripcionBox.Text = p.Descripcion;
     }
     // Pedidos
     PedidoCEN pedidoCEN = new PedidoCEN();
     ProveedorCEN proveedorCEN = new ProveedorCEN();
     var listaFiltrada = new List<PedidoGV>();
     foreach (var pedido in pedidoCEN.ObtenerTodos(0, 0))
     {
         if (p.Equals(pedido.Proveedor))
         {
             listaFiltrada.Add(new PedidoGV()
             {
                 Id = pedido.Id,
                 Fecha = pedido.Fecha,
                 Estado = pedido.Estado.ToString(),
                 TipoPago = pedido.TipoPago.ToString()
             });
         }
     }
     instalacionesGridView.DataSource = listaFiltrada;
 }
        private void Crear_Click(object sender, EventArgs e)
        {
            PedidoCEN pedidoCEN = new PedidoCEN();
            LineaPedidoCEN lineaPedidoCEN = new LineaPedidoCEN();
            // Radiobox seleccionado con el tipo de enum
            var enumSeleccionado = (TipoPagoEnum)pedidoGB.Controls.OfType<RadioButton>().FirstOrDefault(x => x.Checked).Tag;
            // Obtengo el numero de pedido a crear
            int idPedido = pedidoCEN.ObtenerTodos(0, 0).Count + 1;
            // Linea de Pedido a insertar
            IList<LineaPedidoEN> lineaPedido = new List<LineaPedidoEN>();
            // Lista para relacionar las lineas con el pedido
            IList<int> idLineas = new List<int>();
            // Cojo la cantidad y el id de los productos del grid del pedido

            foreach (PedidoGV p in _lproductosPedido)
            {
                // Añado a la lista
                lineaPedido.Add(new LineaPedidoEN(Convert.ToInt32(p.Id), Convert.ToInt32(p.Cantidad),
                    _productoCEN.get_IProductoCAD().ReadOIDDefault(p.Id), null));
                idLineas.Add(Convert.ToInt32(p.Id));
            }
            // Instancio y Creo el pedido
            var pFinal = new PedidoEN(idPedido.ToString(), DateTime.Today, EstadoPedidoEnum.Enviado, enumSeleccionado, lineaPedido, _proveedorCEN.get_IProveedorCAD().ReadOIDDefault(_proveedor.Id));
            pedidoCEN.Crear(pFinal.Id, pFinal.Fecha, pFinal.Estado, pFinal.TipoPago, pFinal.Lineas, pFinal.Proveedor.Id);
            // Relaciono las lineas con el pedido
            pedidoCEN.Relationer_lineas(idPedido.ToString(), idLineas);

            this.Close();
        }
        public void pdfProveedor(ProveedorEN proveedor)
        {
            Document document;
            document = new Document(PageSize.A4, 25, 25, 30, 30);
            string path = @"" + "Proveedor " + proveedor.Id + ".pdf";
            FileStream fs = new FileStream(path, FileMode.OpenOrCreate);

            // Create an instance to the PDF file by creating an instance of the PDF
            // Writer class using the document and the filestrem in the constructor.
            PdfWriter writer = PdfWriter.GetInstance(document, fs);

            // Open the document to enable you to write to the document
            document.Open();

            // Creo cabecera del informe
            PdfPTable tableTitulo = new PdfPTable(2);
            tableTitulo.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
            PdfPCell cell = new PdfPCell(new Phrase("Informe de Proveedor"));
            cell.BorderWidth = 0;
            cell.Colspan = 3;
            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            tableTitulo.AddCell(cell);
            document.Add(tableTitulo);

            //Tabla sin bordes
            PdfPTable tableCabecera = new PdfPTable(2);
            tableCabecera.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;

            //Cargamos la imagen de resources.
            System.Drawing.Image logores = Properties.Resources.logo;
            iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(logores, System.Drawing.Imaging.ImageFormat.Jpeg);

            //Añado imagen a la cabecera y fecha.
            logo.ScaleAbsolute(100f, 100f);
            PdfPCell cellLogo = new PdfPCell(logo);
            cellLogo.BorderWidth = 0;
            tableCabecera.AddCell(cellLogo);
            tableCabecera.AddCell("\n\n\n\n\nEmpresa: " + Constantes._NOMBREEMPRESA + "\nLocalidad: " + Constantes._CIUDADEMPRESA + "\nFecha: " + DateTime.Now.ToString() + "\n");

            //Inserto tabla de cabecera
            document.Add(tableCabecera);

            Paragraph salto = new Paragraph(" ");
            document.Add(salto);
            document.Add(salto);

            //Añadimos una tabla con los datos del Proveedor
            PdfPTable tableProveedor = new PdfPTable(2);
            PdfPCell cell2 = new PdfPCell(new Phrase("Datos del Proveedor"));
            cell2.Colspan = 2;
            cell2.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            tableProveedor.AddCell(cell2);
            tableProveedor.AddCell("Id");
            tableProveedor.AddCell(proveedor.Id);
            tableProveedor.AddCell("Nombre");
            tableProveedor.AddCell(proveedor.Nombre);
            tableProveedor.AddCell("Email");
            tableProveedor.AddCell(proveedor.Email);
            tableProveedor.AddCell("Dirección");
            tableProveedor.AddCell(proveedor.Direccion);
            tableProveedor.AddCell("Localidad");
            tableProveedor.AddCell(proveedor.Localidad);
            tableProveedor.AddCell("Provincia");
            tableProveedor.AddCell(proveedor.Provincia);
            tableProveedor.AddCell("CP");
            tableProveedor.AddCell(proveedor.CodigoPostal);
            tableProveedor.AddCell("País");
            tableProveedor.AddCell(proveedor.Pais);
            tableProveedor.AddCell("Teléfono");
            tableProveedor.AddCell(proveedor.Telefono);
            tableProveedor.AddCell("Descripción");
            tableProveedor.AddCell(proveedor.Descripcion);
            document.Add(tableProveedor);

            document.Add(salto);
            document.Add(salto);

            // Añadimos una tabla con los datos de los pedidos
            PdfPTable tablePedidos = new PdfPTable(4);
            tablePedidos.TotalWidth = 500f;
            tablePedidos.LockedWidth = true;
            PdfPCell cell3 = new PdfPCell(new Phrase("Pedidos al Proveedor"));
            cell3.Colspan = 4;
            cell3.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            tablePedidos.AddCell(cell3);
            tablePedidos.AddCell("Id");
            tablePedidos.AddCell("Fecha");
            tablePedidos.AddCell("Estado");
            tablePedidos.AddCell("Tipo de pago");

            PedidoCEN pedidoCEN = new PedidoCEN();
            ProveedorCEN proveedorCEN = new ProveedorCEN();
            foreach (var pedido in pedidoCEN.ObtenerTodos(0, 0))
            {
                if (proveedor.Equals(pedido.Proveedor))
                {
                    tablePedidos.AddCell(pedido.Id);
                    tablePedidos.AddCell(pedido.Fecha.ToString());
                    tablePedidos.AddCell(pedido.Estado.ToString());
                    tablePedidos.AddCell(pedido.TipoPago.ToString());
                }
            }
            document.Add(tablePedidos);

            //Cerramos todo
            document.Close();
            writer.Close();
            fs.Close();

            MessageBox.Show("Se ha generado un informe en PDF con el nombre \"" + path + "\"");
        }