OptionFrm.pas 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. unit OptionFrm;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, StdCtrls, ExtCtrls, ComCtrls, XPMenu;
  6. type
  7. TOptionForm = class(TForm)
  8. pcOptions: TPageControl;
  9. tsCommon: TTabSheet;
  10. btnOk: TButton;
  11. btnCancel: TButton;
  12. lblCommon: TLabel;
  13. pnlUserInfo: TPanel;
  14. xpm: TXPMenu;
  15. cbAutoSave: TCheckBox;
  16. lblSaveInterval: TLabel;
  17. cbbSaveIntervall: TComboBox;
  18. lblMinutes: TLabel;
  19. gbOverRange: TGroupBox;
  20. lblTitleOverRange: TLabel;
  21. rbLedger: TRadioButton;
  22. rbDeal: TRadioButton;
  23. rbBoth: TRadioButton;
  24. GroupBox1: TGroupBox;
  25. cbExcelWithMis: TCheckBox;
  26. Label1: TLabel;
  27. edtOverRangePercent: TEdit;
  28. Label2: TLabel;
  29. TabSheet1: TTabSheet;
  30. rgGatherZJJLSelect: TRadioGroup;
  31. imgHelp: TImage;
  32. lHintOut: TLabel;
  33. lHintIn: TLabel;
  34. pnlGatherZJJLSelectHint: TPanel;
  35. procedure cbAutoSaveClick(Sender: TObject);
  36. procedure rbLedgerClick(Sender: TObject);
  37. procedure edtOverRangePercentKeyPress(Sender: TObject; var Key: Char);
  38. procedure edtOverRangePercentExit(Sender: TObject);
  39. procedure edtOverRangePercentKeyDown(Sender: TObject; var Key: Word;
  40. Shift: TShiftState);
  41. procedure imgHelpClick(Sender: TObject);
  42. private
  43. procedure SetSaveIntervalEnable(AEnable: Boolean);
  44. function GetOverRangeType: Integer;
  45. procedure SetOverRangeType(const Value: Integer);
  46. public
  47. procedure Load;
  48. procedure Save;
  49. property OverRangeType: Integer read GetOverRangeType write SetOverRangeType;
  50. end;
  51. procedure ModifiedOptions;
  52. implementation
  53. {$R *.dfm}
  54. uses
  55. Globals, ConfigDoc, MainFrm;
  56. procedure ModifiedOptions;
  57. var
  58. OptionForm: TOptionForm;
  59. begin
  60. OptionForm := TOptionForm.Create(nil);
  61. try
  62. OptionForm.Load;
  63. OptionForm.ClientHeight := 338;
  64. OptionForm.ClientWidth := 479;
  65. if OptionForm.ShowModal = mrOk then
  66. OptionForm.Save;
  67. finally
  68. OptionForm.Free;
  69. end;
  70. end;
  71. { TOptionForm }
  72. procedure TOptionForm.Load;
  73. begin
  74. with SupportManager.ConfigInfo do
  75. begin
  76. cbAutoSave.Checked := AutoSave;
  77. SetSaveIntervalEnable(cbAutoSave.Checked);
  78. cbbSaveIntervall.Text := IntToStr(AutoSaveInterval);
  79. Self.OverRangeType := OverRangeType;
  80. edtOverRangePercent.Text := IntToStr(OverRangePercent);
  81. cbExcelWithMis.Checked := ExcelWithMis;
  82. rgGatherZJJLSelect.ItemIndex := GatherZJJLSelect;
  83. end;
  84. end;
  85. procedure TOptionForm.Save;
  86. begin
  87. with SupportManager.ConfigInfo do
  88. begin
  89. AutoSave := cbAutoSave.Checked;
  90. AutoSaveInterval := StrToIntDef(cbbSaveIntervall.Text, 15);
  91. OverRangeType := Self.OverRangeType;
  92. OverRangePercent := StrToIntDef(edtOverRangePercent.Text, 100);
  93. ExcelWithMis := cbExcelWithMis.Checked;
  94. GatherZJJLSelect := rgGatherZJJLSelect.ItemIndex;
  95. end;
  96. MainForm.CurProjectFrame.BillsGatherFrame.zgGclBills.Invalidate;
  97. end;
  98. procedure TOptionForm.cbAutoSaveClick(Sender: TObject);
  99. begin
  100. SetSaveIntervalEnable(cbAutoSave.Checked);
  101. end;
  102. procedure TOptionForm.SetSaveIntervalEnable(AEnable: Boolean);
  103. begin
  104. lblSaveInterval.Enabled := AEnable;
  105. cbbSaveIntervall.Enabled := AEnable;
  106. lblMinutes.Enabled := AEnable;
  107. end;
  108. function TOptionForm.GetOverRangeType: Integer;
  109. begin
  110. if rbLedger.Checked then
  111. Result := rbLedger.Tag
  112. else if rbDeal.Checked then
  113. Result := rbDeal.Tag
  114. else if rbBoth.Checked then
  115. Result := rbBoth.Tag;
  116. end;
  117. procedure TOptionForm.SetOverRangeType(const Value: Integer);
  118. begin
  119. rbLedger.Checked := rbLedger.Tag = Value;
  120. rbDeal.Checked := rbDeal.Tag = Value;
  121. rbBoth.Checked := rbBoth.Tag = Value;
  122. end;
  123. procedure TOptionForm.rbLedgerClick(Sender: TObject);
  124. begin
  125. TRadioButton(Sender).Checked := True;
  126. end;
  127. procedure TOptionForm.edtOverRangePercentKeyPress(Sender: TObject;
  128. var Key: Char);
  129. begin
  130. if not (Key in ['0'..'9', #8, #13]) then
  131. Key := #0;
  132. end;
  133. procedure TOptionForm.edtOverRangePercentExit(Sender: TObject);
  134. var
  135. fPer: Double;
  136. begin
  137. fPer := StrToIntDef(TEdit(Sender).text, 0);
  138. if (fPer < 50) then
  139. TEdit(Sender).text := '50'
  140. else if (fPer > 100) then
  141. TEdit(Sender).text := '100';
  142. end;
  143. procedure TOptionForm.edtOverRangePercentKeyDown(Sender: TObject;
  144. var Key: Word; Shift: TShiftState);
  145. var
  146. fPer: Double;
  147. begin
  148. if (Key = 13) then
  149. begin
  150. fPer := StrToIntDef(TEdit(Sender).text, 0);
  151. if (fPer < 50) then
  152. TEdit(Sender).text := '50'
  153. else if (fPer > 100) then
  154. TEdit(Sender).text := '100';
  155. end;
  156. end;
  157. procedure TOptionForm.imgHelpClick(Sender: TObject);
  158. begin
  159. pnlGatherZJJLSelectHint.Visible := not pnlGatherZJJLSelectHint.Visible;
  160. end;
  161. end.