| 1 | unit fNoteBA;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|---|
| 7 | ExtCtrls, ORCtrls, StdCtrls, ORFn, uTIU;
|
|---|
| 8 |
|
|---|
| 9 | type
|
|---|
| 10 | TfrmNotesByAuthor = class(TForm)
|
|---|
| 11 | pnlBase: TORAutoPanel;
|
|---|
| 12 | lblAuthor: TLabel;
|
|---|
| 13 | radSort: TRadioGroup;
|
|---|
| 14 | cboAuthor: TORComboBox;
|
|---|
| 15 | cmdOK: TButton;
|
|---|
| 16 | cmdCancel: TButton;
|
|---|
| 17 | procedure cboAuthorNeedData(Sender: TObject; const StartFrom: string;
|
|---|
| 18 | Direction, InsertAt: Integer);
|
|---|
| 19 | procedure cmdCancelClick(Sender: TObject);
|
|---|
| 20 | procedure cmdOKClick(Sender: TObject);
|
|---|
| 21 | private
|
|---|
| 22 | FChanged: Boolean;
|
|---|
| 23 | FAuthor: Int64;
|
|---|
| 24 | FAuthorName: string;
|
|---|
| 25 | FAscending: Boolean;
|
|---|
| 26 | end;
|
|---|
| 27 |
|
|---|
| 28 | TAuthorContext = record
|
|---|
| 29 | Changed: Boolean;
|
|---|
| 30 | Author: Int64;
|
|---|
| 31 | AuthorName: string;
|
|---|
| 32 | Ascending: Boolean;
|
|---|
| 33 | end;
|
|---|
| 34 |
|
|---|
| 35 | procedure SelectAuthor(FontSize: Integer; CurrentContext: TTIUContext; var AuthorContext: TAuthorContext);
|
|---|
| 36 |
|
|---|
| 37 | implementation
|
|---|
| 38 |
|
|---|
| 39 | {$R *.DFM}
|
|---|
| 40 |
|
|---|
| 41 | uses rTIU, rCore, uCore;
|
|---|
| 42 |
|
|---|
| 43 | const
|
|---|
| 44 | TX_AUTH_TEXT = 'Select a progress note author or press Cancel.';
|
|---|
| 45 | TX_AUTH_CAP = 'Missing Author';
|
|---|
| 46 |
|
|---|
| 47 | procedure SelectAuthor(FontSize: Integer; CurrentContext: TTIUContext; var AuthorContext: TAuthorContext);
|
|---|
| 48 | { displays author select form for progress notes and returns a record of the selection }
|
|---|
| 49 | var
|
|---|
| 50 | frmNotesByAuthor: TfrmNotesByAuthor;
|
|---|
| 51 | W, H: integer;
|
|---|
| 52 | CurrentAuthor: Int64;
|
|---|
| 53 | begin
|
|---|
| 54 | frmNotesByAuthor := TfrmNotesByAuthor.Create(Application);
|
|---|
| 55 | try
|
|---|
| 56 | with frmNotesByAuthor do
|
|---|
| 57 | begin
|
|---|
| 58 | Font.Size := FontSize;
|
|---|
| 59 | W := ClientWidth;
|
|---|
| 60 | H := ClientHeight;
|
|---|
| 61 | ResizeToFont(FontSize, W, H);
|
|---|
| 62 | ClientWidth := W; pnlBase.Width := W;
|
|---|
| 63 | ClientHeight := H; pnlBase.Height := W;
|
|---|
| 64 | FChanged := False;
|
|---|
| 65 | CurrentAuthor := CurrentContext.Author;
|
|---|
| 66 | with cboAuthor do
|
|---|
| 67 | if CurrentAuthor > 0 then
|
|---|
| 68 | begin
|
|---|
| 69 | InitLongList(ExternalName(CurrentAuthor, 200));
|
|---|
| 70 | SelectByIEN(CurrentAuthor);
|
|---|
| 71 | end
|
|---|
| 72 | else
|
|---|
| 73 | begin
|
|---|
| 74 | InitLongList(User.Name);
|
|---|
| 75 | SelectByIEN(User.DUZ);
|
|---|
| 76 | end;
|
|---|
| 77 | FAscending := CurrentContext.TreeAscending;
|
|---|
| 78 | with radSort do if FAscending then ItemIndex := 0 else ItemIndex := 1;
|
|---|
| 79 | ShowModal;
|
|---|
| 80 | with AuthorContext do
|
|---|
| 81 | begin
|
|---|
| 82 | Changed := FChanged;
|
|---|
| 83 | Author := FAuthor;
|
|---|
| 84 | AuthorName := FAuthorName;
|
|---|
| 85 | Ascending := FAscending;
|
|---|
| 86 | end; {with AuthorContext}
|
|---|
| 87 | end; {with frmNotesByAuthor}
|
|---|
| 88 | finally
|
|---|
| 89 | frmNotesByAuthor.Release;
|
|---|
| 90 | end;
|
|---|
| 91 | end;
|
|---|
| 92 |
|
|---|
| 93 | procedure TfrmNotesByAuthor.cboAuthorNeedData(Sender: TObject; const StartFrom: string;
|
|---|
| 94 | Direction, InsertAt: Integer);
|
|---|
| 95 | begin
|
|---|
| 96 | cboAuthor.ForDataUse(SubSetOfActiveAndInactivePersons(StartFrom, Direction));
|
|---|
| 97 | end;
|
|---|
| 98 |
|
|---|
| 99 | procedure TfrmNotesByAuthor.cmdCancelClick(Sender: TObject);
|
|---|
| 100 | begin
|
|---|
| 101 | Close;
|
|---|
| 102 | end;
|
|---|
| 103 |
|
|---|
| 104 | procedure TfrmNotesByAuthor.cmdOKClick(Sender: TObject);
|
|---|
| 105 | begin
|
|---|
| 106 | if cboAuthor.ItemIEN = 0 then
|
|---|
| 107 | begin
|
|---|
| 108 | InfoBox(TX_AUTH_TEXT, TX_AUTH_CAP, MB_OK or MB_ICONWARNING);
|
|---|
| 109 | Exit;
|
|---|
| 110 | end;
|
|---|
| 111 | FChanged := True;
|
|---|
| 112 | FAuthor := cboAuthor.ItemIEN;
|
|---|
| 113 | FAuthorName := cboAuthor.DisplayText[cboAuthor.ItemIndex];
|
|---|
| 114 | FAscending := radSort.ItemIndex = 0;
|
|---|
| 115 | Close;
|
|---|
| 116 | end;
|
|---|
| 117 |
|
|---|
| 118 | end.
|
|---|