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

📄 config.pas

📁 影院售票系统完整源码
💻 PAS
字号:
unit config;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ComCtrls,Inifiles, ExtCtrls, ImgList,
  CyberXPMenu, Spin, ColorGrd, Mask, CyberEdit,Unit_ADODM, DB, ADODB;

type
  TForm_config = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    BitBtn_save: TBitBtn;
    BitBtn_exit: TBitBtn;
    GroupBox4: TGroupBox;
    LblPort: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Image3: TImage;
    Label1: TLabel;
    ImageList1: TImageList;
    BitBtn1: TBitBtn;
    CyberXPMenu1: TCyberXPMenu;
    ColorDialog1: TColorDialog;
    Edtuser: TEdit;
    Edtdbname: TEdit;
    Label2: TLabel;
    Edtdbserver: TEdit;
    Edtpwd: TEdit;
    TabSheet2: TTabSheet;
    GroupBox1: TGroupBox;
    Label3: TLabel;
    Edttitle: TEdit;
    SpinEdit1: TSpinEdit;
    Label4: TLabel;
    Label5: TLabel;
    Edtlocalname: TEdit;
    GroupBox3: TGroupBox;
    Panel4: TPanel;
    Label8: TLabel;
    Label9: TLabel;
    Edt1: TCyberButtonEdit;
    Edt2: TCyberButtonEdit;
    ListView2: TListView;
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure BitBtn_exitClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BitBtn_saveClick(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure Edt1ButtonClick(Sender: TObject);
    procedure Edt2ButtonClick(Sender: TObject);
    procedure ListView2CustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
  private
    { Private declarations }
    procedure Getparams;
  public
    { Public declarations }

  end;

var
  Form_config: TForm_config;

implementation

uses unit_Public,unit_frmmain;

{$R *.dfm}

procedure TForm_config.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key=VK_Escape then Close;
  if key=13 then perform(WM_NEXTDLGCTL,0,0);
end;    

procedure TForm_config.BitBtn_exitClick(Sender: TObject);
begin
  Close;
end;

procedure TForm_config.FormShow(Sender: TObject);
begin
  Getparams;
end;


procedure TForm_config.BitBtn_saveClick(Sender: TObject);
var
  MyIniFile : TIniFile;
  _FileName : String;
  Cnstr     : string;
begin
  _FileName := ExtractFileDir(ParamStr(0))+'\jxparams.ini';
  if ( not FileExists(_FileName) ) then
  begin
    Application.MessageBox(pchar('配置文件不存在!'),pchar('警告'),MB_OK);
    exit;
  end;
  MyIniFile := TIniFile.Create(_FileName);
  try
    MyIniFile.WriteString('DataBase SetUp',  'DBServer',edtdbserver.Text);
    MyIniFile.WriteString('DataBase SetUp',  'DBName',edtdbname.Text);
    MyIniFile.WriteString('DataBase SetUp', 'UserName',edtuser.Text);
    MyIniFile.WriteString('DataBase SetUp', 'Pwd',edtpwd.Text);
    MyIniFile.WriteInteger('DataBase SetUp','TimeOut',SpinEdit1.Value);
    MyIniFile.WriteString('SysConfig','AppTitle',Edttitle.Text);
    MyIniFile.WriteString('SysConfig','Localname',Edtlocalname.Text);
    MyIniFile.WriteInteger('SysConfig', 'siglecolor'   ,publicinfo.SigleLineColor );
    MyIniFile.WriteInteger('SysConfig', 'doublecolor'  ,publicinfo.DoubleLineColor);
    cnstr:='Provider=SQLOLEDB.1;Persist Security Info=True; User ID='+edtuser.Text+
           ';Password='+edtpwd.Text+';Initial Catalog='+edtdbname.Text+';Data Source='+edtdbserver.Text;
    ADODM.ADOCN.Close ;
    try
      ADODM.ADOCN.ConnectionString :=Cnstr;
      ADODM.ADOCN.ConnectionTimeout:=SpinEdit1.Value;
      ADODM.ADOCN.Open ;
      frmmain.statusbar1.Panels[2].Text :='连接状态:连接成功';
    except
      on e:exception do
      begin
         application.MessageBox(pchar('连接数据库错误!'+e.Message),'连接数据库',mb_ok);
         frmmain.statusbar1.Panels[2].Text :='连接状态:连接失败' ;
      end;
    end;
  finally
    MyIniFile.Free;
  end;
end;



procedure TForm_config.BitBtn1Click(Sender: TObject);
begin
  Edtdbserver.Text := '127.0.0.1';
  Edtdbname.Text   := 'jxdb';
  Edtuser.Text     := 'sa';
end;

procedure TForm_config.Getparams;
var
  _FileName:string;
  MyIniFile:Tinifile;
  _pwd     :string;
begin
   _FileName     := ExtractFileDir(ParamStr(0))+'\jxparams.ini';
  if ( not FileExists(_FileName) ) then
  begin
    Application.MessageBox(pchar('配置文件不存在!'),pchar('警告'),MB_OK);
    exit;
  end;
  MyIniFile := TIniFile.Create(_FileName);
  try
    edtdbserver.Text    := MyIniFile.ReadString('DataBase SetUp',  'DBServer'       ,'127.0.0.1');
    edtdbname.Text      := MyIniFile.ReadString('DataBase SetUp',  'DBName'         ,'jxdb');
    edtuser.Text        := MyIniFile.ReadString('DataBase SetUp', 'UserName'      ,'sa');
    edtpwd.Text         := MyIniFile.ReadString('DataBase SetUp','Pwd','123');
    //edtpwd.Text       :=publicinfo.Decrypt(_pwd,userkey);
    spinedit1.Value     := MyIniFile.ReadInteger('DataBase SetUp', 'TimeOut'    ,5);
    application.Title   := MyIniFile.ReadString('SysConfig','AppTitle','嘉兴大剧院售票系统');
    Edtlocalname.text   := MyIniFile.ReadString('SysConfig','localname','本地售票机');
    publicinfo.SigleLineColor := MyIniFile.ReadInteger('SysConfig', 'siglecolor',$00CAF3BE);
    publicinfo.DoubleLineColor:= MyIniFile.ReadInteger('SysConfig', 'DoubleColor',$00EBFBE6);
    edttitle.Text       := application.Title;
    edt1.Color          :=publicinfo.SigleLineColor;
    edt2.Color          :=publicinfo.DoubleLineColor ;
  finally
    MyIniFile.Free;
  end;
end;

procedure TForm_config.Edt1ButtonClick(Sender: TObject);
begin
  if ColorDialog1.Execute then
  begin
     Edt1.Color                 :=ColorDialog1.Color ;
     publicinfo.SigleLineColor  :=ColorDialog1.Color;
     ListView2.Invalidate ;
  end;
end;

procedure TForm_config.Edt2ButtonClick(Sender: TObject);
begin
  if ColorDialog1.Execute then
  begin
     Edt2.Color                 :=ColorDialog1.Color ;
     publicinfo.DoubleLineColor :=ColorDialog1.Color;
     ListView2.Invalidate ;
  end;
end;

procedure TForm_config.ListView2CustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
  publicinfo.ListViewDraw(item,DefaultDraw)
end;

end.










⌨️ 快捷键说明

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