コード例 #1
0
ファイル: BatchPrintWindow3.xaml.cs プロジェクト: fakeknv/PMS
        /// <summary>
        /// Creates the AddRequestForm Window and Initializes DB Param.
        /// </summary>
        public BatchPrintWindow3(System.Collections.IList items)
        {
            _items  = items;
            pmsutil = new PMSUtil();
            InitializeComponent();
            GetResidingPriests();
            PrintingFee.Value = Convert.ToDouble(pmsutil.GetPrintFee("Burial"));
            records           = new ObservableCollection <RecordEntryBurial>();

            for (int i = 0; i < items.Count; i++)
            {
                RecordEntryBurial recordx = (RecordEntryBurial)items[i];
                Console.WriteLine(recordx.RecordID);
                records.Add(new RecordEntryBurial()
                {
                    RecordID         = recordx.RecordID,
                    EntryNumber      = recordx.EntryNumber,
                    DeathYear        = recordx.DeathYear,
                    DeathDate        = recordx.DeathDate,
                    BurialYear       = recordx.BurialYear,
                    BurialDate       = recordx.BurialDate,
                    FullName         = recordx.FullName,
                    Age              = Convert.ToInt32(recordx.Age),
                    Status           = recordx.Status,
                    Residence1       = recordx.Residence2,
                    Residence2       = recordx.Residence1,
                    Sacrament        = recordx.Sacrament,
                    CauseOfDeath     = recordx.CauseOfDeath,
                    PlaceOfInterment = recordx.PlaceOfInterment,
                    Parent1          = recordx.Parent1,
                    Parent2          = recordx.Parent2,
                    Stipend          = Convert.ToDouble(recordx.Stipend),
                    Minister         = recordx.Minister
                });
            }
            EntriesHolder.Items.Refresh();
            EntriesHolder.ItemsSource = records;
            EntriesHolder.Items.Refresh();
        }
コード例 #2
0
ファイル: BatchPrintWindow3.xaml.cs プロジェクト: fakeknv/PMS
        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;
                });
                RecordEntryBurial recordx = (RecordEntryBurial)_items[i];

                string[] bspl = DateTime.Parse(recordx.BurialDate + "," + recordx.BurialYear).ToString("MM/dd/yyyy").Split('/');
                string   bmon = PrepMonth(int.Parse(bspl[0]));

                string[] dspl = DateTime.Parse(recordx.DeathDate + "," + recordx.DeathYear).ToString("MM/dd/yyyy").Split('/');
                string   dmon = PrepMonth(int.Parse(dspl[0]));

                Document doc = new Document();
                doc.LoadFromFile("Data\\temp_death.docx");
                doc.Replace("name", recordx.FullName, true, true);
                doc.Replace("age", Convert.ToString(recordx.Age), true, true);
                doc.Replace("nationality", "Filipino", true, true);
                doc.Replace("residence", recordx.Residence1, true, true);
                doc.Replace("civil", recordx.Status, true, true);

                if (string.IsNullOrEmpty(recordx.Parent2))
                {
                    doc.Replace("father", " ", true, true);
                    doc.Replace("mother", " ", true, true);
                    doc.Replace("spouse", recordx.Parent1, true, true);
                }
                else
                {
                    doc.Replace("father", recordx.Parent1, true, true);
                    doc.Replace("mother", recordx.Parent2, true, true);
                    doc.Replace("spouse", " ", true, true);
                }
                doc.Replace("date_of_birth", bmon + " " + bspl[1] + ", " + bspl[2], true, true);
                doc.Replace("cause_of_death", recordx.CauseOfDeath, true, true);
                doc.Replace("date_of_burial", dmon + " " + dspl[1] + ", " + dspl[2], true, true);
                doc.Replace("place_of_burial", recordx.PlaceOfInterment, true, true);
                doc.Replace("priest", recordx.Minister, true, true);
                doc.Replace("sign", signature, true, true);
                doc.Replace("no", recordx.EntryNumber.ToString(), true, true);
                doc.Replace("page", GetPNum(recordx.RecordID).ToString(), true, true);
                string[] date = DateTime.Now.ToString("MMMM,d,yyyy").Split(',');;
                doc.Replace("month", date[0], true, true);
                doc.Replace("day", date[1], 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("Burial Cert.", "Paying", recordx.RecordID, Convert.ToDouble(pmsutil.GetPrintFee("Burial")));

                tick++;
            }
        }