1 | unit fDefaultEvent;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
7 | StdCtrls, ORCtrls, ExtCtrls, rOrders, ORFn, uCore, fBase508Form,
|
---|
8 | VA508AccessibilityManager;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TfrmDefaultEvent = class(TfrmBase508Form)
|
---|
12 | pnlTop: TPanel;
|
---|
13 | lblCaption: TLabel;
|
---|
14 | cboEvents: TORComboBox;
|
---|
15 | pnlBottom: TPanel;
|
---|
16 | btnOK: TButton;
|
---|
17 | btnCancel: TButton;
|
---|
18 | procedure btnCancelClick(Sender: TObject);
|
---|
19 | procedure FormCreate(Sender: TObject);
|
---|
20 | procedure btnOKClick(Sender: TObject);
|
---|
21 | private
|
---|
22 | OKPressed: boolean;
|
---|
23 | FDefaultEvtName: string;
|
---|
24 | FPreDefaultEvtID: string;
|
---|
25 | FPreDefaultEvtName: string;
|
---|
26 | public
|
---|
27 | { Public declarations }
|
---|
28 | end;
|
---|
29 |
|
---|
30 | function ExcueteDefaultEvntSetting: string;
|
---|
31 |
|
---|
32 | var
|
---|
33 | frmDefaultEvent: TfrmDefaultEvent;
|
---|
34 |
|
---|
35 | implementation
|
---|
36 |
|
---|
37 | uses VAUtils;
|
---|
38 |
|
---|
39 | {$R *.DFM}
|
---|
40 |
|
---|
41 | function ExcueteDefaultEvntSetting: string;
|
---|
42 | var
|
---|
43 | frmDefaultEvent: TfrmDefaultEvent;
|
---|
44 | begin
|
---|
45 | frmDefaultEvent := TfrmDefaultEvent.Create(Application);
|
---|
46 | try
|
---|
47 | ResizeAnchoredFormToFont(frmDefaultEvent);
|
---|
48 | frmDefaultEvent.ShowModal;
|
---|
49 | Result := frmDefaultEvent.FDefaultEvtName;
|
---|
50 | finally
|
---|
51 | frmDefaultEvent.Free;
|
---|
52 | end;
|
---|
53 | end;
|
---|
54 |
|
---|
55 | procedure TfrmDefaultEvent.btnCancelClick(Sender: TObject);
|
---|
56 | begin
|
---|
57 | Close;
|
---|
58 | end;
|
---|
59 |
|
---|
60 | procedure TfrmDefaultEvent.FormCreate(Sender: TObject);
|
---|
61 | var
|
---|
62 | i : integer;
|
---|
63 | begin
|
---|
64 | FPreDefaultEvtID := '';
|
---|
65 | FPreDefaultEvtName := '';
|
---|
66 | FDefaultEvtName := '';
|
---|
67 | FPreDefaultEvtID := GetDefaultEvt(IntToStr(User.DUZ));
|
---|
68 | ListSpecialtiesED(#0,cboEvents.Items);
|
---|
69 | with cboEvents do
|
---|
70 | begin
|
---|
71 | for i := 0 to Items.Count - 1 do
|
---|
72 | begin
|
---|
73 | if FPreDefaultEvtID = Piece(Items[i],'^',1) then
|
---|
74 | begin
|
---|
75 | ItemIndex := i;
|
---|
76 | FPreDefaultEvtName := Piece(Items[i],'^',9);
|
---|
77 | if Length(FPreDefaultEvtName)<1 then
|
---|
78 | FPreDefaultEvtName := Piece(Items[i],'^',2);
|
---|
79 | break;
|
---|
80 | end;
|
---|
81 | end;
|
---|
82 | end;
|
---|
83 | OKPressed := False;
|
---|
84 | end;
|
---|
85 |
|
---|
86 | procedure TfrmDefaultEvent.btnOKClick(Sender: TObject);
|
---|
87 | const
|
---|
88 | TXT_1 = 'Would you like to change the default event from "';
|
---|
89 | TXT_2 = '" to "';
|
---|
90 | TXT_3 = 'Would you like set your default event to "';
|
---|
91 | var
|
---|
92 | errMsg: string;
|
---|
93 | begin
|
---|
94 | if cboEvents.ItemIndex < 0 then
|
---|
95 | begin
|
---|
96 | ShowMsg('You have to select an event first!');
|
---|
97 | Exit;
|
---|
98 | end;
|
---|
99 | if (Piece(cboEvents.Items[cboEvents.ItemIndex],'^',1) <> FPreDefaultEvtID) and ( Length(FPreDefaultEvtID)>0 )then
|
---|
100 | begin
|
---|
101 | if InfoBox(TXT_1 + FPreDefaultEvtName + TXT_2 + cboEvents.Text + '"?','Warning', MB_OKCANCEL or MB_ICONWARNING) = IDOK then
|
---|
102 | begin
|
---|
103 | errMsg := '';
|
---|
104 | SetDefaultEvent(errMsg, Piece(cboEvents.Items[cboEvents.ItemIndex],'^',1));
|
---|
105 | if length(errMsg)>0 then
|
---|
106 | ShowMsg(errMsg)
|
---|
107 | else
|
---|
108 | ShowMsg('The default release event "' + cboEvents.Text + '" has been set successfully!');
|
---|
109 | FDefaultEvtName := cboEvents.Text;
|
---|
110 | OKPressed := True;
|
---|
111 | Close;
|
---|
112 | end;
|
---|
113 | end
|
---|
114 | else if (Piece(cboEvents.Items[cboEvents.ItemIndex],'^',1) <> FPreDefaultEvtID) and ( Length(FPreDefaultEvtID)=0 )then
|
---|
115 | begin
|
---|
116 | if InfoBox(TXT_3 + cboEvents.Text + '"?','Warning', MB_OKCANCEL or MB_ICONWARNING) = IDOK then
|
---|
117 | begin
|
---|
118 | errMsg := '';
|
---|
119 | SetDefaultEvent(errMsg, Piece(cboEvents.Items[cboEvents.ItemIndex],'^',1));
|
---|
120 | if length(errMsg)>0 then
|
---|
121 | ShowMsg(errMsg)
|
---|
122 | else
|
---|
123 | ShowMsg('The default release event "' + cboEvents.Text + '" has been set successfully!');
|
---|
124 | FDefaultEvtName := cboEvents.Text;
|
---|
125 | OKPressed := True;
|
---|
126 | Close;
|
---|
127 | end;
|
---|
128 | end;
|
---|
129 | end;
|
---|
130 |
|
---|
131 | end.
|
---|