【delphi开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了delphi开源代码-Dictionary_info_u.pas的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
{
unit name : Dictionary_info_U
Author : 李涛
Create date:
description: 字典信息管理
}
unit Dictionary_info_u;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, DB, ADODB, Grids, DBGrids, ComCtrls, ExtCtrls,
StdCtrls, Buttons, inifiles;
type
TreePoint = ^TreeData; //定义结构指针
TreeData = record //定义树列结构
Value: String; //值
Parent: String; //父节点
Kind: String; //作用范围,[如项目类别、商品类别编码]
Mode: String; //模块编号
end;
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
TDictionary_info = class(TForm)
PanelTop: TPanel;
Panel_ICO: TPanel;
Fun_ICO: TImage;
PanelTopText: TPanel;
PanelBottom: TPanel;
Panel2: TPanel;
App_ICO: TImage;
PanelBottomText: TPanel;
ADD_Bit: TBitBtn;
Edit_Bit: TBitBtn;
Del_Bit: TBitBtn;
Splitter1: TSplitter;
TreeView1: TTreeView;
Dictionary_DBGrid: TDBGrid;
Dictionary_ADO: TADOQuery;
Dictionary_DataSource: TDataSource;
Tree_ADO: TADOQuery;
ImageList1: TImageList;
ADOConnection1: TADOConnection;
Dictionary_ADOC_sort_code: TStringField;
Dictionary_ADOC_code: TStringField;
Dictionary_ADOC_name: TStringField;
Dictionary_ADOC_bz: TStringField;
Dictionary_ADOC_stop: TStringField;
Stop_ADO: TADOQuery;
Dictionary_ADOstop: TStringField;
procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
procedure FormShow(Sender: TObject);
procedure ADD_BitClick(Sender: TObject);
procedure Edit_BitClick(Sender: TObject);
procedure Del_BitClick(Sender: TObject);
//--------------------树结构指针--------------------------------------------
private
Tree_Sel : TTreeNode;
Tree_Point: TreePoint;
procedure Tree_star;
{ Private declarations }
public
{ Public declarations }
end;
var
Dictionary_info: TDictionary_info;
MySelf: TSelf; //程序内部描述信息.
implementation
uses Dictionary_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 Dictionary_info 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 TDictionary_info.Tree_star;
var
TreeList: TTreeNode;
TreeChild: TTreeNode;
TreeValues: TreePoint; //Public_Unit_U中自定义结构指针类型
begin
With Tree_ADO do
begin
Close;
SQL.clear;
SQL.Add('Select * From T_dia_dictionary_sort');
SQL.Add('Where C_kind=:flag and C_stop=:stop');
Parameters.ParamByName('flag').Value:='1';
Parameters.ParamByName('stop').Value:='0';
Open;
TreeView1.Items.Clear;
TreeList:=TreeView1.Items.Add(nil,'字典信息');
TreeList.ImageIndex:=0;
TreeList.SelectedIndex:=0;
while not EOF do
begin
New(TreeValues);
TreeValues.Value:=FieldByName('C_code').asString;
TreeValues.parent:='0';
TreeChild:=TreeView1.Items.AddChildObject(TreeList,FieldByName('C_name').asString,TreeValues);
TreeChild.ImageIndex:=1;
TreeChild.SelectedIndex:=2;
//这里没有将分配的内存释放,需要注意释放此处内存,将会防问不道指针内的内容。
//Dispose(TreeValues);
Next;
end;
TreeView1.FullExpand;
end;
end;
procedure TDictionary_info.TreeView1Change(Sender: TObject;
Node: TTreeNode);
begin
//Tree_Sel:=TreeView1.Selected;
Tree_Sel:=Node;
if Tree_Sel<>nil then
if Tree_Sel.Level>0 then //当前不是第一层
begin
Tree_Point:=Tree_Sel.Data;
With Dictionary_ADO do
begin
DisableControls;
Close;
SQL.Clear;
SQL.Add('Select * From T_dia_dictionary');
SQL.Add('Where C_sort_code=:kind');
SQL.Add('Order by C_code');
Parameters.ParamByName('kind').Value:=Tree_Point.Value;
Open;
EnableControls;
end;
end;
end;
procedure TDictionary_info.FormShow(Sender: TObject);
begin
StartPublicParameter;
ActionDatabase;
Tree_star;
end;
procedure TDictionary_info.ADD_BitClick(Sender: TObject);
begin
if Dictionary_ADO.Active then
if not Assigned(Dictionary_Browser) then
begin
Dictionary_Browser:=TDictionary_Browser.create(Self);
Dictionary_Browser.State:='insert';
Dictionary_ADO.Append;
Dictionary_Browser.label5.Caption:=Tree_Sel.Text;
Dictionary_Browser.label6.Caption:=Tree_Point.Value;
Dictionary_Browser.ShowModal;
end;
end;
procedure TDictionary_info.Edit_BitClick(Sender: TObject);
begin
if Dictionary_ADO.Active then
if Dictionary_ADO.RecordCount>0 then
begin
//判断当前记录是否是系统级[0]信息,如果是系统[0]级,不准许修改。
{if
上一篇:
frmgoodstable.frm
下一篇:
经典心理语录净化心灵