Ignore:
Timestamp:
May 21, 2010, 9:03:45 PM (14 years ago)
Author:
Sam Habiel
Message:

Removal of Crystal Reports
Partial Rework of Clinic Patient List report
Other reports that used Crystal don't work yet.
Fixes for Strongly typed DataTables (change the RESOURCEID from uint to int) to support table merge from untyped table.
Support for command line arguments: /s= for server /p= for port /a= for access code /v= for verify code
Only the following combinations work: none; /s and /p; /s, /p, /a, /v

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.cs

    r614 r772  
    11using System;
    2 using System.Drawing;
    3 using System.Collections;
    4 using System.ComponentModel;
    52using System.Windows.Forms;
    63using System.Data;
    7 using CrystalDecisions.Windows;
    8 using CrystalDecisions.Shared;
    9 using CrystalDecisions.CrystalReports.Engine;
    10 using IndianHealthService.BMXNet;
     4using System.Drawing.Printing;
     5using System.Drawing;
    116
    127namespace IndianHealthService.ClinicalScheduling
     
    1510        /// Summary description for DPatientLetter.
    1611        /// </summary>
    17         public class DPatientLetter : System.Windows.Forms.Form
    18         {
    19                 private CrystalDecisions.Windows.Forms.CrystalReportViewer crViewer1;
     12        public class DPatientLetter : System.Windows.Forms.PrintPreviewDialog
     13    {
    2014                /// <summary>
    2115                /// Required designer variable.
    2216                /// </summary>
    23                 private System.ComponentModel.Container components = null;
     17        private System.ComponentModel.Container components = null;
     18        private System.Drawing.Printing.PrintDocument printDocument1;
    2419
    2520                #region Fields
    26 
    27                 private string  m_sBodyText;
     21        DateTime _dtBegin, _dtEnd; //global fields to use in passing to printing method
     22        int _currentResourcePrinting = 0;
     23        int _currentApptPrinting = 0;
     24        dsPatientApptDisplay2 _ds;
    2825                #endregion Fields
    29 
    30                 #region Properties
    31 
    32                 public string BodyText
    33                 {
    34                         get
    35                         {
    36                                 return m_sBodyText;
    37                         }
    38                         set
    39                         {
    40                                 m_sBodyText = value;
    41                         }
    42                 }
    43 
    44                 #endregion Properties
    45 
    46                 public void InitializeForm(CGDocumentManager docManager, int nPatientID)
    47                 {
    48                         try
    49                         {       
    50                                 crViewer1.DisplayGroupTree = true;
    51 
    52                                 ClinicalScheduling.crPatientLetter cr = new crPatientLetter();
    53                                 string sSql = "BSDX PATIENT APPT DISPLAY^" + nPatientID.ToString();
    54                                 System.Data.DataSet ds = new System.Data.DataSet();
    55                                 DataTable dtAppt = docManager.RPMSDataTable(sSql, "PatientAppts");
    56                                 ds.Tables.Add(dtAppt.Copy());
    57 
    58                                 System.Data.DataTable dt =
    59                                         docManager.GlobalDataSet.Tables["Resources"].Copy();
    60                                 ds.Tables.Add(dt);
    61 
    62                                 cr.Database.Tables["PatientAppts"].SetDataSource(ds.Tables["PatientAppts"]);
    63                                 cr.Database.Tables["BSDXResource"].SetDataSource(ds.Tables["Resources"]);
    64 
    65                                 crViewer1.SelectionFormula = "{PatientAppts.ApptDate} >= CurrentDate";
    66                                 this.crViewer1.ReportSource = cr;
    67                                
    68                         }
    69                         catch (Exception ex)
    70                         {
    71                                 throw ex;
    72                         }
    73                 }
    7426
    7527                public void InitializeFormClinicSchedule(CGDocumentManager docManager,
     
    8436                                        throw new Exception("At least one clinic must be selected.");
    8537                                }
     38                _dtBegin = dtBegin;
     39                _dtEnd = dtEnd;
    8640                                string sBegin = dtBegin.ToShortDateString();
    8741                                string sEnd = dtEnd.ToShortDateString();
    88                                 crViewer1.DisplayGroupTree = true;
    8942                                this.Text="Clinic Schedules";
    9043
    91                                 ClinicalScheduling.crAppointmentList cr = new crAppointmentList();
    9244                                string sSql = "BSDX CLINIC LETTERS^" + sClinicList + "^" + sBegin + "^" + sEnd;
    93 
    94                                 DataTable dtAppt = docManager.RPMSDataTable(sSql, "PatientAppts");                             
    95                                 cr.Database.Tables["PatientAppts"].SetDataSource(dtAppt);
    96 
    97                                 this.crViewer1.ReportSource = cr;
    98                         }
     45                string sSql2 = "BSDX RESOURCE LETTERS^" + sClinicList;
     46
     47                _ds = new dsPatientApptDisplay2();
     48                _ds.BSDXResource.Merge(docManager.RPMSDataTable(sSql2, "Resources"));
     49                _ds.PatientAppts.Merge(docManager.RPMSDataTable(sSql, "PatientAppts"));
     50            }
    9951                        catch (Exception ex)
    10052                        {
     
    11365                                        throw new Exception("At least one clinic must be selected.");
    11466                                }
    115                                 crViewer1.DisplayGroupTree = true;
    116 
    117                                 ClinicalScheduling.crRebookLetter cr = new crRebookLetter();
     67
     68                                System.Data.DataSet ds = new System.Data.DataSet();
     69                                ds.Tables.Add(dtLetters.Copy());
     70                               
     71                                string sSql = "BSDX RESOURCE LETTERS^" + sClinicList;
     72                                DataTable dt = docManager.RPMSDataTable(sSql, "Resources");                             
     73                                ds.Tables.Add(dt.Copy());                               
     74                        }
     75                        catch (Exception ex)
     76                        {
     77                                throw ex;
     78                        }
     79                }
     80
     81                public void InitializeFormCancellationLetters(CGDocumentManager docManager,
     82                        string sClinicList,
     83                        DataTable dtLetters)
     84                {
     85                        try
     86                        {       
     87                                if (sClinicList == "")
     88                                {
     89                                        throw new Exception("At least one clinic must be selected.");
     90                                }
    11891
    11992                                System.Data.DataSet ds = new System.Data.DataSet();
     
    12396                                DataTable dt = docManager.RPMSDataTable(sSql, "Resources");                             
    12497                                ds.Tables.Add(dt.Copy());
    125 
    126                                 cr.Database.Tables["PatientAppts"].SetDataSource(ds.Tables["PatientAppts"]);
    127                                 cr.Database.Tables["BSDXResource"].SetDataSource(ds.Tables["Resources"]);
    128 
    129                                 this.crViewer1.ReportSource = cr;
    130                                
    131                         }
    132                         catch (Exception ex)
    133                         {
    134                                 throw ex;
    135                         }
    136                 }
    137 
    138                 public void InitializeFormCancellationLetters(CGDocumentManager docManager,
    139                         string sClinicList,
    140                         DataTable dtLetters)
    141                 {
    142                         try
    143                         {       
    144                                 if (sClinicList == "")
    145                                 {
    146                                         throw new Exception("At least one clinic must be selected.");
    147                                 }
    148                                 crViewer1.DisplayGroupTree = true;
    149 
    150                                 ClinicalScheduling.crCancelLetter cr = new crCancelLetter();
    151 
    152                                 System.Data.DataSet ds = new System.Data.DataSet();
    153                                 ds.Tables.Add(dtLetters.Copy());
    154                                
    155                                 string sSql = "BSDX RESOURCE LETTERS^" + sClinicList;
    156                                 DataTable dt = docManager.RPMSDataTable(sSql, "Resources");                             
    157                                 ds.Tables.Add(dt.Copy());
    158 
    159                                 cr.Database.Tables["PatientAppts"].SetDataSource(ds.Tables["PatientAppts"]);
    160                                 cr.Database.Tables["BSDXResource"].SetDataSource(ds.Tables["Resources"]);
    161 
    162                                 this.crViewer1.ReportSource = cr;
    16398                               
    16499                        }
     
    183118                                string sBegin = dtBegin.ToShortDateString();
    184119                                string sEnd = dtEnd.ToShortDateString();
    185                                 crViewer1.DisplayGroupTree = true;
    186 
    187                                 ClinicalScheduling.crPatientLetter cr = new crPatientLetter();
     120
    188121                                string sSql = "BSDX CLINIC LETTERS^" + sClinicList + "^" + sBegin + "^" + sEnd;
    189122
     
    195128                                DataTable dt = docManager.RPMSDataTable(sSql, "Resources");                             
    196129                                ds.Tables.Add(dt.Copy());
    197 
    198                                 cr.Database.Tables["PatientAppts"].SetDataSource(ds.Tables["PatientAppts"]);
    199                                 cr.Database.Tables["BSDXResource"].SetDataSource(ds.Tables["Resources"]);
    200 
    201                                 this.crViewer1.ReportSource = cr;
    202130                               
    203131                        }
     
    243171                private void InitializeComponent()
    244172                {
    245                         this.crViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
    246                         this.SuspendLayout();
    247                         //
    248                         // crViewer1
    249                         //
    250                         this.crViewer1.ActiveViewIndex = -1;
    251                         this.crViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
    252                         this.crViewer1.Location = new System.Drawing.Point(0, 0);
    253                         this.crViewer1.Name = "crViewer1";
    254                         this.crViewer1.ReportSource = null;
    255                         this.crViewer1.Size = new System.Drawing.Size(648, 398);
    256                         this.crViewer1.TabIndex = 0;
    257                         //
    258                         // DPatientLetter
    259                         //
    260                         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    261                         this.ClientSize = new System.Drawing.Size(648, 398);
    262                         this.Controls.Add(this.crViewer1);
    263                         this.Name = "DPatientLetter";
    264                         this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    265                         this.Text = "Patient Letter";
    266                         this.ResumeLayout(false);
     173            this.printDocument1 = new System.Drawing.Printing.PrintDocument();
     174            this.SuspendLayout();
     175            //
     176            // printDocument1
     177            //
     178            this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
     179            //
     180            // DPatientLetter
     181            //
     182            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     183            this.ClientSize = new System.Drawing.Size(648, 398);
     184            this.Document = this.printDocument1;
     185            this.Name = "DPatientLetter";
     186            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     187            this.Text = "Patient Letter";
     188            this.ResumeLayout(false);
    267189
    268190                }
    269191                #endregion
     192
     193        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
     194        {
     195            // _currentResourcePrinting starts with zero. There will be at least this one.
     196            ClinicalScheduling.Printing.PrintAppointments(_ds, e, _dtBegin, _dtEnd,
     197                    _currentResourcePrinting, ref _currentApptPrinting);
     198
     199            //If the printing routine says it needs more pages to print the appointments,
     200            //return here and have it print again.
     201            if (e.HasMorePages == true) return;
     202
     203            // if there are more resouces to print, increment. Setting HasMorePages to true
     204            // calls this routine again, so printing will happen with the incremented _currentResourcePrinting
     205            if (_currentResourcePrinting < _ds.BSDXResource.Rows.Count - 1)
     206            {
     207                _currentResourcePrinting++;
     208                e.HasMorePages = true;
     209            }
     210           
     211        }
    270212        }
    271213}
Note: See TracChangeset for help on using the changeset viewer.