Esempio n. 1
0
        private Document GeneratePDF(string use)
        {
            List <Bottles> listBottle = new List <Bottles>();

            //check which order by is selected, select the correct list depending on that
            if (radColor.Checked)
            {
                listBottle = Bottles.OrderByColor();
            }
            else if (radCountry.Checked)
            {
                listBottle = Bottles.OrderByCountry();
            }
            else if (radManufacturer.Checked)
            {
                listBottle = Bottles.OrderByManufacturer();
            }
            else if (radVariety.Checked)
            {
                listBottle = Bottles.OrderByVarietal();
            }
            else if (txtResearch.Text != "")
            {
                listBottle = Bottles.ResearchByKeyword(txtResearch.Text);
            }
            //if no ordering, select all bottles as they are in DB
            else
            {
                listBottle = Bottles.ShowAllBottles();
            }

            string jour = DateTime.Today.Day.ToString() + "." + DateTime.Today.Month.ToString() + "." + DateTime.Today.Year.ToString();
            // Must have write permissions to the path folder
            PdfWriter writer;

            if (use == "def")
            {
                writer = new PdfWriter("C:\\ListeBouteilles_" + jour + ".pdf");
            }
            else
            {
                writer = new PdfWriter("C:\\temp\\list" + jour + ".pdf");
            }
            //it is necessary to specify, because the class PdfDocument exist in both iText and Spire
            iText.Kernel.Pdf.PdfDocument pdf = new iText.Kernel.Pdf.PdfDocument(writer);
            Document  document = new Document(pdf);
            Paragraph header   = new Paragraph("Liste de bouteilles stockées")
                                 .SetTextAlignment(TextAlignment.CENTER)
                                 .SetFontSize(14);

            document.Add(header);
            Table table = CreateTable(listBottle);

            document.Add(table);
            document.Close();

            return(document);
        }
        public void ResearchByKeyWord_existingword_OK()
        {
            List <Bottles> resExpected = lstKeyword;
            List <Bottles> resCalculated;

            resCalculated = Bottles.ResearchByKeyword("test");

            Assert.AreEqual(resExpected, resCalculated);
        }
Esempio n. 3
0
        private void btnResearch_Click(object sender, EventArgs e)
        {
            string keyword;

            if (txtResearch.Text != "")
            {
                keyword   = txtResearch.Text;
                lstBottle = Bottles.ResearchByKeyword(keyword);
                // method to reload the data, specifying the data to use
                LoadData(lstBottle);
            }
            else
            {
                MessageBox.Show("Sans texte de recherche, cela ne fonctionnera pas");
            }
        }