⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 options.pas

📁 一套非常发好的财务管理软件,想从事此方面开发的可以借签
💻 PAS
字号:
unit Options;

interface

uses
  Windows, Graphics, Controls, Forms, SysUtils,
  Dialogs, StdCtrls, ExtCtrls, SUIButton, SUIEdit, ExtFunc,
  SUIDBCtrls, SUIURLLabel, jpeg, Classes, DB, ADODB, SUIForm, SUIComboBox;

type
  TFrmOptions = class(TForm)
    suiForm1: TsuiForm;
    btnOK: TsuiButton;
    btnCancel: TsuiButton;
    GroupBox1: TGroupBox;
    cbIsWriteLog: TsuiCheckBox;
    cbExitBeforeBackup: TsuiCheckBox;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    cbReportName: TsuiComboBox;
    editW2: TsuiEdit;
    editH2: TsuiEdit;
    editW1: TsuiEdit;
    editH1: TsuiEdit;
    Label3: TLabel;
    Label4: TLabel;
    q: TADOQuery;
    Label5: TLabel;
    editH3: TsuiEdit;
    Label6: TLabel;
    editW3: TsuiEdit;
    procedure cbIsWriteLogClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btnOKClick(Sender: TObject);
    procedure cbReportNameChange(Sender: TObject);
    procedure editW1KeyPress(Sender: TObject; var Key: Char);
    procedure editW2Change(Sender: TObject);
    procedure editH2Change(Sender: TObject);
    procedure editW1Exit(Sender: TObject);
  private
    { Private declarations }
  public
    PDPageWidth,PDPageHeight:integer;
    AccountPageWidth,AccountPageHeight:integer;
    ReportPageWidth,ReportPageHeight:array of integer;
  end;

var
  FrmOptions: TFrmOptions;
implementation

uses DataModule,PublicFunc;

{$R *.dfm}

procedure TFrmOptions.cbIsWriteLogClick(Sender: TObject);
begin
  btnOK.Enabled:=true;
end;

procedure TFrmOptions.FormShow(Sender: TObject);
var
  i:integer;
begin
  cbIsWriteLog.Checked:=DM.isWriteLog;
  cbExitBeforeBackup.Checked:=DM.ExitBeforeBackup;

  PDPageWidth:=DM.PDPageWidth;
  PDPageHeight:=DM.PDPageHeight;
  AccountPageWidth:=DM.AccountPageWidth;
  AccountPageHeight:=DM.AccountPageHeight;

  SetLength(ReportPageWidth,cbReportName.Items.Count);
  SetLength(ReportPageHeight,cbReportName.Items.Count);

  for i:=0 to cbReportName.Items.Count-1 do
  begin
    ReportPageWidth[i]:=DM.ReportPageWidth[i];
    ReportPageHeight[i]:=DM.ReportPageHeight[i];
  end;
  editW1.Text:=IntToStr(PDPageWidth);
  editH1.Text:=IntToStr(PDPageHeight);
  editW3.Text:=IntToStr(AccountPageWidth);
  editH3.Text:=IntToStr(AccountPageHeight);
  cbReportName.ItemIndex:=0;
  editW2.Text:=IntToStr(ReportPageWidth[0]);
  editH2.Text:=IntToStr(ReportPageHeight[0]);
end;

procedure TFrmOptions.btnOKClick(Sender: TObject);
var
  i:integer;
begin
  DM.isWriteLog:=cbIsWriteLog.Checked;
  DM.ExitBeforeBackup:=cbExitBeforeBackup.Checked;

  DM.PDPageWidth:=StrToInt(editW1.text);
  DM.PDPageHeight:=StrToInt(editH1.text);

  DM.AccountPageWidth:=StrToInt(editW3.text);
  DM.AccountPageHeight:=StrToInt(editH3.text);

  for i:=0 to cbReportName.Items.Count-1 do
  begin
    DM.ReportPageWidth[i]:=ReportPageWidth[i];
    DM.ReportPageHeight[i]:=ReportPageHeight[i];
    q.Connection:=DM.adoc;
    q.Close;
    q.SQL.Clear;
    q.SQL.Add('update Reports set PageWidth='+IntToStr(ReportPageWidth[i])+' where Name='''+cbReportName.Items[i]+'''');
    q.ExecSQL;
    q.Close;
    q.SQL.Clear;
    q.SQL.Add('update Reports set PageHeight='+IntToStr(ReportPageHeight[i])+' where Name='''+cbReportName.Items[i]+'''');
    q.ExecSQL;
    q.Close;
  end;
  SetOptionsKeyValue(DM.adoc,'退出前备份数据',BoolToStr(DM.ExitBeforeBackup));
  SetOptionsKeyValue(DM.adoc,'保存日志',BoolToStr(DM.isWriteLog));
  SetOptionsKeyValue(DM.adoc,'凭证打印纸张宽度',editW1.Text);
  SetOptionsKeyValue(DM.adoc,'凭证打印纸张高度',editH1.Text);
  SetOptionsKeyValue(DM.adoc,'帐簿打印纸张宽度',editW3.Text);
  SetOptionsKeyValue(DM.adoc,'帐簿打印纸张高度',editH3.Text);
end;

procedure TFrmOptions.cbReportNameChange(Sender: TObject);
begin
  editW2.Text:=IntToStr(ReportPageWidth[cbReportName.ItemIndex]);
  editH2.Text:=IntToStr(ReportPageHeight[cbReportName.ItemIndex]);
end;

procedure TFrmOptions.editW1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0','1','2','3','4','5','6','7','8','9',#8]) then Key:=#0;
end;

procedure TFrmOptions.editW2Change(Sender: TObject);
begin
  btnOK.Enabled:=true;
  try
    ReportPageWidth[cbReportName.ItemIndex]:=StrToInt(editW2.Text);
  except
    ;
  end;
end;

procedure TFrmOptions.editH2Change(Sender: TObject);
begin
  btnOK.Enabled:=true;
  try
    ReportPageHeight[cbReportName.ItemIndex]:=StrToInt(editH2.Text);
  except
    ;
  end;
end;

procedure TFrmOptions.editW1Exit(Sender: TObject);
begin
  if Trim(TsuiEdit(Sender).Text)='' then
  begin
    Frm_MsgBox('系统信息','请输入一个正确的数值!',MsgBox_OK_ERROR);
    TsuiEdit(Sender).SetFocus;
    Exit;
  end;
  if StrToInt(Trim(TsuiEdit(Sender).Text))<1 then
  begin
    Frm_MsgBox('系统信息','请输入一个正确的数值!',MsgBox_OK_ERROR);
    TsuiEdit(Sender).SetFocus;
    Exit;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -