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