【delphi开源代码栏目提醒】:网学会员鉴于大家对delphi开源代码十分关注,论文会员在此为大家搜集整理了“Author_u.pas”一文,供大家参考学习
unit Author_u;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids, DB, ADODB, QuickRpt,
inifiles;
type
TSelf = record //自身定义的记录类型。记录着登陆基础信息。
//--------------------应用程序参数部分--------------------------------------
AppPath: String; //工作路径
SourcePath: String; //资源路径
AppIcon: String; //当前模块应用图标路径文件名
//--------------------About软件关于部分信息---------------------------------
Software: String; //软件名称
Copyright: String; //版权所有(C)
Edition: String; //版本
Droit: String; //产品使用权属于
Soft_UserName: String; //软件使用注册人
Soft_Company: String; //软件使用注册公司
//--------------------数据库的连接信息--------------------------------------
DBServer: String; //数据库服务器
DBName: String; //数据库名称
DBLogon: String; //登陆用户
DBPass: String; //登陆数据库密码
end;
type
TAuthor = class(TForm)
DBGrid1: TDBGrid;
ADOConnection1: TADOConnection;
Author_ADO: TADOQuery;
DataSource1: TDataSource;
Author_ADODec_id: TBCDField;
Author_ADOC_name: TStringField;
Author_ADOC_Sex: TStringField;
Author_ADODt_birthday: TDateTimeField;
Author_ADOC_genre: TStringField;
Author_ADOC_company: TStringField;
Author_ADOIm_Photo: TBlobField;
Author_ADOC_stop: TStringField;
Author_ADOT_bz: TMemoField;
Author_ADOC_zjm: TStringField;
QuickRep1: TQuickRep;
PanelTop: TPanel;
Panel_ICO: TPanel;
Fun_ICO: TImage;
PanelTopText: TPanel;
PanelBottom: TPanel;
Panel2: TPanel;
App_ICO: TImage;
PanelBottomText: TPanel;
Add_but: TBitBtn;
Edit_but: TBitBtn;
Del_but: TBitBtn;
Find_but: TBitBtn;
print_but: TBitBtn;
procedure FormShow(Sender: TObject);
procedure Add_butClick(Sender: TObject);
procedure Edit_butClick(Sender: TObject);
procedure Del_butClick(Sender: TObject);
procedure Find_butClick(Sender: TObject);
procedure print_butClick(Sender: TObject);
procedure QuickRep1Preview(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Author: TAuthor;
MySelf: TSelf; //程序内部描述信息.
implementation
uses Author_info_Browser_u, PublicQuery_u_a, Print_Browser_U;
{$R *.dfm}
{1}//--------------------------------------------------------------------------
procedure StartPublicParameter;
var
AppIni: TiniFile;
begin
with MySelf do
begin
try
GetDir(0,AppPath);
AppIni:=TiniFile.Create(AppPath+'\System.ini');
SourcePath:=AppIni.ReadString('system','SourcePath',SourcePath);
DBServer:=AppIni.ReadString('Database','DBServer',DBServer);
DBName:=AppIni.ReadString('Database','DBName',DBName);
DBLogon:=AppIni.ReadString('Database','DBLogon',DBLogon);
DBPass:=AppIni.ReadString('Database','DBPass',DBPass);
//------------About信息----------------------------------
Software:=AppIni.ReadString('About','Software',Software);
Copyright:=AppIni.ReadString('About','Copyright',Copyright);
Edition:=AppIni.ReadString('About','Edition',Edition);
Droit:=AppIni.ReadString('About','Droit',Droit);
Soft_UserName:=AppIni.ReadString('About','Soft_UserName',Soft_UserName);
Soft_Company:=AppIni.ReadString('About','Soft_Company',Soft_Company);
//-------------------------------------------------------
finally
AppIni.Free;
AppIni:=nil;
end;
end;
end;
{2}//-------------------------------------------------------------------------
procedure ActionDatabase;
begin
With MySelf do
with Author do
begin
try
ADOConnection1.Close;
ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;'+
'Password='+DBPass+';'+
'Persist Security Info=True;'+
'User ID='+DBLogon+';'+
'Initial Catalog='+DBName+';'+
'Data Source='+DBServer+';';
ADOConnection1.Open;
except
//运行注册数据库程序。
end;
end;
end;
procedure TAuthor.FormShow(Sender: TObject);
begin
StartPublicParameter;
ActionDatabase;
Author_ADO.Open;
QuickRep1.Hide;
end;
procedure TAuthor.Add_butClick(Sender: TObject);
begin
if Author_ADO.Active then
if not Assigned(Author_info_Browser) then
begin
Author_info_Browser:=TAuthor_info_Browser.create(Self);
Author_info_Browser.State:='insert';
Author_ADO.Append;
Author_info_Browser.ShowModal;
end;
end;
procedure TAuthor.Edit_butClick(Sender: TObject);
begin
if Author_ADO.Active then
if Author_ADO.RecordCount>0 then
begin
//判断当前记录是否是系统级[0]信息,如果是系统[0]级,不准许修改。
{if Dictionary_ADO.FieldByName('C_flag').Value='0' then
begin
ShowMessage('此条记录是系统信息记录,不准许修改或删除。');
end
else}
if not Assigned(Author_info_Browser) then
begin
Author_info_Browser:=TAuthor_info_Browser.create(Self);
Author_info_Browser.State:='update';
Author_ADO.Edit;
Author_info_Browser.ShowModal;
end;
end;
end;
procedure TAuthor.Del_butClick(Sender: TObject);
begin
if Author_ADO.Active then
if Author_ADO.RecordCount>0 then
begin
if MessageDlg('确认要将['+Author_ADO.FieldByName('C_name').asString+']删除?',mtCustom,[mbYes,mbNo],0)=mrYes then
Author_ADO.Delete;
end;
end;
procedure TAuthor.Find_butClick(Sender: TObject);
begin
if Author_ADO.Active then
if not Assigned(PublicQuery) then
begin
PublicQuery:=TPublicQuery.Create(self);
PublicQuery.ADO_name:=Author_ADO.Name;
PublicQuery.ShowModal;
end;
end;
procedure TAuthor.print_butClick(Sender: TObject);
begin
if (Author_ADO.Active) and (Author_ADO.RecordCount>0) then
if not Print_Browser.Visible then
begin
Print_Browser.Show;
QuickRep1.Preview;
end
else
begin
Print_Browser.SetFocus;
Print_Browser.WindowState:=wsMaximized;
end;
end;
procedure TAuthor.QuickRep1Preview(Sender: TObject);
begin
Print_Browser.QRPreview1.QRPrinter:=QuickRep1.QRPrinter;
end;
end.
上一篇:
Departments.cpp
下一篇:
网络能耗监测系统管理端的研究与实现