db_setdestination.pas
来自「亚惠快餐管理信息系统 包括亚惠快餐管理的各项功能」· PAS 代码 · 共 151 行
PAS
151 行
unit DB_SetDestination;
{
代码单元名称:通用数据库备份工具新建设备窗口
从属软件:大连资金清算中心打码机管理信息系统
开发单位:大连理工大学计算机技术研究所软件工程研究室
作者:王树润
时间:2001,1,30
}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, FileCtrl;
type
TDB_DfmSetDestination = class(TForm)
Label1: TLabel;
DestinationNameEdit: TEdit;
GroupBox1: TGroupBox;
DiskNameRadioButton: TRadioButton;
DiskAddressEdit: TEdit;
Label2: TLabel;
DriveComboBox1: TDriveComboBox;
DirectoryListBox1: TDirectoryListBox;
Button1: TButton;
Button2: TButton;
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure DiskNameRadioButtonClick(Sender: TObject);
procedure DriveComboBox1Change(Sender: TObject);
procedure DirectoryListBox1Change(Sender: TObject);
procedure DestinationNameEditChange(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MyServerName: string;
DestinationComboBox: TComboBox;
constructor Create(Owner: TComponent; AMyServerName: string;
ADestinationComboBox: TComboBox); overload;
end;
implementation
uses DB_DataModule1, PublicUnit;
{$R *.DFM}
constructor TDB_DfmSetDestination.Create(Owner: TComponent;
AMyServerName: string; ADestinationComboBox: TComboBox);
begin
inherited Create(Owner);
MyServerName := AMyServerName;
DestinationComboBox := ADestinationComboBox;
end;
//窗体==========================================================================
procedure TDB_DfmSetDestination.FormShow(Sender: TObject);
begin
DB_DfmDataModule1.ADOConnection1.ConnectionString :=
'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=' +
PublicUnit.DbUser
+ ';Password=' + PublicUnit.DbPass + ';Initial Catalog=master;Data Source='
+
PublicUnit.ServerName;
DiskNameRadioButton.Checked := True;
DirectoryListBox1.Drive := DriveComboBox1.Drive;
if copy(DirectoryListBox1.Directory, Pos(':\', DirectoryListBox1.Directory) +
2, 1) <> '' then
DiskAddressEdit.Text := DirectoryListBox1.Directory + '\'
else
DiskAddressEdit.Text := DirectoryListBox1.Directory;
end;
//关闭==========================================================================
procedure TDB_DfmSetDestination.Button2Click(Sender: TObject);
begin
DB_DfmDataModule1.ADOQuery1.Close;
DB_DfmDataModule1.ADOConnection1.Close;
Close;
end;
//确认==========================================================================
procedure TDB_DfmSetDestination.Button1Click(Sender: TObject);
begin
if DestinationNameEdit.Text = '' then
begin
ShowMessage('请输入设备逻辑名称!');
Exit;
end;
with DB_DfmDataModule1.ADOQuery1 do
begin
Close;
Sql.Clear;
if DiskNameRadioButton.Checked = True then
Sql.Add('sp_addumpdevice ''disk'',''' + DestinationNameEdit.Text + ''','''
+ DiskAddressEdit.Text + DestinationNameEdit.Text + '.BAK''');
try
ExecSQL;
except
ShowMessage('error');
Exit;
end;
end;
DestinationComboBox.Items.Add(DestinationNameEdit.Text);
DestinationComboBox.ItemIndex :=
DestinationComboBox.Items.IndexOf(DestinationNameEdit.Text);
DB_DfmDataModule1.ADOQuery1.Close;
DB_DfmDataModule1.ADOConnection1.Close;
Close;
end;
//其它按钮======================================================================
procedure TDB_DfmSetDestination.DiskNameRadioButtonClick(Sender: TObject);
begin
DriveComboBox1.Enabled := True;
DirectoryListBox1.Enabled := True;
end;
procedure TDB_DfmSetDestination.DriveComboBox1Change(Sender: TObject);
begin
DirectoryListBox1.Drive := DriveComboBox1.Drive;
end;
procedure TDB_DfmSetDestination.DirectoryListBox1Change(Sender: TObject);
begin
if copy(DirectoryListBox1.Directory, Pos(':\', DirectoryListBox1.Directory) +
2, 1) <> '' then
DiskAddressEdit.Text := DirectoryListBox1.Directory + '\'
else
DiskAddressEdit.Text := DirectoryListBox1.Directory;
end;
procedure TDB_DfmSetDestination.DestinationNameEditChange(Sender: TObject);
begin
if Pos('.', DestinationNameEdit.Text) <> 0 then
begin
ShowMessage('不用输入扩展名!');
DestinationNameEdit.Text := '';
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?