/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

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