/// <summary> /// Creates the AddRequestForm Window and Initializes DB Param. /// </summary> public BatchPrintWindow2(System.Collections.IList items) { _items = items; pmsutil = new PMSUtil(); InitializeComponent(); GetResidingPriests(); PrintingFee.Value = Convert.ToDouble(pmsutil.GetPrintFee("Matrimonial")); records = new ObservableCollection <RecordEntryMatrimonial>(); for (int i = 0; i < items.Count; i++) { RecordEntryMatrimonial recordx = (RecordEntryMatrimonial)items[i]; Console.WriteLine(recordx.RecordID); records.Add(new RecordEntryMatrimonial() { RecordID = recordx.RecordID, EntryNumber = recordx.EntryNumber, MarriageYear = recordx.MarriageYear, MarriageDate = recordx.MarriageDate, FullName1 = recordx.FullName1, FullName2 = recordx.FullName2, Age1 = Convert.ToInt32(recordx.Age1), Age2 = Convert.ToInt32(recordx.Age2), Hometown1 = recordx.Hometown1, Hometown2 = recordx.Hometown2, Residence1 = recordx.Residence1, Residence2 = recordx.Residence2, Parent1 = recordx.Parent1, Parent2 = recordx.Parent2, Parent3 = recordx.Parent3, Parent4 = recordx.Parent4, Witness1 = recordx.Witness1, Witness2 = recordx.Witness2, W1Residence = recordx.W1Residence, W2Residence = recordx.W2Residence, Stipend = Convert.ToDouble(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; }); RecordEntryMatrimonial recordx = (RecordEntryMatrimonial)_items[i]; string[] bspl = DateTime.Parse(recordx.MarriageDate + "," + recordx.MarriageYear).ToString("MM/dd/yyyy").Split('/'); string bsuff = GetDaySuffix(int.Parse(bspl[1])); string bmon = PrepMonth(int.Parse(bspl[0])); Document doc = new Document(); doc.LoadFromFile("Data\\temp_marriage.docx"); doc.Replace("name", recordx.FullName1, true, true); doc.Replace("name2", recordx.FullName2, true, true); doc.Replace("age", recordx.Age1.ToString(), true, true); doc.Replace("age2", recordx.Age2.ToString(), true, true); doc.Replace("nationality", "Filipino", true, true); doc.Replace("nationality2", "Filipino", true, true); doc.Replace("residence", recordx.Residence1, true, true); doc.Replace("residence2", recordx.Residence2, true, true); doc.Replace("civil", recordx.Status1, true, true); doc.Replace("civil2", recordx.Status2, true, true); doc.Replace("father", recordx.Parent1, true, true); doc.Replace("father2", recordx.Parent3, true, true); doc.Replace("mother", recordx.Parent2, true, true); doc.Replace("mother2", recordx.Parent4, true, true); doc.Replace("witness", recordx.Witness1, true, true); doc.Replace("witness2", recordx.Witness2, true, true); doc.Replace("place", "St. Raphael Parish", true, true); doc.Replace("date", bmon + " " + bspl[1] + bsuff + ", " + bspl[2], true, true); doc.Replace("priest", recordx.Minister, true, true); doc.Replace("sign", signature, true, true); doc.Replace("page", GetPNum(recordx.RecordID).ToString(), true, true); doc.Replace("no", GetBNum(recordx.RecordID).ToString(), true, true); string[] date = DateTime.Now.ToString("MMMM,d,yyyy").Split(','); doc.Replace("month", date[0], true, true); date[1] = date[1] + GetDaySuffix(int.Parse(date[1])); doc.Replace("days", date[1], true, true); doc.Replace("YY", date[2].Remove(0, 2), 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"); } //Reference string tmp = pmsutil.LogRecord(recordx.RecordID, "LOGC-03"); }); pmsutil.InsertTransaction("Matrimonial Cert.", "Paying", recordx.RecordID, Convert.ToDouble(pmsutil.GetPrintFee("Matrimonial"))); tick++; } }