source: cprs/trunk/CPRS-Chart/Options/fOptionsNotes.pas@ 1736

Last change on this file since 1736 was 1679, checked in by healthsevak, 10 years ago

Updating the working copy to CPRS version 28

File size: 5.6 KB
Line 
1unit fOptionsNotes;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ExtCtrls, ORCtrls, ORFn, ComCtrls, fBase508Form,
8 VA508AccessibilityManager;
9
10type
11 TfrmOptionsNotes = class(TfrmBase508Form)
12 lblAutoSave1: TLabel;
13 lblCosigner: TLabel;
14 txtAutoSave: TCaptionEdit;
15 spnAutoSave: TUpDown;
16 chkVerifyNote: TCheckBox;
17 chkAskSubject: TCheckBox;
18 cboCosigner: TORComboBox;
19 pnlBottom: TPanel;
20 bvlBottom: TBevel;
21 btnOK: TButton;
22 btnCancel: TButton;
23 lblAutoSave2: TLabel;
24 procedure FormShow(Sender: TObject);
25 procedure btnOKClick(Sender: TObject);
26 procedure txtAutoSaveChange(Sender: TObject);
27 procedure txtAutoSaveKeyPress(Sender: TObject; var Key: Char);
28 procedure txtAutoSaveExit(Sender: TObject);
29 procedure spnAutoSaveClick(Sender: TObject; Button: TUDBtnType);
30 procedure cboCosignerNeedData(Sender: TObject; const StartFrom: String;
31 Direction, InsertAt: Integer);
32 procedure cboCosignerExit(Sender: TObject);
33 private
34 FStartingCosigner: Int64;
35 { Private declarations }
36 public
37 { Public declarations }
38 end;
39
40var
41 frmOptionsNotes: TfrmOptionsNotes;
42
43procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
44
45implementation
46
47{$R *.DFM}
48
49uses
50 rOptions, uOptions, rCore, rTIU, rDCSumm;
51
52procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
53// create the form and make it modal, return an action
54var
55 frmOptionsNotes: TfrmOptionsNotes;
56begin
57 frmOptionsNotes := TfrmOptionsNotes.Create(Application);
58 actiontype := 0;
59 try
60 with frmOptionsNotes do
61 begin
62 if (topvalue < 0) or (leftvalue < 0) then
63 Position := poScreenCenter
64 else
65 begin
66 Position := poDesigned;
67 Top := topvalue;
68 Left := leftvalue;
69 end;
70 ResizeAnchoredFormToFont(frmOptionsNotes);
71 ShowModal;
72 actiontype := btnOK.Tag;
73 end;
74 finally
75 frmOptionsNotes.Release;
76 end;
77end;
78
79procedure TfrmOptionsNotes.FormShow(Sender: TObject);
80// displays defaults
81// opening tab^use last tab^autosave seconds^verify note title
82var
83 autosave, verify: integer;
84 cosigner: Int64;
85 values, cosignername: string;
86begin
87 values := rpcGetOther;
88 autosave := strtointdef(Piece(values, '^', 3), -1);
89 verify := strtointdef(Piece(values, '^', 4), 0);
90 chkVerifyNote.Checked := verify = 1;
91 chkVerifyNote.Tag := verify;
92 spnAutoSave.Position := autosave;
93 spnAutoSave.Tag := autosave;
94
95 values := rpcGetDefaultCosigner;
96 cosigner := strtoint64def(Piece(values, '^', 1), 0);
97 cosignername := Piece(values, '^', 2);
98 cboCosigner.Items.Add('0^<none>');
99 cboCosigner.InitLongList(cosignername);
100 cboCosigner.SelectByIEN(cosigner);
101 FStartingCosigner := cosigner;
102 chkAskSubject.Checked := rpcGetSubject;
103 if chkAskSubject.Checked then chkAskSubject.Tag := 1;
104end;
105
106procedure TfrmOptionsNotes.btnOKClick(Sender: TObject);
107// only saves values if they have been changed
108// opening tab^use last tab^autosave seconds^verify note title
109var
110 values: string;
111begin
112 values := '';
113 values := values + '^';
114 values := values + '^';
115 if spnAutoSave.Position <> spnAutoSave.Tag then
116 values := values + inttostr(spnAutoSave.Position);
117 values := values + '^';
118 if chkVerifyNote.Checked then
119 if chkVerifyNote.Tag <> 1 then
120 values := values + '1';
121 if not chkVerifyNote.Checked then
122 if chkVerifyNote.Tag <> 0 then
123 values := values + '0';
124 rpcSetOther(values);
125 with chkAskSubject do
126 if (Checked and (Tag = 0)) or (not Checked and (Tag = 1)) then
127 rpcSetSubject(Checked);
128 with cboCosigner do
129 if FStartingCosigner <> ItemIEN then
130 rpcSetDefaultCosigner(ItemIEN);
131 ResetTIUPreferences;
132 ResetDCSummPreferences;
133end;
134
135procedure TfrmOptionsNotes.txtAutoSaveChange(Sender: TObject);
136var
137 maxvalue: integer;
138begin
139 maxvalue := spnAutoSave.Max;
140 with txtAutoSave do
141 begin
142 if strtointdef(Text, maxvalue) > maxvalue then
143 begin
144 beep;
145 InfoBox('Number must be < ' + inttostr(maxvalue), 'Warning', MB_OK or MB_ICONWARNING);
146 if strtointdef(Text, 0) > maxvalue then
147 Text := inttostr(maxvalue);
148 end;
149 end;
150 spnAutoSaveClick(self, btNext);
151end;
152
153procedure TfrmOptionsNotes.txtAutoSaveKeyPress(Sender: TObject;
154 var Key: Char);
155begin
156 if Key = #13 then
157 begin
158 Perform(WM_NextDlgCtl, 0, 0);
159 exit;
160 end;
161 if not (Key in ['0'..'9', #8]) then
162 begin
163 Key := #0;
164 beep;
165 end;
166end;
167
168procedure TfrmOptionsNotes.txtAutoSaveExit(Sender: TObject);
169begin
170 with txtAutoSave do
171 begin
172 if Text = '' then
173 begin
174 Text := '0';
175 spnAutoSaveClick(self, btNext);
176 end
177 else if (Copy(Text, 1, 1) = '0') and (length(Text) > 1) then
178 begin
179 Text := inttostr(strtointdef(Text, 0));
180 spnAutoSaveClick(self, btNext);
181 end;
182 end;
183end;
184
185procedure TfrmOptionsNotes.spnAutoSaveClick(Sender: TObject;
186 Button: TUDBtnType);
187begin
188 txtAutoSave.SetFocus;
189 txtAutoSave.Tag := strtointdef(txtAutoSave.Text, 0);
190end;
191
192procedure TfrmOptionsNotes.cboCosignerNeedData(Sender: TObject;
193 const StartFrom: String; Direction, InsertAt: Integer);
194begin
195 cboCosigner.ForDataUse(rpcGetCosigners(StartFrom, Direction));
196end;
197
198procedure TfrmOptionsNotes.cboCosignerExit(Sender: TObject);
199begin
200 with cboCosigner do
201 if (Text = '') or (ItemIndex = -1) then
202 begin
203 ItemIndex := 0;
204 Text := DisplayText[0];
205 end;
206end;
207
208end.
Note: See TracBrowser for help on using the repository browser.