/// <summary> /// Creates the AddRequestForm Window and Initializes DB Param. /// </summary> public BatchPrintWindow(System.Collections.IList items) { _items = items; pmsutil = new PMSUtil(); InitializeComponent(); GetResidingPriests(); PrintingFee.Value = Convert.ToDouble(pmsutil.GetPrintFee("Baptismal")); records = new ObservableCollection <RecordEntryBaptismal>(); for (int i = 0; i < items.Count; i++) { RecordEntryBaptismal recordx = (RecordEntryBaptismal)items[i]; Console.WriteLine(recordx.RecordID); records.Add(new RecordEntryBaptismal() { RecordID = recordx.RecordID, EntryNumber = recordx.EntryNumber, BaptismalYear = recordx.BaptismalYear, BaptismalDate = recordx.BaptismalDate, FullName = recordx.FullName, BirthDate = recordx.BirthDate, Legitimacy = recordx.Legitimacy, PlaceOfBirth = recordx.PlaceOfBirth, Parent1 = recordx.Parent1, Parent2 = recordx.Parent2, Godparent1 = recordx.Godparent1, Godparent2 = recordx.Godparent2, Stipend = recordx.Stipend, Minister = recordx.Minister }); } EntriesHolder.Items.Refresh(); EntriesHolder.ItemsSource = records; EntriesHolder.Items.Refresh(); }
private void BatchPrint(object sender, DoWorkEventArgs e) { int tick = 0; int total = _items.Count; string signature = ""; string purpose = ""; double fee = 0d; App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { QueueCounter.Content = tick + "/" + total; QueuePBar.IsIndeterminate = true; signature = Signatory.Text; purpose = Purpose.Text; fee = Convert.ToDouble(PrintingFee.Value); }); for (int i = 0; i < _items.Count; i++) { App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { QueueCounter.Content = tick + "/" + total; }); RecordEntryBaptismal recordx = (RecordEntryBaptismal)_items[i]; string x1, x2; string[] bspl = DateTime.Parse(recordx.BirthDate).ToString("MM/dd/yyyy").Split('/'); string bsuff = GetDaySuffix(int.Parse(bspl[1])); string bmon = PrepMonth(int.Parse(bspl[0])); if (int.Parse(bspl[2]) > 1999) { x1 = ""; bspl[2] = bspl[2].Remove(0, 2); } else { x1 = "X"; } string[] dspl = DateTime.Parse(recordx.BaptismalDate + "," + recordx.BaptismalYear).ToString("MM/dd/yyyy").Split('/'); string dsuff = GetDaySuffix(int.Parse(dspl[1])); string dmon = PrepMonth(int.Parse(dspl[0])); if (int.Parse(dspl[2]) > 1999) { x2 = ""; dspl[2] = dspl[2].Remove(0, 2); } else { x2 = "X"; } Document doc = new Document(); doc.LoadFromFile("Data\\temp_baptismal.docx"); doc.LoadFromFile("Data\\temp_baptismal.docx"); doc.Replace("name", recordx.FullName, true, true); doc.Replace("father", recordx.Parent1, true, true); doc.Replace("mother", recordx.Parent2, true, true); doc.Replace("born", recordx.PlaceOfBirth, true, true); doc.Replace("day1", int.Parse(bspl[1]) + bsuff, true, true); doc.Replace("month1", bmon, true, true); doc.Replace("X1", x1, true, true); doc.Replace("year1", DateTime.Parse(recordx.BirthDate).ToString("yyyy"), true, true); doc.Replace("day2", int.Parse(dspl[1]) + dsuff, true, true); doc.Replace("month2", dmon, true, true); doc.Replace("X2", x2, true, true); doc.Replace("year2", DateTime.Parse(recordx.BaptismalDate + "," + recordx.BaptismalYear).ToString("yyyy"), true, true); doc.Replace("church", pmsutil.GetChurchName(), true, true); doc.Replace("by", signature, true, true); doc.Replace("sponsor1", recordx.Godparent1, true, true); doc.Replace("sponsor2", recordx.Godparent2, true, true); doc.Replace("book", GetBNum(recordx.RecordID).ToString(), true, true); doc.Replace("page", GetPNum(recordx.RecordID).ToString(), true, true); doc.Replace("no", recordx.EntryNumber.ToString(), true, true); doc.Replace("priest", recordx.Minister, true, true); doc.Replace("purpose", purpose, true, true); doc.Replace("date", DateTime.Now.ToString("MMMM d, yyyy"), true, true); doc.SaveToFile("Data\\print-" + i + ".docx", FileFormat.Docx); //Load Document Document document = new Document(); document.LoadFromFile(@"Data\\print-" + i + ".docx"); //Convert Word to PDF document.SaveToFile("Output\\print_file-" + i + ".pdf", FileFormat.PDF); App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { if (SkipPreview.IsChecked == true) { Spire.Pdf.PdfDocument docx = new Spire.Pdf.PdfDocument(); docx.LoadFromFile(@"Output\\print_file-" + i + ".pdf"); docx.PrintDocument.Print(); } else { System.Diagnostics.Process.Start("Output\\print_file-" + i + ".pdf"); } if (Purpose.SelectedIndex == 0) { //Reference string tmp = pmsutil.LogRecord(recordx.RecordID, "LOGC-03"); } else { //Marriage string tmp = pmsutil.LogRecord(recordx.RecordID, "LOGC-04"); } }); pmsutil.InsertTransaction("Baptismal Cert.", "Paying", recordx.RecordID, Convert.ToDouble(pmsutil.GetPrintFee("Baptismal"))); tick++; } }