[453] | 1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
| 2 | unit fOptionsReportsCustom;
|
---|
| 3 |
|
---|
| 4 | interface
|
---|
| 5 |
|
---|
| 6 | uses
|
---|
| 7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 8 | StdCtrls, ExtCtrls, Spin, ORCtrls, fOptions, ComCtrls, ORFn, ORNet, Grids, uConst,
|
---|
| 9 | ORDtTm, rCore, DKLang;
|
---|
| 10 |
|
---|
| 11 | type
|
---|
| 12 | TfrmOptionsReportsCustom = class(TForm)
|
---|
| 13 | Panel1: TPanel;
|
---|
| 14 | Bevel3: TBevel;
|
---|
| 15 | btnApply: TButton;
|
---|
| 16 | btnCancel: TButton;
|
---|
| 17 | Panel2: TPanel;
|
---|
| 18 | grdReport: TCaptionStringGrid;
|
---|
| 19 | edtMax: TCaptionEdit;
|
---|
| 20 | odbStop: TORDateBox;
|
---|
| 21 | odbStart: TORDateBox;
|
---|
| 22 | odbTool: TORDateBox;
|
---|
| 23 | btnOK: TButton;
|
---|
| 24 | Panel3: TPanel;
|
---|
| 25 | edtSearch: TCaptionEdit;
|
---|
| 26 | Label1: TLabel;
|
---|
| 27 | DKLanguageController1: TDKLanguageController;
|
---|
| 28 | function ValFor(ACol, ARow: Integer): string;
|
---|
| 29 | procedure FormCreate(Sender: TObject);
|
---|
| 30 | procedure grdReportMouseDown(Sender: TObject; Button: TMouseButton;
|
---|
| 31 | Shift: TShiftState; X, Y: Integer);
|
---|
| 32 | procedure grdReportKeyPress(Sender: TObject; var Key: Char);
|
---|
| 33 | procedure grdReportDrawCell(Sender: TObject; ACol, ARow: Integer;
|
---|
| 34 | Rect: TRect; State: TGridDrawState);
|
---|
| 35 | procedure UMDelayEvent(var Message: TMessage); Message UM_DELAYEVENT;
|
---|
| 36 | procedure edtMaxExit(Sender: TObject);
|
---|
| 37 | procedure btnApplyClick(Sender: TObject);
|
---|
| 38 | procedure btnCancelClick(Sender: TObject);
|
---|
| 39 | procedure odbStartExit(Sender: TObject);
|
---|
| 40 | procedure odbStopExit(Sender: TObject);
|
---|
| 41 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 42 | procedure odbStartKeyPress(Sender: TObject; var Key: Char);
|
---|
| 43 | procedure odbStopKeyPress(Sender: TObject; var Key: Char);
|
---|
| 44 | procedure edtMaxKeyPress(Sender: TObject; var Key: Char);
|
---|
| 45 | procedure btnOKClick(Sender: TObject);
|
---|
| 46 | procedure edtSearchChange(Sender: TObject);
|
---|
| 47 | procedure edtSearchKeyPress(Sender: TObject; var Key: Char);
|
---|
| 48 | procedure FormShow(Sender: TObject);
|
---|
| 49 | procedure grdReportKeyDown(Sender: TObject; var Key: Word;
|
---|
| 50 | Shift: TShiftState);
|
---|
| 51 | procedure FormDestroy(Sender: TObject);
|
---|
| 52 | private
|
---|
| 53 | { Private declarations }
|
---|
| 54 | //startDate,endDate,
|
---|
| 55 | maxOcurs,signal: integer;
|
---|
| 56 | rptList: TStringList;
|
---|
| 57 | fDropColumn: Integer;
|
---|
| 58 | sDate,eDate: string;
|
---|
| 59 | procedure ShowEditor(ACol, ARow: Integer; AChar: Char);
|
---|
| 60 | public
|
---|
| 61 | { Public declarations }
|
---|
| 62 | end;
|
---|
| 63 | var
|
---|
| 64 | frmOptionsReportsCustom: TfrmOptionsReportsCustom;
|
---|
| 65 |
|
---|
| 66 | const
|
---|
| 67 | Col_StartDate = 1;
|
---|
| 68 | Col_StopDate = 2;
|
---|
| 69 | Col_Max = 3;
|
---|
| 70 | TAB = #9;
|
---|
| 71 |
|
---|
| 72 | procedure DialogOptionsHSCustom(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
|
---|
| 73 |
|
---|
| 74 | implementation
|
---|
| 75 |
|
---|
| 76 | uses rOptions, uOptions, fReports, uCore, uAccessibleStringGrid;
|
---|
| 77 |
|
---|
| 78 | {$R *.DFM}
|
---|
| 79 |
|
---|
| 80 | procedure TfrmOptionsReportsCustom.UMDelayEvent(var Message: TMessage);
|
---|
| 81 | { after focusing events are completed for a combobox, set the key the user typed }
|
---|
| 82 | begin
|
---|
| 83 | case Message.LParam of
|
---|
| 84 | Col_StartDate:
|
---|
| 85 | begin
|
---|
| 86 | odbStart.Visible := True;
|
---|
| 87 | odbStart.Text := Chr(Message.WParam);
|
---|
| 88 | end;
|
---|
| 89 | COL_StopDate :
|
---|
| 90 | begin
|
---|
| 91 | odbStop.Visible := True;
|
---|
| 92 | odbStop.Text := Chr(Message.WParam);
|
---|
| 93 | end;
|
---|
| 94 | COL_Max :
|
---|
| 95 | begin
|
---|
| 96 | edtMax.Visible := True;
|
---|
| 97 | edtMax.Text := Chr(Message.WParam);
|
---|
| 98 | end;
|
---|
| 99 | end;
|
---|
| 100 | end;
|
---|
| 101 |
|
---|
| 102 | procedure DialogOptionsHSCustom(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
|
---|
| 103 | var
|
---|
| 104 | frmOptionsReportsCustom: TfrmOptionsReportsCustom;
|
---|
| 105 | begin
|
---|
| 106 | frmOptionsReportsCustom := TfrmOptionsReportsCustom.Create(Application);
|
---|
| 107 | actiontype := 0;
|
---|
| 108 | try
|
---|
| 109 | with frmOptionsReportsCustom do
|
---|
| 110 | begin
|
---|
| 111 | if (topvalue < 0) or (leftvalue < 0) then
|
---|
| 112 | Position := poScreenCenter
|
---|
| 113 | else
|
---|
| 114 | begin
|
---|
| 115 | Position := poDesigned;
|
---|
| 116 | Top := topvalue;
|
---|
| 117 | Left := leftvalue;
|
---|
| 118 | end;
|
---|
| 119 | ResizeAnchoredFormToFont(frmOptionsReportsCustom);
|
---|
| 120 | ShowModal;
|
---|
| 121 | actiontype := btnApply.Tag;
|
---|
| 122 | end;
|
---|
| 123 | finally
|
---|
| 124 | frmOptionsReportsCustom.Release;
|
---|
| 125 | end;
|
---|
| 126 | end;
|
---|
| 127 |
|
---|
| 128 | procedure TfrmOptionsReportsCustom.FormCreate(Sender: TObject);
|
---|
| 129 | begin
|
---|
| 130 | rptList := TStringList.Create;
|
---|
| 131 | TAccessibleStringGrid.WrapControl(grdReport);
|
---|
| 132 | end;
|
---|
| 133 |
|
---|
| 134 | procedure TfrmOptionsReportsCustom.ShowEditor(ACol, ARow: Integer; AChar: Char);
|
---|
| 135 |
|
---|
| 136 | procedure PlaceControl(AControl: TWinControl);
|
---|
| 137 | var
|
---|
| 138 | ARect: TRect;
|
---|
| 139 | begin
|
---|
| 140 | with AControl do
|
---|
| 141 | begin
|
---|
| 142 | ARect := grdReport.CellRect(ACol, ARow);
|
---|
| 143 | SetBounds(ARect.Left + grdReport.Left + 2, ARect.Top + grdReport.Top + 2,
|
---|
| 144 | ARect.Right - ARect.Left - 1 , ARect.Bottom-ARect.Top -1 );
|
---|
| 145 | Visible := True;
|
---|
| 146 | Tag := ARow;
|
---|
| 147 | BringToFront;
|
---|
| 148 | Show;
|
---|
| 149 | SetFocus;
|
---|
| 150 | end;
|
---|
| 151 | end;
|
---|
| 152 | procedure Synch(AEdit: TEdit; const edtText: string);
|
---|
| 153 | begin
|
---|
| 154 | AEdit.Text := edtText;
|
---|
| 155 | AEdit.SelectAll;
|
---|
| 156 | end;
|
---|
| 157 | begin
|
---|
| 158 | inherited;
|
---|
| 159 | if ARow = 0 then Exit; //header row
|
---|
| 160 | with grdReport do if (ARow = Pred(RowCount)) and (ACol > 4 ) then Exit;
|
---|
| 161 | case ACol of
|
---|
| 162 | Col_StartDate: begin
|
---|
| 163 | if (ARow > 0 ) then
|
---|
| 164 | begin
|
---|
| 165 | PlaceControl(odbStart);
|
---|
| 166 | Synch(odbStart,ValFor(Col_StartDate,ARow));
|
---|
| 167 | if AChar <> #0 then PostMessage(Handle, UM_DELAYEVENT, Ord(AChar), COL_StartDate);
|
---|
| 168 | end;
|
---|
| 169 | end;
|
---|
| 170 | Col_StopDate: begin
|
---|
| 171 | if (ARow > 0 ) then
|
---|
| 172 | begin
|
---|
| 173 | PlaceControl(odbStop);
|
---|
| 174 | Synch(odbStop, ValFor(Col_StopDate,ARow));
|
---|
| 175 | if AChar <> #0 then PostMessage(Handle, UM_DELAYEVENT, Ord(AChar), COL_StopDate);
|
---|
| 176 | end;
|
---|
| 177 | end;
|
---|
| 178 | Col_Max: begin
|
---|
| 179 | if (ARow > 0 ) and (StrToInt(ValFor(Col_Max,ARow)) > 0) then
|
---|
| 180 | begin
|
---|
| 181 | PlaceControl(edtMax);
|
---|
| 182 | Synch(edtMax, ValFor(Col_Max,ARow));
|
---|
| 183 | fDropColumn := Col_Max;
|
---|
| 184 | if AChar <> #0 then PostMessage(Handle, UM_DELAYEVENT, Ord(AChar), COL_Max);
|
---|
| 185 | end;
|
---|
| 186 | end;
|
---|
| 187 | end;
|
---|
| 188 | end;
|
---|
| 189 |
|
---|
| 190 | function TfrmOptionsReportsCustom.ValFor(ACol, ARow: Integer): string;
|
---|
| 191 | begin
|
---|
| 192 | Result := grdReport.Cells[ACol, ARow];
|
---|
| 193 | end;
|
---|
| 194 |
|
---|
| 195 | procedure TfrmOptionsReportsCustom.grdReportKeyPress(Sender: TObject;
|
---|
| 196 | var Key: Char);
|
---|
| 197 | begin
|
---|
| 198 | inherited;
|
---|
| 199 | if grdReport.Col = 1 then
|
---|
| 200 | sDate := grdReport.Cells[grdReport.Col,grdReport.Row];
|
---|
| 201 | if grdReport.Col = 2 then
|
---|
| 202 | eDate := grdReport.Cells[grdReport.Col,grdReport.Row];
|
---|
| 203 | if (grdReport.Col = 3) and (grdReport.Cells[grdReport.Col, grdReport.Row]='') then
|
---|
| 204 | Exit else if Length(grdReport.Cells[3, grdReport.Row]) > 0 then maxOcurs := StrToInt( grdReport.Cells[3,grdReport.Row]);
|
---|
| 205 | if Key = #13 then ShowEditor(grdReport.Col, grdReport.Row, #0);
|
---|
| 206 | if Key = #9 then
|
---|
| 207 | begin
|
---|
| 208 | odbStart.Visible := False;
|
---|
| 209 | odbStop.Visible := False;
|
---|
| 210 | edtMax.Visible := False;
|
---|
| 211 | ShowEditor(grdReport.Col, grdReport.Row, #0);
|
---|
| 212 | end;
|
---|
| 213 | if Key in [#32..#127] then ShowEditor(grdReport.Col, grdReport.Row, Key);
|
---|
| 214 | signal := 0;
|
---|
| 215 | end;
|
---|
| 216 |
|
---|
| 217 | procedure TfrmOptionsReportsCustom.grdReportMouseDown(Sender: TObject;
|
---|
| 218 | Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
---|
| 219 | var
|
---|
| 220 | ACol,ARow: integer;
|
---|
| 221 | begin
|
---|
| 222 | inherited;
|
---|
| 223 | if (not User.ToolsRptEdit) then // For users with Reports settings edit parameter not set.
|
---|
| 224 | begin
|
---|
| 225 | abort;
|
---|
| 226 | exit;
|
---|
| 227 | end;
|
---|
| 228 | grdReport.MouseToCell(X,Y,ACol,ARow);
|
---|
| 229 | if (ARow < 1) or (ACol < 1) then
|
---|
| 230 | begin
|
---|
| 231 | odbStop.Visible := False;
|
---|
| 232 | odbStart.Visible := False;
|
---|
| 233 | edtMax.Visible := False;
|
---|
| 234 | Exit;
|
---|
| 235 | end;
|
---|
| 236 | if ACol = 1 then
|
---|
| 237 | begin
|
---|
| 238 | odbStop.Visible := False;
|
---|
| 239 | edtMax.Visible := False;
|
---|
| 240 | sDate := grdReport.Cells[1,ARow];
|
---|
| 241 | ShowEditor(ACol, ARow, #0);
|
---|
| 242 | end;
|
---|
| 243 | if ACol = 2 then
|
---|
| 244 | begin
|
---|
| 245 | odbStart.Visible := False;
|
---|
| 246 | edtMax.Visible := False;
|
---|
| 247 | eDate := grdReport.Cells[2,ARow];
|
---|
| 248 | ShowEditor(ACol, ARow, #0);
|
---|
| 249 | end;
|
---|
| 250 | if (ACol = 3) and (grdReport.Cells[ACol,ARow]='') then
|
---|
| 251 | begin
|
---|
| 252 | odbStart.Visible := False;
|
---|
| 253 | odbStop.Visible := False;
|
---|
| 254 | Exit;
|
---|
| 255 | end
|
---|
| 256 | else if (ACol = 3) and (strtoint(grdReport.Cells[ACol,ARow])>0) then
|
---|
| 257 | begin
|
---|
| 258 | odbStart.Visible := False;
|
---|
| 259 | odbStop.Visible := False;
|
---|
| 260 | maxOcurs := strtoint(grdReport.Cells[ACol,ARow]);
|
---|
| 261 | ShowEditor(ACol, ARow, #0);
|
---|
| 262 | end
|
---|
| 263 | else
|
---|
| 264 | begin
|
---|
| 265 | grdReport.Col := 0;
|
---|
| 266 | grdReport.Row := ARow;
|
---|
| 267 | end;
|
---|
| 268 | signal := 0;
|
---|
| 269 | end;
|
---|
| 270 |
|
---|
| 271 | procedure TfrmOptionsReportsCustom.grdReportDrawCell(Sender: TObject; ACol,
|
---|
| 272 | ARow: Integer; Rect: TRect; State: TGridDrawState);
|
---|
| 273 | begin
|
---|
| 274 | inherited;
|
---|
| 275 | grdReport.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2,
|
---|
| 276 | Piece(grdReport.Cells[ACol, ARow], TAB, 1));
|
---|
| 277 |
|
---|
| 278 | end;
|
---|
| 279 |
|
---|
| 280 | procedure TfrmOptionsReportsCustom.edtMaxExit(Sender: TObject);
|
---|
| 281 | var
|
---|
| 282 | newValue: String;
|
---|
| 283 | code, I: integer;
|
---|
| 284 | begin
|
---|
| 285 | if edtMax.Modified then
|
---|
| 286 | begin
|
---|
| 287 | newValue := edtMax.Text;
|
---|
| 288 | if length(newValue) = 0 then
|
---|
| 289 | begin
|
---|
| 290 | // InfoBox('Invalid value of max occurences', 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
| 291 | InfoBox(DKLangConstW('fOptionsReportsCustom_Invalid_value_of_max_occurences'), DKLangConstW('fOptionsReportsCustom_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
| 292 | edtMax.Text := IntToStr(maxOcurs);
|
---|
| 293 | edtMax.SetFocus;
|
---|
| 294 | edtMax.SelectAll;
|
---|
| 295 | end;
|
---|
| 296 | if length(newValue) > 0 then
|
---|
| 297 | begin
|
---|
| 298 | Val(newValue, I, code);
|
---|
| 299 | if I = 0 then begin end; //added to keep compiler from generating a hint
|
---|
| 300 | if code <> 0 then
|
---|
| 301 | begin
|
---|
| 302 | // InfoBox('Invalid value of max occurences', 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
| 303 | InfoBox(DKLangConstW('fOptionsReportsCustom_Invalid_value_of_max_occurences'), DKLangConstW('fOptionsReportsCustom_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
| 304 | edtMax.Text := IntToStr(maxOcurs);
|
---|
| 305 | edtMax.SetFocus;
|
---|
| 306 | edtMax.SelectAll;
|
---|
| 307 | end;
|
---|
| 308 | if code = 0 then
|
---|
| 309 | begin
|
---|
| 310 | if strtoint(edtMax.Text) <= 0 then
|
---|
| 311 | begin
|
---|
| 312 | // InfoBox('the value of max should be greater than 0', 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
| 313 | InfoBox(DKLangConstW('fOptionsReportsCustom_the_value_of_max_should_be_greater_than_0'), DKLangConstW('fOptionsReportsCustom_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
| 314 | edtMax.Text := intToStr(maxOcurs);
|
---|
| 315 | edtMax.SetFocus;
|
---|
| 316 | edtMax.SelectAll;
|
---|
| 317 | exit;
|
---|
| 318 | end;
|
---|
| 319 | grdReport.Cells[Col_Max, edtMax.Tag] := edtMax.Text;
|
---|
| 320 | if compareStr(Piece(Piece(grdReport.Cells[0,edtMax.Tag],TAB,2),'^',2),'M')=0 then
|
---|
| 321 | begin
|
---|
| 322 | edtMax.Visible := False;
|
---|
| 323 | btnApply.Enabled := True;
|
---|
| 324 | Exit;
|
---|
| 325 | end;
|
---|
| 326 | grdReport.Cells[0,edtMax.Tag] := grdReport.Cells[0,edtMax.Tag] + '^M';
|
---|
| 327 | edtMax.Visible := False;
|
---|
| 328 | btnApply.Enabled := True;
|
---|
| 329 | end;
|
---|
| 330 | end;
|
---|
| 331 | end;
|
---|
| 332 | end;
|
---|
| 333 |
|
---|
| 334 | procedure TfrmOptionsReportsCustom.btnApplyClick(Sender: TObject);
|
---|
| 335 | var
|
---|
| 336 | valueStartdate, valueStopdate,valueMax, rpt, values,name: string;
|
---|
| 337 | i: integer;
|
---|
| 338 | begin
|
---|
| 339 | for i := 1 to grdReport.RowCount do
|
---|
| 340 | begin
|
---|
| 341 | if CompareStr(Piece(Piece( grdReport.Cells[0,i],TAB,2),'^',2),'M')=0 then
|
---|
| 342 | begin
|
---|
| 343 | rpt := Piece(Piece( grdReport.Cells[0,i],TAB,2),'^',1);
|
---|
| 344 | name := Piece( grdReport.Cells[0,i],TAB,1);
|
---|
| 345 | odbTool.Text := grdReport.Cells[1,i];
|
---|
| 346 | valueStartDate := odbTool.RelativeTime;
|
---|
| 347 | odbTool.Text := grdReport.Cells[2,i];
|
---|
| 348 | valueStopDate := odbTool.RelativeTime;
|
---|
| 349 | valueMax := grdReport.Cells[3,i];
|
---|
| 350 | if Length(valueMax)<1 then
|
---|
| 351 | valueMax := '7';
|
---|
| 352 | values := valueStartdate + ';' + valueStopDate + ';' + valueMax;
|
---|
| 353 | //{ if CompareStr(name,'Imaging (local only)')=0 then // imaging report id is hard coded to be 10000 <-- original line. //kt 8/8/2007
|
---|
| 354 | { if CompareStr(name,DKLangConstW('fOptionsReportsCustom_Imaging_xlocal_onlyx'))=0 then // imaging report id is hard coded to be 10000 //kt added 8/8/2007
|
---|
| 355 | values := valueStartdate + ';' + valueStopDate + ';;;' + valueMax
|
---|
| 356 | else}
|
---|
| 357 | rpcSetIndividualReportSetting(rpt, values);
|
---|
| 358 | end;
|
---|
| 359 | end;
|
---|
| 360 | btnApply.Enabled := False;
|
---|
| 361 | odbStart.Visible := False;
|
---|
| 362 | odbStop.Visible := False;
|
---|
| 363 | edtMax.Visible := False;
|
---|
| 364 | frmReports.LoadTreeView;
|
---|
| 365 | with frmReports.tvReports do
|
---|
| 366 | begin
|
---|
| 367 | if Items.Count > 0 then
|
---|
| 368 | Selected := Items.GetFirstNode;
|
---|
| 369 | frmReports.tvReportsClick(Selected);
|
---|
| 370 | end;
|
---|
| 371 | end;
|
---|
| 372 |
|
---|
| 373 | procedure TfrmOptionsReportsCustom.btnCancelClick(Sender: TObject);
|
---|
| 374 | begin
|
---|
| 375 | rptList.Clear;
|
---|
| 376 | Close;
|
---|
| 377 | end;
|
---|
| 378 |
|
---|
| 379 |
|
---|
| 380 | procedure TfrmOptionsReportsCustom.odbStartExit(Sender: TObject);
|
---|
| 381 | //const
|
---|
| 382 | //TX_BAD_START = 'The start date is not valid.'; <-- original line. //kt 8/8/2007
|
---|
| 383 | //TX_STOPSTART = 'The start date must not be after the stop date.'; <-- original line. //kt 8/8/2007
|
---|
| 384 | var
|
---|
| 385 | x,ErrMsg,datestart,datestop: String;
|
---|
| 386 | TX_BAD_START : string; //kt
|
---|
| 387 | TX_STOPSTART : string; //kt
|
---|
| 388 |
|
---|
| 389 | begin
|
---|
| 390 | TX_BAD_START := DKLangConstW('fOptionsReportsCustom_The_start_date_is_not_validx'); //kt added 8/8/2007
|
---|
| 391 | TX_STOPSTART := DKLangConstW('fOptionsReportsCustom_The_start_date_must_not_be_after_the_stop_datex'); //kt added 8/8/2007
|
---|
| 392 | if odbStart.text = '' then
|
---|
| 393 | begin
|
---|
| 394 | // InfoBox(TX_BAD_START, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
| 395 | InfoBox(TX_BAD_START, DKLangConstW('fOptionsReportsCustom_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
| 396 | odbStart.Visible := True;
|
---|
| 397 | odbStart.Text := sDate;
|
---|
| 398 | odbStart.Setfocus;
|
---|
| 399 | odbStart.SelectAll;
|
---|
| 400 | exit;
|
---|
| 401 | end;
|
---|
| 402 | if odbStart.Text = sDate then
|
---|
| 403 | exit;
|
---|
| 404 | ErrMsg := '';
|
---|
| 405 | odbStart.Validate(x);
|
---|
| 406 | if Length(x) > 0 then
|
---|
| 407 | begin
|
---|
| 408 | ErrMsg := TX_BAD_START;
|
---|
| 409 | // InfoBox(TX_BAD_START, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
| 410 | InfoBox(TX_BAD_START, DKLangConstW('fOptionsReportsCustom_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
| 411 | odbStart.Visible := True;
|
---|
| 412 | odbStart.Text := sDate;
|
---|
| 413 | odbStart.Setfocus;
|
---|
| 414 | odbStart.SelectAll;
|
---|
| 415 | exit;
|
---|
| 416 | end;
|
---|
| 417 | datestart := odbStart.RelativeTime;
|
---|
| 418 | datestop := MakeRelativeDateTime(
|
---|
| 419 | StrToFMDateTime(grdReport.Cells[Col_StopDate,odbStart.Tag])
|
---|
| 420 | );
|
---|
| 421 | delete(datestart,1,1);
|
---|
| 422 | delete(datestop,1,1);
|
---|
| 423 | if StrToIntDef(datestart,0)> StrToIntDef(datestop,0) then
|
---|
| 424 | begin
|
---|
| 425 | // InfoBox(TX_STOPSTART, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
| 426 | InfoBox(TX_STOPSTART, DKLangConstW('fOptionsReportsCustom_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
| 427 | odbStart.Text := grdReport.Cells[Col_StopDate,odbStart.Tag];
|
---|
| 428 | odbStart.SetFocus;
|
---|
| 429 | odbStart.SelectAll;
|
---|
| 430 | exit;
|
---|
| 431 | end;
|
---|
| 432 | grdReport.Cells[Col_StartDate, odbStart.Tag] := DateToStr(FMDateTimeToDateTime(odbStart.FMDateTime));
|
---|
| 433 | odbStart.Visible := False;
|
---|
| 434 | btnApply.Enabled := True;
|
---|
| 435 | if compareStr(Piece(Piece(grdReport.Cells[0,odbStart.Tag],TAB,2),'^',2),'M')=0 then
|
---|
| 436 | Exit;
|
---|
| 437 | grdReport.Cells[0,odbStart.Tag] := grdReport.Cells[0,odbStart.Tag] + '^M';
|
---|
| 438 | end;
|
---|
| 439 |
|
---|
| 440 | procedure TfrmOptionsReportsCustom.odbStopExit(Sender: TObject);
|
---|
| 441 | //const
|
---|
| 442 | //TX_BAD_STOP = 'The stop date is not valid.'; <-- original line. //kt 8/8/2007
|
---|
| 443 | //TX_BAD_ORDER = 'The stop date must not be earlier than start date.'; <-- original line. //kt 8/8/2007
|
---|
| 444 | var
|
---|
| 445 | x, ErrMsg,datestart,datestop: string;
|
---|
| 446 | TX_BAD_STOP : string; //kt
|
---|
| 447 | TX_BAD_ORDER : string; //kt
|
---|
| 448 | begin
|
---|
| 449 | TX_BAD_STOP := DKLangConstW('fOptionsReportsCustom_The_stop_date_is_not_validx'); //kt added 8/8/2007
|
---|
| 450 | TX_BAD_ORDER := DKLangConstW('fOptionsReportsCustom_The_stop_date_must_not_be_earlier_than_start_datex'); //kt added 8/8/2007
|
---|
| 451 | if odbStop.text = '' then
|
---|
| 452 | begin
|
---|
| 453 | // InfoBox(TX_BAD_STOP, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
| 454 | InfoBox(TX_BAD_STOP, DKLangConstW('fOptionsReportsCustom_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
| 455 | odbStop.Visible := True;
|
---|
| 456 | odbStop.Text := eDate;
|
---|
| 457 | odbStop.Setfocus;
|
---|
| 458 | odbStop.SelectAll;
|
---|
| 459 | exit;
|
---|
| 460 | end;
|
---|
| 461 |
|
---|
| 462 | if odbStop.Text = eDate then
|
---|
| 463 | exit;
|
---|
| 464 |
|
---|
| 465 | ErrMsg := '';
|
---|
| 466 | odbStop.Validate(x);
|
---|
| 467 | if Length(x) > 0 then
|
---|
| 468 | begin
|
---|
| 469 | ErrMsg := TX_BAD_STOP;
|
---|
| 470 | // InfoBox(TX_BAD_STOP, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
| 471 | InfoBox(TX_BAD_STOP, DKLangConstW('fOptionsReportsCustom_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
| 472 | odbStop.Visible := True;
|
---|
| 473 | odbStop.Text := eDate;
|
---|
| 474 | odbStop.Setfocus;
|
---|
| 475 | odbStop.SelectAll;
|
---|
| 476 | exit;
|
---|
| 477 | end;
|
---|
| 478 |
|
---|
| 479 | datestart := MakeRelativeDateTime(
|
---|
| 480 | StrToFMDateTime(grdReport.Cells[Col_StartDate,odbStop.Tag])
|
---|
| 481 | );
|
---|
| 482 | datestop := odbStop.RelativeTime;
|
---|
| 483 | delete(datestart,1,1);
|
---|
| 484 | delete(datestop,1,1);
|
---|
| 485 | if StrToIntDef(datestart,0)> StrToIntDef(datestop,0) then
|
---|
| 486 | begin
|
---|
| 487 | // InfoBox(TX_BAD_ORDER, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
| 488 | InfoBox(TX_BAD_ORDER, DKLangConstW('fOptionsReportsCustom_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
| 489 | odbStop.Text := grdReport.Cells[Col_StartDate,odbStop.Tag];
|
---|
| 490 | odbStop.SetFocus;
|
---|
| 491 | odbStop.SelectAll;
|
---|
| 492 | exit;
|
---|
| 493 | end;
|
---|
| 494 | grdReport.Cells[Col_StopDate, odbStop.Tag] := DateToStr(FMDateTimeToDateTime(odbStop.FMDateTime));
|
---|
| 495 | odbStop.Visible := False;
|
---|
| 496 | btnApply.Enabled := True;
|
---|
| 497 | if compareStr(Piece(Piece(grdReport.Cells[0,odbStop.Tag],TAB,2),'^',2),'M')=0 then
|
---|
| 498 | Exit;
|
---|
| 499 | grdReport.Cells[0,odbStop.Tag] := grdReport.Cells[0,odbStop.Tag] + '^M';
|
---|
| 500 | end;
|
---|
| 501 |
|
---|
| 502 |
|
---|
| 503 | procedure TfrmOptionsReportsCustom.FormClose(Sender: TObject;
|
---|
| 504 | var Action: TCloseAction);
|
---|
| 505 | begin
|
---|
| 506 | Close;
|
---|
| 507 | rptList.Clear;
|
---|
| 508 | end;
|
---|
| 509 |
|
---|
| 510 | procedure TfrmOptionsReportsCustom.odbStartKeyPress(Sender: TObject;
|
---|
| 511 | var Key: Char);
|
---|
| 512 | begin
|
---|
| 513 | if Key = #13 then
|
---|
| 514 | begin
|
---|
| 515 | odbStart.Visible := False;
|
---|
| 516 | Perform(WM_NextDlgCtl, 0, 0);
|
---|
| 517 | exit;
|
---|
| 518 | end;
|
---|
| 519 | end;
|
---|
| 520 |
|
---|
| 521 | procedure TfrmOptionsReportsCustom.odbStopKeyPress(Sender: TObject;
|
---|
| 522 | var Key: Char);
|
---|
| 523 | begin
|
---|
| 524 | if Key = #13 then
|
---|
| 525 | begin
|
---|
| 526 | odbStop.Visible := False;
|
---|
| 527 | Perform(WM_NextDlgCtl, 0, 0);
|
---|
| 528 | exit;
|
---|
| 529 | end;
|
---|
| 530 | end;
|
---|
| 531 |
|
---|
| 532 | procedure TfrmOptionsReportsCustom.edtMaxKeyPress(Sender: TObject;
|
---|
| 533 | var Key: Char);
|
---|
| 534 | begin
|
---|
| 535 | if Key = #13 then
|
---|
| 536 | begin
|
---|
| 537 | edtMax.Visible := False;
|
---|
| 538 | Perform(WM_NextDlgCtl, 0, 0);
|
---|
| 539 | exit;
|
---|
| 540 | end;
|
---|
| 541 | end;
|
---|
| 542 |
|
---|
| 543 | procedure TfrmOptionsReportsCustom.btnOKClick(Sender: TObject);
|
---|
| 544 | begin
|
---|
| 545 | if btnApply.Enabled then
|
---|
| 546 | btnApplyClick(self);
|
---|
| 547 | Close;
|
---|
| 548 | end;
|
---|
| 549 |
|
---|
| 550 | procedure TfrmOptionsReportsCustom.edtSearchChange(Sender: TObject);
|
---|
| 551 | var
|
---|
| 552 | i: integer;
|
---|
| 553 | needle,hay: String;
|
---|
| 554 | selRect: TGridRect;
|
---|
| 555 |
|
---|
| 556 | begin
|
---|
| 557 | if (edtSearch.Modified) and (signal=0) then
|
---|
| 558 | begin
|
---|
| 559 | needle := UpperCase(edtSearch.text);
|
---|
| 560 | if length(needle)=0 then
|
---|
| 561 | begin
|
---|
| 562 | selRect.Left := 0;
|
---|
| 563 | selRect.Top := 1;
|
---|
| 564 | selRect.Right := 0;
|
---|
| 565 | selRect.Bottom := 1;
|
---|
| 566 | grdReport.Selection := selRect;
|
---|
| 567 | grdReport.TopRow := 1;
|
---|
| 568 | exit;
|
---|
| 569 | end;
|
---|
| 570 | for i := 1 to grdReport.RowCount do
|
---|
| 571 | begin
|
---|
| 572 | hay := Piece(UpperCase(grdReport.Cells[0,i]),TAB,1);
|
---|
| 573 | hay := Copy(hay,0,length(needle));
|
---|
| 574 | if Pos(needle, hay) > 0 then
|
---|
| 575 | begin
|
---|
| 576 | selRect.Left := 0;
|
---|
| 577 | selRect.Top := i;
|
---|
| 578 | selRect.Right := 0;
|
---|
| 579 | selRect.Bottom := i;
|
---|
| 580 | grdReport.Selection := selRect;
|
---|
| 581 | grdReport.TopRow := i;
|
---|
| 582 | exit;
|
---|
| 583 | end;
|
---|
| 584 | end;
|
---|
| 585 | end;
|
---|
| 586 | if (edtSearch.Modified) and (signal=1) then
|
---|
| 587 | begin
|
---|
| 588 | signal := 0;
|
---|
| 589 | end;
|
---|
| 590 | Exit;
|
---|
| 591 | end;
|
---|
| 592 |
|
---|
| 593 | procedure TfrmOptionsReportsCustom.edtSearchKeyPress(Sender: TObject;
|
---|
| 594 | var Key: Char);
|
---|
| 595 | begin
|
---|
| 596 | if Key = #13 then
|
---|
| 597 | begin
|
---|
| 598 | Perform(WM_NextDlgCtl, 0, 0);
|
---|
| 599 | edtSearch.Text := '';
|
---|
| 600 | exit;
|
---|
| 601 | end;
|
---|
| 602 | end;
|
---|
| 603 |
|
---|
| 604 | procedure TfrmOptionsReportsCustom.FormShow(Sender: TObject);
|
---|
| 605 | var
|
---|
| 606 | i,rowNum: integer;
|
---|
| 607 | startOff,stopOff: string;
|
---|
| 608 | today: TFMDateTime;
|
---|
| 609 | begin
|
---|
| 610 | today := FMToday;
|
---|
| 611 | signal := 0;
|
---|
| 612 | rptList := TStringList.Create;
|
---|
| 613 | CallV('ORWTPD GETSETS',[nil]);
|
---|
| 614 | MixedCaseList( RPCBrokerV.Results );
|
---|
| 615 | rptList := TStringList(RPCBrokerV.Results);
|
---|
| 616 | SortByPiece(rptList,'^',2);
|
---|
| 617 | rowNum := rptList.Count;
|
---|
| 618 | grdReport.RowCount := rowNum + 1;
|
---|
| 619 | // grdReport.Cells[0,0] := 'Report Name'; <-- original line. //kt 8/8/2007
|
---|
| 620 | grdReport.Cells[0,0] := DKLangConstW('fOptionsReportsCustom_Report_Name'); //kt added 8/8/2007
|
---|
| 621 | // grdReport.Cells[1,0] := 'Start Date'; <-- original line. //kt 8/8/2007
|
---|
| 622 | grdReport.Cells[1,0] := DKLangConstW('fOptionsReportsCustom_Start_Date'); //kt added 8/8/2007
|
---|
| 623 | // grdReport.Cells[2,0] := 'Stop Date'; <-- original line. //kt 8/8/2007
|
---|
| 624 | grdReport.Cells[2,0] := DKLangConstW('fOptionsReportsCustom_Stop_Date'); //kt added 8/8/2007
|
---|
| 625 | // grdReport.Cells[3 ,0] := 'Max'; <-- original line. //kt 8/8/2007
|
---|
| 626 | grdReport.Cells[3 ,0] := DKLangConstW('fOptionsReportsCustom_Max'); //kt added 8/8/2007
|
---|
| 627 |
|
---|
| 628 | for i := 1 to grdReport.RowCount-1 do
|
---|
| 629 | begin
|
---|
| 630 | grdReport.Cells[0,i] := Piece(rptList[i-1],'^',2)+ TAB + Piece(rptList[i-1],'^',1);
|
---|
| 631 | startOff := Piece(Piece(rptList[i-1],'^',3),';',1);
|
---|
| 632 | stopOff := Piece(Piece(rptList[i-1],'^',3),';',2);
|
---|
| 633 | delete(startOff,1,1);
|
---|
| 634 | delete(stopOff,1,1);
|
---|
| 635 | grdReport.Cells[1,i] := DateToStr(FMDateTimeToDateTime(FMDateTimeOffsetBy(today, StrToIntDef(startOff,0))));
|
---|
| 636 | grdReport.Cells[2,i] := DateToStr(FMDateTimeToDateTime(FMDateTimeOffsetBy(today, StrToIntDef(stopOff,0))));
|
---|
| 637 | grdReport.Cells[3,i] := Piece(Piece(rptList[i-1],'^',3),';',3);
|
---|
| 638 | end;
|
---|
| 639 | if not edtSearch.Focused then
|
---|
| 640 | edtSearch.SetFocus;
|
---|
| 641 | // btnCancel.Caption := 'Cancel'; <-- original line. //kt 8/8/2007
|
---|
| 642 | btnCancel.Caption := DKLangConstW('fOptionsReportsCustom_Cancel'); //kt added 8/8/2007
|
---|
| 643 | if (not User.ToolsRptEdit) then // For users with Reports settings edit parameter not set.
|
---|
| 644 | begin
|
---|
| 645 | grdReport.onKeyPress := nil;
|
---|
| 646 | grdReport.onMouseDown := nil;
|
---|
| 647 | odbStart.readOnly := true;
|
---|
| 648 | odbStart.onExit := nil;
|
---|
| 649 | odbStart.onKeyPress := nil;
|
---|
| 650 | odbStop.readOnly := true;
|
---|
| 651 | odbStop.onExit := nil;
|
---|
| 652 | odbStop.onKeyPress := nil;
|
---|
| 653 | edtMax.readOnly := true;
|
---|
| 654 | odbTool.readOnly := true;
|
---|
| 655 | btnOK.visible := false;
|
---|
| 656 | btnApply.visible := false;
|
---|
| 657 | // btnCancel.Caption := 'Close'; <-- original line. //kt 8/8/2007
|
---|
| 658 | btnCancel.Caption := DKLangConstW('fOptionsReportsCustom_Close'); //kt added 8/8/2007
|
---|
| 659 | end;
|
---|
| 660 | end;
|
---|
| 661 |
|
---|
| 662 | procedure TfrmOptionsReportsCustom.grdReportKeyDown(Sender: TObject;
|
---|
| 663 | var Key: Word; Shift: TShiftState);
|
---|
| 664 | begin
|
---|
| 665 | if (Key = VK_TAB) then
|
---|
| 666 | begin
|
---|
| 667 | if ssShift in Shift then
|
---|
| 668 | begin
|
---|
| 669 | EdtSearch.SetFocus;
|
---|
| 670 | Key := 0;
|
---|
| 671 | end
|
---|
| 672 | else if ssCtrl in Shift then
|
---|
| 673 | begin
|
---|
| 674 | if User.ToolsRptEdit then
|
---|
| 675 | btnApply.SetFocus
|
---|
| 676 | else
|
---|
| 677 | btnCancel.SetFocus;
|
---|
| 678 | Key := 0;
|
---|
| 679 | end;
|
---|
| 680 | end;
|
---|
| 681 | if Key = VK_ESCAPE then begin
|
---|
| 682 | EdtSearch.SetFocus;
|
---|
| 683 | Key := 0;
|
---|
| 684 | end;
|
---|
| 685 | end;
|
---|
| 686 |
|
---|
| 687 | procedure TfrmOptionsReportsCustom.FormDestroy(Sender: TObject);
|
---|
| 688 | begin
|
---|
| 689 | TAccessibleStringGrid.UnwrapControl(grdReport);
|
---|
| 690 | end;
|
---|
| 691 |
|
---|
| 692 | end.
|
---|
| 693 |
|
---|