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

📄 systemoptionsf.pas

📁 极具实用价值的文件管理系统
💻 PAS
字号:
{ *********************************************************************** }
{ Unit Name: SystemOptionsF
{ Purpose: SystemOptionsF
{ Author: Cyclone
{ History:
{         2004-6-28 23:36:33 Create the function
{ *********************************************************************** }

unit SystemOptionsF;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DialogBaseF, Buttons, CycSpeedButton, CycPanel, ExtCtrls, StrUtils,
  StdCtrls, Mask, DBCtrls, CycLabeledDBEdit, CycLabeledLookupDBEdit,
  {$IFDEF MSWINDOWS} FileCtrl, {$ENDIF} CycLabel, CycLabeledEdit;

type
  TfmSystemOptions = class(TfmDialogBase)
    edtRootPath: TCycLabeledLookupDBEdit;
    grxSystemRunningNo: TGroupBox;
    edtPrefix: TCycLabeledDBEdit;
    CycLabel1: TCycLabel;
    CycLabel2: TCycLabel;
    CycLabel4: TCycLabel;
    edtNoPlace: TCycLabeledDBEdit;
    cbxYear: TDBComboBox;
    cbxMonth: TDBComboBox;
    cbxDay: TDBComboBox;
    edtFormat: TCycLabeledEdit;
    chkUseSkin: TCheckBox;
    procedure edtRootPathSubButtonClick(Sender: TObject);
    procedure btnCancelClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure btnOKClick(Sender: TObject);
    procedure edtPrefixChange(Sender: TObject);
    procedure edtNoPlaceKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
    function CheckRunningNoFormat: Boolean;
    function CheckDataValid: Boolean;
  public
    { Public declarations }
  end;

var
  fmSystemOptions: TfmSystemOptions;

implementation

uses MainD, PubFuns;

{$R *.dfm}

procedure TfmSystemOptions.edtRootPathSubButtonClick(Sender: TObject);
var
  APath: String;
begin
  if SelectDirectory('Please select root path', '', APath) then
  begin
    dmMain.dsSystemOptions.Edit;
    dmMain.dsSystemOptions.FieldByName('RootPath').AsString := APath;
  end;
end;

procedure TfmSystemOptions.btnCancelClick(Sender: TObject);
begin
  if IsDataSetInEdit(dmMain.dsSystemOptions) then
  begin
    dmMain.dsSystemOptions.Cancel;
  end;
  dmMain.dsSystemOptions.CancelBatch;
  inherited;
end;

procedure TfmSystemOptions.FormCreate(Sender: TObject);
begin
  inherited;
  if dmMain.dsSystemOptions.Active then
    dmMain.dsSystemOptions.Close;
  dmMain.dsSystemOptions.Open;
  if dmMain.dsSystemOptions.IsEmpty then
    dmMain.dsSystemOptions.Append;
  chkUseSkin.Checked := pUseSkin;
end;

procedure TfmSystemOptions.btnOKClick(Sender: TObject);
begin
  if not CheckDataValid then
    Exit;
  if IsDataSetInEdit(dmMain.dsSystemOptions) then
  begin
    dmMain.dsSystemOptions.Post;
  end;
  dmMain.dsSystemOptions.UpdateBatch;
  pPrefix := edtPrefix.Text;
  pYearString := cbxYear.Text;
  pMonthString := cbxMonth.Text;
  pDayString := cbxDay.Text;
  pNoPlace := StrToIntDef(edtNoPlace.Text, 5);
  pRootPath := edtRootPath.Text;
  if (pRootPath <> '') and (RightStr(pRootPath, 1) <> '\') then
    pRootPath := pRootPath + '\';
  pUseSkin := chkUseSkin.Checked;
  inherited;
end;

procedure TfmSystemOptions.edtPrefixChange(Sender: TObject);
begin
  edtFormat.Text := dmMain.GetRunningNoFormat(edtPrefix.Text, cbxYear.Text, cbxMonth.Text, cbxDay.Text, StrToIntDef(edtNoPlace.Text, 0));
end;

{-----------------------------------------------------------------------------
  Procedure: TfmSystemOptions.CheckRunningNoFormat
  Purpose:   Check Running No. Format
  Arguments: None
  Result:    Boolean
  Author:    Cyclone
  History:   2004-12-9 23:27:10

-----------------------------------------------------------------------------}
function TfmSystemOptions.CheckRunningNoFormat: Boolean;
begin
  Result := False;
  if not ((StrToIntDef(edtNoPlace.Text, 0) >= 3) and (StrToIntDef(edtNoPlace.Text, 0) <= 9)) then
  begin
    ShowError('No. place must be ''3''..''9''');
    edtNoPlace.SetFocus;
    Exit;
  end;
  Result := True;
end;

{-----------------------------------------------------------------------------
  Procedure: TfmSystemOptions.CheckDataValid
  Purpose:   Check Data Valid
  Arguments: None
  Result:    Boolean
  Author:    Cyclone
  Date:      2005-3-24 22:09:44

-----------------------------------------------------------------------------}
function TfmSystemOptions.CheckDataValid: Boolean;
begin
  Result := False;
  if not DirectoryExists(edtRootPath.Text) then
  begin
    ShowError('Root path not exists!');
    edtRootPath.SetFocus;
    Exit;
  end;
  if not CheckRunningNoFormat then
    Exit;
  Result := True;
end;

procedure TfmSystemOptions.edtNoPlaceKeyPress(Sender: TObject;
  var Key: Char);
begin
  if not ((Key in ['3'..'9']) or (Ord(Key) = VK_BACK)) then
    Key := #0;
end;

end.

⌨️ 快捷键说明

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