[456] | 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;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 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 |
|
---|
| 29 | function ExcueteDefaultEvntSetting: string;
|
---|
| 30 |
|
---|
| 31 | var
|
---|
| 32 | frmDefaultEvent: TfrmDefaultEvent;
|
---|
| 33 |
|
---|
| 34 | implementation
|
---|
| 35 |
|
---|
| 36 | {$R *.DFM}
|
---|
| 37 |
|
---|
| 38 | function ExcueteDefaultEvntSetting: string;
|
---|
| 39 | var
|
---|
| 40 | frmDefaultEvent: TfrmDefaultEvent;
|
---|
| 41 | begin
|
---|
| 42 | frmDefaultEvent := TfrmDefaultEvent.Create(Application);
|
---|
| 43 | try
|
---|
| 44 | ResizeAnchoredFormToFont(frmDefaultEvent);
|
---|
| 45 | frmDefaultEvent.ShowModal;
|
---|
| 46 | Result := frmDefaultEvent.FDefaultEvtName;
|
---|
| 47 | finally
|
---|
| 48 | frmDefaultEvent.Free;
|
---|
| 49 | end;
|
---|
| 50 | end;
|
---|
| 51 |
|
---|
| 52 | procedure TfrmDefaultEvent.btnCancelClick(Sender: TObject);
|
---|
| 53 | begin
|
---|
| 54 | Close;
|
---|
| 55 | end;
|
---|
| 56 |
|
---|
| 57 | procedure TfrmDefaultEvent.FormCreate(Sender: TObject);
|
---|
| 58 | var
|
---|
| 59 | i : integer;
|
---|
| 60 | begin
|
---|
| 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;
|
---|
| 81 | end;
|
---|
| 82 |
|
---|
| 83 | procedure TfrmDefaultEvent.btnOKClick(Sender: TObject);
|
---|
| 84 | const
|
---|
| 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 "';
|
---|
| 88 | var
|
---|
| 89 | errMsg: string;
|
---|
| 90 | begin
|
---|
| 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;
|
---|
| 126 | end;
|
---|
| 127 |
|
---|
| 128 | end.
|
---|