Example #1
0
        /// <summary>
        /// Creates the AddRequestForm Window and Initializes DB Param.
        /// </summary>
        public BatchPrintWindow1(System.Collections.IList items)
        {
            _items  = items;
            pmsutil = new PMSUtil();
            InitializeComponent();
            GetResidingPriests();
            PrintingFee.Value = Convert.ToDouble(pmsutil.GetPrintFee("Confirmation"));
            records           = new ObservableCollection <RecordEntryConfirmation>();

            for (int i = 0; i < items.Count; i++)
            {
                RecordEntryConfirmation recordx = (RecordEntryConfirmation)items[i];
                Console.WriteLine(recordx.RecordID);
                records.Add(new RecordEntryConfirmation()
                {
                    RecordID         = recordx.RecordID,
                    EntryNumber      = recordx.EntryNumber,
                    ConfirmationYear = recordx.ConfirmationYear,
                    ConfirmationDate = recordx.ConfirmationDate,
                    FullName         = recordx.FullName,
                    Age            = Convert.ToInt32(recordx.Age),
                    Parish         = recordx.Parish,
                    Province       = recordx.Province,
                    PlaceOfBaptism = recordx.PlaceOfBaptism,
                    Parent1        = recordx.Parent1,
                    Parent2        = recordx.Parent2,
                    Sponsor1       = recordx.Sponsor1,
                    Sponsor2       = recordx.Sponsor2,
                    Stipend        = recordx.Stipend,
                    Minister       = recordx.Minister
                });
            }
            EntriesHolder.Items.Refresh();
            EntriesHolder.ItemsSource = records;
            EntriesHolder.Items.Refresh();
        }
Example #2
0
        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;
                });
                RecordEntryConfirmation recordx = (RecordEntryConfirmation)_items[i];

                string x1;

                string[] spl  = DateTime.Parse(recordx.ConfirmationDate + "," + recordx.ConfirmationYear).ToString("MM/dd/yyyy").Split('/');
                string   suff = GetDaySuffix(int.Parse(spl[1]));
                string   mon  = PrepMonth(int.Parse(spl[0]));
                if (int.Parse(spl[2]) > 1999)
                {
                    x1     = "";
                    spl[2] = spl[2].Remove(0, 2);
                }
                else
                {
                    x1 = "X";
                }

                Document doc = new Document();
                doc.LoadFromFile("Data\\temp_confirmation.docx");
                doc.Replace("name", recordx.FullName, true, true);
                doc.Replace("day", int.Parse(spl[1]) + suff, true, true);
                doc.Replace("month", mon, true, true);
                doc.Replace("X", x1, true, true);
                doc.Replace("year", spl[2], true, true);
                doc.Replace("by", recordx.Minister, true, true);
                doc.Replace("no", recordx.EntryNumber.ToString(), 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("Confirmation Cert.", "Paying", recordx.RecordID, Convert.ToDouble(pmsutil.GetPrintFee("Confirmation")));
                tick++;
            }
        }