PageRenderTime 14ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Gedemin/Transaction/gdc_dlgAcctAccCard_unit.pas

http://gedemin.googlecode.com/
Pascal | 238 lines | 195 code | 30 blank | 13 comment | 20 complexity | 93cf02d6ee8a834bdefc72bebc1af078 MD5 | raw file
  1unit gdc_dlgAcctAccCard_unit;
  2
  3interface
  4
  5uses
  6  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7  gdc_dlgBaseAcctConfig, IBDatabase, Menus, Db, ActnList, StdCtrls, Mask,
  8  DBCtrls, gdv_frameBaseAnalitic_unit, gdv_frameQuantity_unit, gd_ClassList,
  9  gdv_frameSum_unit, ComCtrls, gdv_frameAnalyticValue_unit, AcctUtils,
 10  gdv_AcctConfig_unit, gsIBLookupComboBox, Storages, gsStorage_CompPath;
 11
 12type
 13  TdlgAcctAccCardConfig = class(TdlgBaseAcctConfig)
 14    cbGroup: TCheckBox;
 15    gbCorrAccounts: TGroupBox;
 16    Label1: TLabel;
 17    cbCorrAccounts: TComboBox;
 18    Button2: TButton;
 19    cbCorrSubAccounts: TCheckBox;
 20    rbDebit: TRadioButton;
 21    rbCredit: TRadioButton;
 22    actCorrAccounts: TAction;
 23    procedure actCorrAccountsExecute(Sender: TObject);
 24    procedure FormDockDrop(Sender: TObject; Source: TDragDockObject; X,
 25      Y: Integer);
 26    procedure cbCorrAccountsChange(Sender: TObject);
 27    procedure cbCorrSubAccountsClick(Sender: TObject);
 28
 29  private
 30    FCorrAccountIDs: TList;
 31
 32  protected
 33    procedure UpdateControls; override;
 34    class function ConfigClassName: string; override;
 35
 36    procedure DoLoadConfig(const Config: TBaseAcctConfig);override;
 37    procedure DoSaveConfig(Config: TBaseAcctConfig);override;
 38
 39  public
 40    destructor Destroy; override;
 41
 42    procedure LoadSettings; override;
 43    procedure SaveSettings; override;
 44  end;
 45
 46var
 47  dlgAcctAccCardConfig: TdlgAcctAccCardConfig;
 48
 49implementation
 50
 51{$R *.DFM}
 52
 53destructor TdlgAcctAccCardConfig.Destroy;
 54begin
 55  FCorrAccountIDs.Free;
 56  inherited;
 57end;
 58
 59procedure TdlgAcctAccCardConfig.actCorrAccountsExecute(Sender: TObject);
 60begin
 61  if AccountDialog(cbCorrAccounts, 0) then
 62  begin
 63    if FCorrAccountIDs <> nil then
 64      FCorrAccountIDs.Clear;
 65    UpdateControls;
 66  end;
 67end;
 68
 69procedure TdlgAcctAccCardConfig.FormDockDrop(Sender: TObject;
 70  Source: TDragDockObject; X, Y: Integer);
 71begin
 72  inherited;
 73  FreeAndNil(FCorrAccountIDs);
 74end;
 75
 76procedure TdlgAcctAccCardConfig.cbCorrAccountsChange(Sender: TObject);
 77begin
 78  if FCorrAccountIDs <> nil then
 79    FCorrAccountIDs.Clear
 80end;
 81
 82procedure TdlgAcctAccCardConfig.cbCorrSubAccountsClick(Sender: TObject);
 83begin
 84  if FCorrAccountIDs <> nil then
 85    FCorrAccountIDs.Clear
 86end;
 87
 88procedure TdlgAcctAccCardConfig.UpdateControls;
 89begin
 90  if FCorrAccountIDs = nil then
 91    FCorrAccountIDs := TList.Create;
 92  inherited;
 93  SetAccountIDs(cbCorrAccounts, FCorrAccountIDs, cbCorrSubAccounts.Checked);
 94end;
 95
 96class function TdlgAcctAccCardConfig.ConfigClassName: string;
 97begin
 98  Result := 'TAccCardConfig';
 99end;
100
101procedure TdlgAcctAccCardConfig.DoLoadConfig(
102  const Config: TBaseAcctConfig);
103var
104  C: TAccCardConfig;
105begin
106  inherited;
107  if Config is TAccCardConfig then
108  begin
109    C := Config as TAccCardConfig;
110    with C do
111    begin
112      cbGroup.Checked := Group;
113      cbCorrAccounts.Text := CorrAccounts;
114      rbDebit.Checked := AccountPart = 'D';
115      rbCredit.Checked := AccountPart <> 'D';
116      cbCorrSubAccounts.Checked := IncCorrSubAccounts;
117    end;
118  end;
119end;
120
121procedure TdlgAcctAccCardConfig.DoSaveConfig(Config: TBaseAcctConfig);
122var
123  C: TAccCardConfig;
124begin
125  inherited;
126  if Config is TAccCardConfig then
127  begin
128    C := Config as TAccCardConfig;
129    with C do
130    begin
131      Group := cbGroup.Checked;
132      CorrAccounts := cbCorrAccounts.Text;
133      if rbDebit.Checked then
134        AccountPart := 'D'
135      else
136        AccountPart := 'C';
137      IncCorrSubAccounts := cbCorrSubAccounts.Checked;
138    end;
139  end;
140end;
141
142procedure TdlgAcctAccCardConfig.LoadSettings;
143{@UNFOLD MACRO INH_CRFORM_PARAMS(VAR)}
144{M}VAR
145{M}  Params, LResult: Variant;
146{M}  tmpStrings: TStackStrings;
147{END MACRO}
148var
149  ComponentPath: string;
150begin
151  {@UNFOLD MACRO INH_CRFORM_WITHOUTPARAMS('TDLGACCTACCCARDCONFIG', 'LOADSETTINGS', KEYLOADSETTINGS)}
152  {M}  try
153  {M}    if Assigned(gdcMethodControl) and Assigned(ClassMethodAssoc) then
154  {M}    begin
155  {M}      SetFirstMethodAssoc('TDLGACCTACCCARDCONFIG', KEYLOADSETTINGS);
156  {M}      tmpStrings := TStackStrings(ClassMethodAssoc.IntByKey[KEYLOADSETTINGS]);
157  {M}      if (tmpStrings = nil) or (tmpStrings.IndexOf('TDLGACCTACCCARDCONFIG') = -1) then
158  {M}      begin
159  {M}        Params := VarArrayOf([GetGdcInterface(Self)]);
160  {M}        if gdcMethodControl.ExecuteMethodNew(ClassMethodAssoc, Self, 'TDLGACCTACCCARDCONFIG',
161  {M}          'LOADSETTINGS', KEYLOADSETTINGS, Params, LResult) then exit;
162  {M}      end else
163  {M}        if tmpStrings.LastClass.gdClassName <> 'TDLGACCTACCCARDCONFIG' then
164  {M}        begin
165  {M}          Inherited;
166  {M}          Exit;
167  {M}        end;
168  {M}    end;
169  {END MACRO}
170
171  inherited;
172
173  if UserStorage <> nil then
174  begin
175    ComponentPath := BuildComponentPath(Self);
176    cbCorrAccounts.Items.Text := UserStorage.ReadString(ComponentPath, 'CorrAccountHistory', '');
177  end;
178
179  {@UNFOLD MACRO INH_CRFORM_FINALLY('TDLGACCTACCCARDCONFIG', 'LOADSETTINGS', KEYLOADSETTINGS)}
180  {M}finally
181  {M}  if Assigned(gdcMethodControl) and Assigned(ClassMethodAssoc) then
182  {M}    ClearMacrosStack('TDLGACCTACCCARDCONFIG', 'LOADSETTINGS', KEYLOADSETTINGS);
183  {M}end;
184  {END MACRO}
185end;
186
187procedure TdlgAcctAccCardConfig.SaveSettings;
188{@UNFOLD MACRO INH_CRFORM_PARAMS(VAR)}
189{M}VAR
190{M}  Params, LResult: Variant;
191{M}  tmpStrings: TStackStrings;
192{END MACRO}
193var
194  ComponentPath: string;
195begin
196  {@UNFOLD MACRO INH_CRFORM_WITHOUTPARAMS('TDLGACCTACCCARDCONFIG', 'SAVESETTINGS', KEYSAVESETTINGS)}
197  {M}  try
198  {M}    if Assigned(gdcMethodControl) and Assigned(ClassMethodAssoc) then
199  {M}    begin
200  {M}      SetFirstMethodAssoc('TDLGACCTACCCARDCONFIG', KEYSAVESETTINGS);
201  {M}      tmpStrings := TStackStrings(ClassMethodAssoc.IntByKey[KEYSAVESETTINGS]);
202  {M}      if (tmpStrings = nil) or (tmpStrings.IndexOf('TDLGACCTACCCARDCONFIG') = -1) then
203  {M}      begin
204  {M}        Params := VarArrayOf([GetGdcInterface(Self)]);
205  {M}        if gdcMethodControl.ExecuteMethodNew(ClassMethodAssoc, Self, 'TDLGACCTACCCARDCONFIG',
206  {M}          'SAVESETTINGS', KEYSAVESETTINGS, Params, LResult) then exit;
207  {M}      end else
208  {M}        if tmpStrings.LastClass.gdClassName <> 'TDLGACCTACCCARDCONFIG' then
209  {M}        begin
210  {M}          Inherited;
211  {M}          Exit;
212  {M}        end;
213  {M}    end;
214  {END MACRO}
215
216  inherited;
217
218  if UserStorage <> nil then
219  begin
220    ComponentPath := BuildComponentPath(Self);
221    SaveHistory(cbCorrAccounts);
222    UserStorage.WriteString(ComponentPath, 'CorrAccountHistory', cbCorrAccounts.Items.Text);
223  end;
224
225  {@UNFOLD MACRO INH_CRFORM_FINALLY('TDLGACCTACCCARDCONFIG', 'SAVESETTINGS', KEYSAVESETTINGS)}
226  {M}finally
227  {M}  if Assigned(gdcMethodControl) and Assigned(ClassMethodAssoc) then
228  {M}    ClearMacrosStack('TDLGACCTACCCARDCONFIG', 'SAVESETTINGS', KEYSAVESETTINGS);
229  {M}end;
230  {END MACRO}
231end;
232
233initialization
234  RegisterFrmClass(TdlgAcctAccCardConfig);
235
236finalization
237  UnRegisterFrmClass(TdlgAcctAccCardConfig);
238end.