Пример #1
0
        private void butPostcards_Click(object sender, EventArgs e)
        {
            if (!validDateFrom.IsValid || !validDateTo.IsValid)
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            DateTime dateFrom = PIn.Date(validDateFrom.Text);
            DateTime dateTo   = PIn.Date(validDateTo.Text);

            if (dateTo < dateFrom)
            {
                MsgBox.Show(this, "To date cannot be before From date.");
                return;
            }
            if (dateFrom.AddYears(1) <= dateTo)
            {
                MsgBox.Show(this, "Date range must not exceed 1 year.");
                return;
            }
            BirthdayTable = RpBirthday.GetBirthdayTable(dateFrom, dateTo);
            if (BirthdayTable.Rows.Count == 0)
            {
                MsgBox.Show(this, "No postcards to preview.");
                return;
            }
            pagesPrinted    = 0;
            patientsPrinted = 0;
            PaperSize           paperSize;
            PrintoutOrientation orient = PrintoutOrientation.Default;

            if (PrefC.GetLong(PrefName.RecallPostcardsPerSheet) == 1)
            {
                paperSize = new PaperSize("Postcard", 400, 600);
                orient    = PrintoutOrientation.Landscape;
            }
            else if (PrefC.GetLong(PrefName.RecallPostcardsPerSheet) == 3)
            {
                paperSize = new PaperSize("Postcard", 850, 1100);
            }
            else              //4
            {
                paperSize = new PaperSize("Postcard", 850, 1100);
                orient    = PrintoutOrientation.Landscape;
            }
            int totalPages = (int)Math.Ceiling((double)BirthdayTable.Rows.Count / (double)PrefC.GetLong(PrefName.RecallPostcardsPerSheet));

            PrinterL.TryPreview(pdCards_PrintPage,
                                Lan.g(this, "Birthday report postcards printed"),
                                PrintSituation.Postcard,
                                new Margins(0, 0, 0, 0),
                                PrintoutOrigin.AtMargin,
                                paperSize,
                                orient,
                                totalPages
                                );
        }
Пример #2
0
 private void butLabelPreview_Click(object sender, EventArgs e)
 {
     if (gridMain.SelectedIndices.Length == 0)
     {
         MsgBox.Show(this, "Please select patient(s) first.");
         return;
     }
     pagesPrinted    = 0;
     patientsPrinted = 0;
     PrinterL.TryPreview(pdLabels_PrintPage,
                         Lan.g(this, "Treatment finder labels printed"),
                         PrintSituation.LabelSheet,
                         new Margins(0, 0, 0, 0),
                         PrintoutOrigin.AtMargin,
                         totalPages: (int)Math.Ceiling((double)gridMain.SelectedIndices.Length / 30)
                         );
 }