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 ShowAllBottles_NoSorting_OK() { List <Bottles> resExpected = lstBottles; List <Bottles> resCalculated = new List <Bottles>(); resCalculated = Bottles.ShowAllBottles(); Assert.AreEqual(resExpected, resCalculated); }
private void Researchfrm_Load(object sender, EventArgs e) { List <string> lstTab = new List <string>(); // get a list of all bottles in DB lstBottle = Bottles.ShowAllBottles(); LoadData(lstBottle); }
/** * method to load all data pertaining to the bottles, to show them on screen */ private void LoadData() { dvgBottles.ColumnCount = 8; //option for display dvgBottles.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy; dvgBottles.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; dvgBottles.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dvgBottles.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dvgBottles.CellBorderStyle = DataGridViewCellBorderStyle.Single; dvgBottles.GridColor = Color.Black; //column width - default : 100px dvgBottles.Columns[0].Width = 55; dvgBottles.Columns[3].Width = 45; dvgBottles.Columns[4].Width = 50; dvgBottles.Columns[5].Width = 55; //columns name dvgBottles.Columns[1].Name = "Nom du vin"; dvgBottles.Columns[2].Name = "Producteur"; dvgBottles.Columns[3].Name = "Année"; dvgBottles.Columns[4].Name = "Volume"; dvgBottles.Columns[5].Name = "Couleurs"; dvgBottles.Columns[6].Name = "Cépage(s)"; dvgBottles.Columns[7].Name = "Description"; dvgBottles.Columns[0].Name = "Quantité"; //delete all datas already contained in the datagridview dvgBottles.Rows.Clear(); List <Bottles> lstBottle = Bottles.ShowAllBottles(); foreach (Bottles bot in lstBottle) { string[] row = { bot.BottleNumber.ToString(), bot.Name, bot.Manufacturer, bot.Year.ToString(), bot.Volume.ToString(), bot.Color, bot.Varietal.ToString(), bot.Description }; dvgBottles.Rows.Add(row); } }