} //button to save pdf file about all the customers in the table private void showSuppliersbtn_Click(object sender, EventArgs e) { Pfile pd = new Pfile("Suppliers Report.pdf"); pd.doc.OpenDocument(); pd.SetTitle("Suppliers"); PdfPTable myTable = new PdfPTable(5); float[] widthCell = new float[5]; for (int i = 0; i < 5; i++) { widthCell[i] = 20; } PdfPCell myCell = new PdfPCell(); myCell.FixedHeight = 20; myCell.HorizontalAlignment = Element.ALIGN_CENTER; myCell.VerticalAlignment = Element.ALIGN_CENTER; suppliers[] supp; supp = dataB.getAllsuppliers(); myCell.Phrase = new Phrase("suppplier ID"); myTable.AddCell(myCell); myCell.Phrase = new Phrase(" Name"); myTable.AddCell(myCell); myCell.Phrase = new Phrase("Address"); myTable.AddCell(myCell); myCell.Phrase = new Phrase("Phone Number"); myTable.AddCell(myCell); myCell.Phrase = new Phrase("Email"); myTable.AddCell(myCell); for (int i = 0; i < supp.Length; i++) { myCell.Phrase = new Phrase(supp[i].Supplier_id.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(supp[i].Sup_name.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(supp[i].Address.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(supp[i].Phone.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(supp[i].Email.ToString()); myTable.AddCell(myCell); } try { pd.doc.Add(myTable); MessageBox.Show("Success file downloaded"); } catch (Exception ex) { MessageBox.Show(ex.Message); } pd.CloseReport(); }//button to save pdf file about all the suppliers in the table
private void ShowCustomersBtn_Click_1(object sender, EventArgs e) { Pfile pd = new Pfile("Customers Report.pdf"); pd.doc.OpenDocument(); pd.SetTitle("Customers"); PdfPTable myTable = new PdfPTable(7); float[] widthCell = new float[7]; for (int i = 0; i < 7; i++) { widthCell[i] = 20; } PdfPCell myCell = new PdfPCell(); myCell.FixedHeight = 20; myCell.HorizontalAlignment = Element.ALIGN_CENTER; myCell.VerticalAlignment = Element.ALIGN_CENTER; Customers[] custo; custo = dataB.getAllCustomers(); myCell.Phrase = new Phrase("Customer ID"); myTable.AddCell(myCell); myCell.Phrase = new Phrase(" First Name"); myTable.AddCell(myCell); myCell.Phrase = new Phrase(" Last Name"); myTable.AddCell(myCell); myCell.Phrase = new Phrase("Address"); myTable.AddCell(myCell); myCell.Phrase = new Phrase("Email"); myTable.AddCell(myCell); myCell.Phrase = new Phrase("Phone Number"); myTable.AddCell(myCell); myCell.Phrase = new Phrase("Amount"); myTable.AddCell(myCell); for (int i = 0; i < custo.Length; i++) { myCell.Phrase = new Phrase(custo[i].Customer_id.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(custo[i].Customer_FirstName.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(custo[i].Customer_LastName.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(custo[i].Customer_Address.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(custo[i].Customer_Email.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(custo[i].Customer_PhoneNo.ToString()); myTable.AddCell(myCell); myCell.Phrase = new Phrase(custo[i].Customer_amount.ToString()); myTable.AddCell(myCell); } try { pd.doc.Add(myTable); MessageBox.Show("Success file downloaded"); } catch (Exception ex) { MessageBox.Show(ex.Message); } pd.CloseReport(); } //button to save pdf file about all the customers in the table