source: cprs/branches/HealthSevak-CPRS/CPRS-Chart/fAlertForward.pas@ 1702

Last change on this file since 1702 was 830, checked in by Kevin Toppenberg, 14 years ago

Upgrading to version 27

File size: 5.3 KB
Line 
1unit fAlertForward;
2
3interface
4
5uses Windows, Messages, SysUtils, Classes, Graphics, Forms, Controls,
6 Dialogs, StdCtrls, Buttons, ORCtrls, ORfn, ExtCtrls, fAutoSz, ComCtrls, fBase508Form,
7 VA508AccessibilityManager;
8
9type
10 TfrmAlertForward = class(TfrmBase508Form)
11 cmdOK: TButton;
12 cmdCancel: TButton;
13 cboSrcList: TORComboBox;
14 DstList: TORListBox;
15 SrcLabel: TLabel;
16 DstLabel: TLabel;
17 pnlBase: TORAutoPanel;
18 memAlert: TMemo;
19 Label1: TLabel;
20 memComment: TMemo;
21 btnAddAlert: TButton;
22 btnRemoveAlertFwrd: TButton;
23 btnRemoveAllAlertFwrd: TButton;
24 procedure btnRemoveAlertFwrdClick(Sender: TObject);
25 procedure btnAddAlertClick(Sender: TObject);
26 procedure cboSrcListNeedData(Sender: TObject; const StartFrom: String;
27 Direction, InsertAt: Integer);
28 procedure cmdOKClick(Sender: TObject);
29 procedure cmdCancelClick(Sender: TObject);
30 procedure cboSrcListKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
31 procedure cboSrcListMouseClick(Sender: TObject);
32 procedure FormCreate(Sender: TObject);
33 procedure cboSrcListChange(Sender: TObject);
34 procedure DstListChange(Sender: TObject);
35 procedure btnRemoveAllAlertFwrdClick(Sender: TObject);
36 private
37 RemovingAll: boolean;
38 end;
39
40function ForwardAlertTo(Alert: String): Boolean;
41
42
43implementation
44
45{$R *.DFM}
46
47uses rCore, uCore, VA508AccessibilityRouter;
48
49const
50 TX_DUP_RECIP = 'You have already selected that recipient.';
51 TX_RECIP_CAP = 'Error adding recipient';
52
53var XQAID: string;
54
55function ForwardAlertTo(Alert: String): Boolean;
56var
57 frmAlertForward: TfrmAlertForward;
58begin
59 frmAlertForward := TfrmAlertForward.Create(Application);
60 try
61 ResizeAnchoredFormToFont(frmAlertForward);
62 with frmAlertForward do
63 begin
64 memAlert.SetTextBuf(PChar(Piece(Alert, U, 2)));
65 XQAID := Piece(Alert, U, 1);
66 ShowModal;
67 end;
68 finally
69 frmAlertForward.Release;
70 Result := True;
71 end;
72end;
73
74procedure TfrmAlertForward.FormCreate(Sender: TObject);
75begin
76 inherited;
77 if ScreenReaderSystemActive then
78 memAlert.TabStop := TRUE;
79 cboSrcList.InitLongList('');
80end;
81
82procedure TfrmAlertForward.cboSrcListNeedData(Sender: TObject;
83 const StartFrom: String; Direction, InsertAt: Integer);
84begin
85 (Sender as TORComboBox).ForDataUse(SubSetOfPersons(StartFrom, Direction));
86end;
87
88procedure TfrmAlertForward.cmdCancelClick(Sender: TObject);
89begin
90 Close;
91end;
92
93procedure TfrmAlertForward.cmdOKClick(Sender: TObject);
94var
95 i: integer ;
96 Recip: string;
97begin
98
99 for i := 0 to DstList.Items.Count-1 do
100 begin
101 Recip := Piece(DstList.Items[i], U, 1);
102 memComment.Text := StringReplace(memComment.Text, CRLF, ' ', [rfReplaceAll]);
103 ForwardAlert(XQAID, Recip, 'A', memComment.Text);
104 end;
105 Close;
106end;
107
108procedure TfrmAlertForward.DstListChange(Sender: TObject);
109var
110 HasFocus: boolean;
111begin
112 inherited;
113 if DstList.SelCount = 1 then
114 if Piece(DstList.Items[0], '^', 1) = '' then
115 begin
116 btnRemoveAlertFwrd.Enabled := false;
117 btnRemoveAllAlertFwrd.Enabled := false;
118 exit;
119 end;
120 HasFocus := btnRemoveAlertFwrd.Focused;
121 if Not HasFocus then
122 HasFocus := btnRemoveAllAlertFwrd.Focused;
123 btnRemoveAlertFwrd.Enabled := DstList.SelCount > 0;
124 btnRemoveAllAlertFwrd.Enabled := DstList.Items.Count > 0;
125 if HasFocus and (DstList.SelCount = 0) then
126 btnAddAlert.SetFocus;
127end;
128
129procedure TfrmAlertForward.btnAddAlertClick(Sender: TObject);
130begin
131 inherited;
132 cboSrcListMouseClick(btnAddAlert);
133end;
134
135procedure TfrmAlertForward.btnRemoveAlertFwrdClick(Sender: TObject);
136var
137 i: integer;
138begin
139 with DstList do
140 begin
141 if ItemIndex = -1 then exit ;
142 for i := Items.Count-1 downto 0 do
143 if Selected[i] then
144 begin
145 if ScreenReaderSystemActive and (not RemovingAll) then
146 GetScreenReader.Speak(Piece(DstList.Items[i],U,2) +
147 ' Removed from ' + DstLabel.Caption);
148 Items.Delete(i) ;
149 end;
150 end;
151end;
152
153procedure TfrmAlertForward.btnRemoveAllAlertFwrdClick(Sender: TObject);
154begin
155 inherited;
156 DstList.SelectAll;
157 RemovingAll := TRUE;
158 try
159 btnRemoveAlertFwrdClick(self);
160 if ScreenReaderSystemActive then
161 GetScreenReader.Speak(DstLabel.Caption + ' Cleared');
162 finally
163 RemovingAll := FALSE;
164 end;
165end;
166
167procedure TfrmAlertForward.cboSrcListChange(Sender: TObject);
168begin
169 inherited;
170 btnAddAlert.Enabled := CboSrcList.ItemIndex > -1;
171end;
172
173procedure TfrmAlertForward.cboSrcListKeyDown(Sender: TObject; var Key: Word;
174 Shift: TShiftState);
175begin
176 if Key = VK_RETURN then
177 begin
178 cboSrcListMouseClick(Self);
179 end;
180end;
181
182procedure TfrmAlertForward.cboSrcListMouseClick(Sender: TObject);
183begin
184 if cboSrcList.ItemIndex = -1 then exit;
185 if (DstList.SelectByID(cboSrcList.ItemID) <> -1) then
186 begin
187 InfoBox(TX_DUP_RECIP, TX_RECIP_CAP, MB_OK or MB_ICONWARNING);
188 Exit;
189 end;
190 DstList.Items.Add(cboSrcList.Items[cboSrcList.Itemindex]);
191 if ScreenReaderSystemActive then
192 GetScreenReader.Speak(Piece(cboSrcList.Items[cboSrcList.Itemindex],U,2) +
193 ' Added to ' + DstLabel.Caption);
194 btnRemoveAlertFwrd.Enabled := DstList.SelCount > 0;
195 btnRemoveAllAlertFwrd.Enabled := DstList.Items.Count > 0;
196end;
197
198end.
Note: See TracBrowser for help on using the repository browser.