📄 optionspropertyfrm.pas
字号:
unit OptionsPropertyFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SJCustomProperty, cxLookAndFeelPainters, PropStorageEh,
StdCtrls, cxButtons, ExtCtrls, ComCtrls, cxControls, cxContainer, cxEdit,
cxTextEdit, cxMaskEdit, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit,
cxDBLookupComboBox, cxCheckBox, IniFiles, cxSpinEdit;
type
TfrmPropertyOptions = class(TSJCustomPropertyForm)
PageControl: TPageControl;
TabSheet1: TTabSheet;
GroupBox1: TGroupBox;
Label1: TLabel;
edtCompany: TcxTextEdit;
Label2: TLabel;
edtBankname: TcxTextEdit;
edtAccount: TcxTextEdit;
Label3: TLabel;
Label4: TLabel;
edtAddress: TcxTextEdit;
TabSheet2: TTabSheet;
GroupBox2: TGroupBox;
Label5: TLabel;
edtCollector: TcxLookupComboBox;
chkPreview: TcxCheckBox;
Label6: TLabel;
edtUnits: TcxTextEdit;
Label7: TLabel;
edtItem: TcxTextEdit;
chkShowPrintDialog: TcxCheckBox;
Label8: TLabel;
edtInvoiceLength: TcxSpinEdit;
Label9: TLabel;
edtStartInv: TcxTextEdit;
edtEndInv: TcxTextEdit;
Label10: TLabel;
Label11: TLabel;
procedure btnOKClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure edtInvoiceLengthPropertiesChange(Sender: TObject);
private
procedure SaveSetting;
procedure LoadSetting;
public
{ Public declarations }
end;
var
frmPropertyOptions: TfrmPropertyOptions;
implementation
uses InvPrintDM;
{$R *.dfm}
procedure TfrmPropertyOptions.LoadSetting;
// 加载用户选项
var
Afilename: string;
begin
Afilename := ExtractFilePath(Application.ExeName) + 'DjsrInvPrinter.ini';
if not FileExists(Afilename) then
Exit;
with TIniFile.Create(Afilename) do
try
// 单位信息
if SectionExists('Normal') then
begin
if ValueExists('Normal', 'Company') then
edtCompany.Text := ReadString('Normal', 'Company', '');
if ValueExists('Normal', 'Address') then
edtAddress.Text := ReadString('Normal', 'Address', '');
if ValueExists('Normal', 'Bankname') then
edtBankname.Text := ReadString('Normal', 'Bankname', '');
if ValueExists('Normal', 'Account') then
edtAccount.Text := ReadString('Normal', 'Account', '');
end;
// 发票信息
if SectionExists('Invoice') then
begin
if ValueExists('Invoice', 'InvoiceLength') then
edtInvoiceLength.Value := ReadInteger('Invoice', 'InvoiceLength', 8);
if ValueExists('Invoice', 'StartInv') then
edtStartInv.Text := ReadString('Invoice', 'StartInv', '00000001');
if ValueExists('Invoice', 'EndInv') then
edtEndInv.Text := ReadString('Invoice', 'EndInv', '99999999');
end;
// 打印信息
if SectionExists('Print') then
begin
if ValueExists('Print', 'Collector') then
edtCollector.EditValue := ReadString('Print', 'Collector', '00000');
if ValueExists('Print', 'InvoiceLength') then
edtInvoiceLength.Value := ReadInteger('Print', 'InvoiceLength', 8);
if ValueExists('Print', 'Units') then
edtUnits.Text := ReadString('Print', 'Units', '立方米');
if ValueExists('Print', 'Item') then
edtItem.Text := ReadString('Print', 'Item', '自来水销售');
if ValueExists('Print', 'Preview') then
chkPreview.Checked := ReadBool('Print', 'Preview', True);
if ValueExists('Print', 'ShowDialog') then
chkShowPrintDialog.Checked := ReadBool('Print', 'ShowDialog', True);
end;
finally
Free;
end;
end;
procedure TfrmPropertyOptions.SaveSetting;
// 保存用户选项
var
Afilename: string;
begin
Afilename := ExtractFilePath(Application.ExeName) + 'DjsrInvPrinter.ini';
with TIniFile.Create(Afilename) do
try
// 单位信息
WriteString('Normal', 'Company', edtCompany.Text);
WriteString('Normal', 'Address', edtAddress.Text);
WriteString('Normal', 'Bankname', edtBankname.Text);
WriteString('Normal', 'Account', edtAccount.Text);
// 发票信息
WriteInteger('Invoice', 'InvoiceLength', edtInvoiceLength.Value);
WriteString('Invoice', 'StartInv', edtStartInv.Text);
WriteString('Invoice', 'EndInv', edtEndInv.Text);
// 打印信息
WriteString('Print', 'Collector', edtCollector.EditValue);
WriteString('Print', 'Units', edtUnits.Text);
WriteString('Print', 'Item', edtItem.Text);
WriteBool('Print', 'Preview', chkPreview.Checked);
WriteBool('Print', 'ShowDialog', chkShowPrintDialog.Checked);
finally
Free;
end;
end;
procedure TfrmPropertyOptions.btnOKClick(Sender: TObject);
begin
inherited;
SaveSetting;
end;
procedure TfrmPropertyOptions.FormShow(Sender: TObject);
begin
inherited;
LoadSetting;
end;
procedure TfrmPropertyOptions.edtInvoiceLengthPropertiesChange(
Sender: TObject);
begin
inherited;
edtStartInv.Properties.MaxLength := edtInvoiceLength.Value;
edtEndInv.Properties.MaxLength := edtInvoiceLength.Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -