| 1 | unit fSurgeryView; | 
|---|
| 2 |  | 
|---|
| 3 | interface | 
|---|
| 4 |  | 
|---|
| 5 | uses | 
|---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ORFN, | 
|---|
| 7 | StdCtrls, ExtCtrls, ORCtrls, ComCtrls, ORDtTm, Spin, rSurgery, fBase508Form, | 
|---|
| 8 | VA508AccessibilityManager; | 
|---|
| 9 |  | 
|---|
| 10 | type | 
|---|
| 11 | TfrmSurgeryView = class(TfrmBase508Form) | 
|---|
| 12 | pnlBase: TORAutoPanel; | 
|---|
| 13 | lblBeginDate: TLabel; | 
|---|
| 14 | calBeginDate: TORDateBox; | 
|---|
| 15 | lblEndDate: TLabel; | 
|---|
| 16 | calEndDate: TORDateBox; | 
|---|
| 17 | cmdOK: TButton; | 
|---|
| 18 | cmdCancel: TButton; | 
|---|
| 19 | lblMaxDocs: TLabel; | 
|---|
| 20 | edMaxDocs: TCaptionEdit; | 
|---|
| 21 | grpTreeView: TGroupBox; | 
|---|
| 22 | lblGroupBy: TOROffsetLabel; | 
|---|
| 23 | cboGroupBy: TORComboBox; | 
|---|
| 24 | radTreeSort: TRadioGroup; | 
|---|
| 25 | cmdClear: TButton; | 
|---|
| 26 | procedure cmdOKClick(Sender: TObject); | 
|---|
| 27 | procedure cmdCancelClick(Sender: TObject); | 
|---|
| 28 | procedure cmdClearClick(Sender: TObject); | 
|---|
| 29 | private | 
|---|
| 30 | FChanged: Boolean; | 
|---|
| 31 | FBeginDate: string; | 
|---|
| 32 | FFMBeginDate: TFMDateTime; | 
|---|
| 33 | FEndDate: string; | 
|---|
| 34 | FFMEndDate: TFMDateTime; | 
|---|
| 35 | FOpProc: string; | 
|---|
| 36 | FMaxDocs: integer; | 
|---|
| 37 | FGroupBy: string; | 
|---|
| 38 | FTreeAscending: Boolean; | 
|---|
| 39 | FCurrentContext: TSurgCaseContext; | 
|---|
| 40 | end; | 
|---|
| 41 |  | 
|---|
| 42 | function SelectSurgeryView(FontSize: Integer; ShowForm: Boolean; CurrentContext: TSurgCaseContext; | 
|---|
| 43 | var SurgeryContext: TSurgCaseContext): boolean ; | 
|---|
| 44 |  | 
|---|
| 45 | implementation | 
|---|
| 46 |  | 
|---|
| 47 | {$R *.DFM} | 
|---|
| 48 |  | 
|---|
| 49 | uses rCore, uCore; | 
|---|
| 50 |  | 
|---|
| 51 | const | 
|---|
| 52 | TX_DATE_ERR = 'Enter valid beginning and ending dates or press Cancel.'; | 
|---|
| 53 | TX_DATE_ERR_CAP = 'Error in Date Range'; | 
|---|
| 54 |  | 
|---|
| 55 | function SelectSurgeryView(FontSize: Integer; ShowForm: Boolean; CurrentContext: TSurgCaseContext; | 
|---|
| 56 | var SurgeryContext: TSurgCaseContext): boolean ; | 
|---|
| 57 | var | 
|---|
| 58 | frmSurgeryView: TfrmSurgeryView; | 
|---|
| 59 | W, H: Integer; | 
|---|
| 60 | begin | 
|---|
| 61 | frmSurgeryView := TfrmSurgeryView.Create(Application); | 
|---|
| 62 | try | 
|---|
| 63 | with frmSurgeryView do | 
|---|
| 64 | begin | 
|---|
| 65 | Font.Size := FontSize; | 
|---|
| 66 | W := ClientWidth; | 
|---|
| 67 | H := ClientHeight; | 
|---|
| 68 | ResizeToFont(FontSize, W, H); | 
|---|
| 69 | ClientWidth  := W; pnlBase.Width  := W; | 
|---|
| 70 | ClientHeight := H; pnlBase.Height := H; | 
|---|
| 71 | FChanged := False; | 
|---|
| 72 | FCurrentContext := CurrentContext; | 
|---|
| 73 | calBeginDate.Text := CurrentContext.BeginDate; | 
|---|
| 74 | calEndDate.Text   := CurrentContext.EndDate; | 
|---|
| 75 | if calEndDate.Text = '' then calEndDate.Text := 'TODAY'; | 
|---|
| 76 | if CurrentContext.MaxDocs > 0 then | 
|---|
| 77 | edMaxDocs.Text :=  IntToStr(CurrentContext.MaxDocs) | 
|---|
| 78 | else | 
|---|
| 79 | edMaxDocs.Text := ''; | 
|---|
| 80 | FMaxDocs := StrToIntDef(edMaxDocs.Text, 0); | 
|---|
| 81 | radTreeSort.ItemIndex := 0; | 
|---|
| 82 | cboGroupBy.SelectByID(CurrentContext.GroupBy); | 
|---|
| 83 | if ShowForm then ShowModal else cmdOKClick(frmSurgeryView); | 
|---|
| 84 |  | 
|---|
| 85 | with SurgeryContext do | 
|---|
| 86 | begin | 
|---|
| 87 | Changed := FChanged; | 
|---|
| 88 | OpProc := FOpProc; | 
|---|
| 89 | BeginDate := FBeginDate; | 
|---|
| 90 | FMBeginDate := FFMBeginDate; | 
|---|
| 91 | EndDate := FEndDate; | 
|---|
| 92 | FMEndDate := FFMEndDate; | 
|---|
| 93 | MaxDocs := FMaxDocs; | 
|---|
| 94 | GroupBy := FGroupBy; | 
|---|
| 95 | TreeAscending := FTreeAscending; | 
|---|
| 96 | Result := Changed ; | 
|---|
| 97 | end; | 
|---|
| 98 |  | 
|---|
| 99 | end; {with frmSurgeryView} | 
|---|
| 100 | finally | 
|---|
| 101 | frmSurgeryView.Release; | 
|---|
| 102 | end; | 
|---|
| 103 | end; | 
|---|
| 104 |  | 
|---|
| 105 | procedure TfrmSurgeryView.cmdOKClick(Sender: TObject); | 
|---|
| 106 | var | 
|---|
| 107 | bdate, edate: TFMDateTime; | 
|---|
| 108 | begin | 
|---|
| 109 | if calBeginDate.Text <> '' then | 
|---|
| 110 | bdate := StrToFMDateTime(calBeginDate.Text) | 
|---|
| 111 | else | 
|---|
| 112 | bdate := 0 ; | 
|---|
| 113 |  | 
|---|
| 114 | if calEndDate.Text <> '' then | 
|---|
| 115 | edate   := StrToFMDateTime(calEndDate.Text) | 
|---|
| 116 | else | 
|---|
| 117 | edate := 0 ; | 
|---|
| 118 |  | 
|---|
| 119 | if (bdate <= edate) then | 
|---|
| 120 | begin | 
|---|
| 121 | FBeginDate := calBeginDate.Text; | 
|---|
| 122 | FFMBeginDate := bdate; | 
|---|
| 123 | FEndDate := calEndDate.Text; | 
|---|
| 124 | FFMEndDate := edate; | 
|---|
| 125 | end | 
|---|
| 126 | else | 
|---|
| 127 | begin | 
|---|
| 128 | InfoBox(TX_DATE_ERR, TX_DATE_ERR_CAP, MB_OK or MB_ICONWARNING); | 
|---|
| 129 | Exit; | 
|---|
| 130 | end; | 
|---|
| 131 |  | 
|---|
| 132 | FTreeAscending := (radTreeSort.ItemIndex = 0); | 
|---|
| 133 | FMaxDocs := StrToIntDef(edMaxDocs.Text, 0); | 
|---|
| 134 | if cboGroupBy.ItemID <> '' then | 
|---|
| 135 | FGroupBy := cboGroupBy.ItemID | 
|---|
| 136 | else | 
|---|
| 137 | FGroupBy := ''; | 
|---|
| 138 | FChanged := True; | 
|---|
| 139 | Close; | 
|---|
| 140 | end; | 
|---|
| 141 |  | 
|---|
| 142 | procedure TfrmSurgeryView.cmdCancelClick(Sender: TObject); | 
|---|
| 143 | begin | 
|---|
| 144 | FChanged := False; | 
|---|
| 145 | Close; | 
|---|
| 146 | end; | 
|---|
| 147 |  | 
|---|
| 148 | procedure TfrmSurgeryView.cmdClearClick(Sender: TObject); | 
|---|
| 149 | begin | 
|---|
| 150 | cboGroupBy.ItemIndex := -1; | 
|---|
| 151 | radTreeSort.ItemIndex := 0; | 
|---|
| 152 | end; | 
|---|
| 153 |  | 
|---|
| 154 | end. | 
|---|