public SettingsForm() { InitializeComponent(); BranchInfo dummybranch = new BranchInfo(Branch.Brisbane); branchSelectionComboBox.DataSource = dummybranch.GetBranchNameList(); LoadDefaultSettings(); }
private void button1_Click(object sender, EventArgs e) { List <string> warningMessages = throughOutCheck(); if (warningMessages.Count > 0) { if (!doesUserWantToProceed(warningMessages)) { return; // if user decide to take another look, then return } } List <Account> accountList = new List <Account>(); for (int i = 0; i < MAX_ACCOUNTS_SUPPORTED; i++) { if (accountCheckBoxes[i].Checked) { string accountType = accountTypeComboBoxes[i].Text; string ccyCode = accountCcyComboBoxes[i].Text; string longNumber = "100001401" + accountLongNumberTextBoxes[i].Text; string shortNumber = ""; if (accountShortNumberTextBoxes[i].Text != "") { shortNumber = "9000" + accountShortNumberTextBoxes[i].Text; } accountList.Add(new Account(accountType, ccyCode, longNumber, shortNumber)); } } CustomerInformation customer; if (addressInclusionCheckBox.Checked) { customer = new CustomerInformation(customerNameTextBox.Text, addressLineTextBox1.Text, addressLineTextBox2.Text, addressLineTextBox3.Text); } else { customer = new CustomerInformation(customerNameTextBox.Text); } BranchInfo branch = new BranchInfo((Branch)(Properties.Settings.Default.DefaultBranchIndex)); bool inclEmail = emailInclusionCheckBox.Checked; string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + customer.GetName() + ".pdf"; Pdf_Generation_Class.GenerateWelcomeLetterSimple(fileName, customer, accountList, branch, inclEmail); if (openFileCheckBox.Checked) { System.Diagnostics.Process.Start(fileName); } }
private static void DrawBranchNameAddress(BranchInfo branch, bool inclEmail) { // save graphics state Contents.SaveGraphicsState(); // set coordinate Contents.Translate(10, 18.7); // Define constants const Double Width = 9.65; const Double Height = 8; const Double FontSize = 10; // Create text box object with no first line indent TextBox branchContact = new TextBox(Width, 0); // print address List <string> branchAddress = branch.GetContact(inclEmail); branchAddress[0] = "Bank of China " + branchAddress[0]; foreach (string line in branchAddress) { branchContact.AddText(ArialNormal, FontSize, line + "\n"); } // print web address branchContact.AddText(ArialNormal, FontSize, "http://www.bankofchina.com/au/"); // Draw the text box Double PosY = Height; Contents.DrawText(0.0, ref PosY, 0.0, 0, 0, 0, TextBoxJustify.Right, branchContact); // restore graphics state Contents.RestoreGraphicsState(); return; }
private static void DrawGroupContact() { // Define constants const Double LEFT = 1.3; const Double TOP = 4.5; const Double BOTTOM = 1; const Double RIGHT = 1.3 + 18.39; const Double FONT_SIZE = 8; const Double MARGIN_HOR = 0.04; const Double MARGIN_VER = 0.04; BranchInfo branch = new BranchInfo(Branch.Banking); string[,] branchContact = branch.GetFullDataSet(); int numOfBranches = branchContact.GetLength(0); int numOfColumns = (numOfBranches + 1) / 2; // column widths Double colWidth = 18.39 / numOfColumns; // define table PdfTable Table = new PdfTable(Page, Contents, ArialNormal, FONT_SIZE); Table.TableArea = new PdfRectangle(LEFT, BOTTOM, RIGHT, TOP); Table.SetColumnWidth(Enumerable.Repeat(colWidth, numOfColumns).ToArray()); // define borders Table.Borders.ClearAllBorders(); // margin PdfRectangle Margin = new PdfRectangle(MARGIN_HOR, MARGIN_VER); // account type style Table.DefaultCellStyle.Margin = Margin; for (int i = 0; i < 2 * 4; i++) { int index = i % 4; int startBranchIndex; if (i < 4) { startBranchIndex = 0; } else { startBranchIndex = numOfColumns; } int cell = 0; for (int j = startBranchIndex; j < startBranchIndex + numOfColumns; j++) { Table.Cell[cell].Value = branchContact[j, index]; cell++; } Table.DrawRow(); if (i == 3) { Table.DrawRow(); //Draw 2 extra rows as spacer Table.DrawRow(); } } Table.Close(); // save graphics state Contents.SaveGraphicsState(); // restore graphics state Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Create article's example test PDF document //////////////////////////////////////////////////////////////////// public static void GenerateWelcomeLetterSimple(String FileName, CustomerInformation customer, List <Account> accountList, BranchInfo branch, bool inclEmail, Boolean Debug = false) { // Create an empty pdf document in A4 and measured in cm bool landscape = false; document = new PdfDocument(PaperType.A4, landscape, UnitOfMeasure.cm, FileName); // Set debug tag document.Debug = Debug; // Write Pdf info PdfInfo Info = PdfInfo.CreatePdfInfo(document); Info.Title("Welcome Letter - Bank of China"); Info.Author("Bank of China " + branch.GetAddress()[0]); Info.Keywords("Account, Bank of China, Remittance"); Info.Subject("Remittance information for Bank of China accounts"); // define font resources DefineFontResources(); // Add first page, also the only page for simple welcome letter Page = new PdfPage(document); // Add contents to page Contents = new PdfContents(Page); // Add graphices and text contents to the contents object DrawTitle(); if (customer.HasAddress()) { DrawCustomerNameAddress(customer); } DrawBranchNameAddress(branch, inclEmail); DrawLetterGreeting(customer); DrawBankInformation(customer); DrawAccountInformationForm(accountList); DrawLetterBody(); DrawGroupContact(); // Create pdf file document.CreateFile(); // exit return; }