source: cprs/branches/foia-cprs/CPRS-Chart/fDefaultEvent.pas@ 819

Last change on this file since 819 was 459, checked in by Kevin Toppenberg, 16 years ago

Adding foia-cprs branch

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