source: cprs/trunk/CPRS-Chart/Consults/fConsultBSt.pas@ 463

Last change on this file since 463 was 456, checked in by Kevin Toppenberg, 16 years ago

Initial Upload of Official WV CPRS 1.0.26.76

File size: 3.3 KB
RevLine 
[456]1unit fConsultBSt;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 ExtCtrls, ORCtrls, StdCtrls, ORFn, uConsults;
8
9type
10 TfrmConsultsByStatus = class(TForm)
11 pnlBase: TORAutoPanel;
12 lblStatus: TLabel;
13 radSort: TRadioGroup;
14 lstStatus: TORListBox;
15 cmdOK: TButton;
16 cmdCancel: TButton;
17 procedure cmdCancelClick(Sender: TObject);
18 procedure cmdOKClick(Sender: TObject);
19 private
20 FChanged: Boolean;
21 FStatus: string;
22 FStatusName: string;
23 FAscending: Boolean;
24 end;
25
26 TStatusContext = record
27 Changed: Boolean;
28 Status: string;
29 StatusName: string;
30 Ascending: Boolean;
31 end;
32
33function SelectStatus(FontSize: Integer; CurrentContext: TSelectContext; var StatusContext: TStatusContext): boolean ;
34
35implementation
36
37{$R *.DFM}
38
39uses rConsults, rCore, uCore;
40
41const
42 TX_STAT_TEXT = 'Select a consult status or press Cancel.';
43 TX_STAT_CAP = 'Missing Status';
44
45function SelectStatus(FontSize: Integer; CurrentContext: TSelectContext; var StatusContext: TStatusContext): boolean ;
46{ displays Status select form for consults and returns a record of the selection }
47var
48 frmConsultsByStatus: TfrmConsultsByStatus;
49 W, H, i, j: Integer;
50 CurrentStatus: string;
51begin
52 frmConsultsByStatus := TfrmConsultsByStatus.Create(Application);
53 try
54 with frmConsultsByStatus do
55 begin
56 Font.Size := FontSize;
57 W := ClientWidth;
58 H := ClientHeight;
59 ResizeToFont(FontSize, W, H);
60 ClientWidth := W; pnlBase.Width := W;
61 ClientHeight := H; pnlBase.Height := H;
62 FChanged := False;
63 with radSort do {if SortConsultsAscending then ItemIndex := 0 else} ItemIndex := 1;
64 lstStatus.Items.Assign(SubSetOfStatus);
65 CurrentStatus := CurrentContext.Status;
66 if CurrentStatus <> '' then with lstStatus do
67 begin
68 i := 1;
69 while Piece(CurrentStatus, ',', i) <> '' do
70 begin
71 j := SelectByID(Piece(CurrentStatus, ',', i));
72 if j > -1 then Selected[j] := True;
73 Inc(i);
74 end;
75 end;
76 ShowModal;
77 with StatusContext do
78 begin
79 Changed := FChanged;
80 Status := FStatus;
81 StatusName := FStatusName;
82 Ascending := FAscending;
83 Result := Changed ;
84 end; {with StatusContext}
85 end; {with frmConsultsByStatus}
86 finally
87 frmConsultsByStatus.Release;
88 end;
89end;
90
91procedure TfrmConsultsByStatus.cmdCancelClick(Sender: TObject);
92begin
93 Close;
94end;
95
96procedure TfrmConsultsByStatus.cmdOKClick(Sender: TObject);
97var
98 i: integer;
99begin
100 if lstStatus.SelCount = 0 then
101 begin
102 InfoBox(TX_STAT_TEXT, TX_STAT_CAP, MB_OK or MB_ICONWARNING);
103 Exit;
104 end;
105 FChanged := True;
106 with lstStatus do for i := 0 to Items.Count-1 do if Selected[i] then
107 begin
108 if Piece(Items[i], U, 1) <> '999' then
109 FStatus := FStatus + Piece(Items[i], U, 1) + ','
110 else
111 FStatus := FStatus + Piece(Items[i],U,3) ;
112 FStatusName := FStatusName + DisplayText[i] + ',' ;
113 end;
114 FStatus := Copy(FStatus, 1, Length(FStatus)-1);
115 FStatusName := Copy(FStatusName, 1, Length(FStatusName)-1);
116 FAscending := radSort.ItemIndex = 0;
117 Close;
118end;
119
120end.
Note: See TracBrowser for help on using the repository browser.