📄 codemanager.~pas
字号:
//
//模块名称:代码管理
//编写:陈剑
//日期:2001年11月14日
//修改:2002年1月28日
//参数说明:CodeRule:分级规则 CodeLen:代码长度 ExprLen:中文解释长度
//
unit codemanager;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, basewin, ActnList, ImgList, Menus, ComCtrls, ToolWin, ExtCtrls,
DB, DBTables, Grids, DBGrids, XPMenu, fcTreeView, StdCtrls, fcCombo,
fctreecombo, TFlatCheckListBoxUnit;
type
Tcodemanager_form = class(Tbasewin_frm)
Panel2: TPanel;
Panel3: TPanel;
Splitter1: TSplitter;
Splitter2: TSplitter;
Panel4: TPanel;
Query1: TQuery;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
fcTreeView1: TfcTreeView;
fcTreeView2: TfcTreeView;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
MainMenu1: TMainMenu;
exit_menu: TMenuItem;
exit_submenu: TMenuItem;
exit_but: TAction;
ToolButton5: TToolButton;
N1: TMenuItem;
help_but: TAction;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ListView1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
procedure fcTreeView2Click(Sender: TObject);
procedure FlashList(tab1,tab2:String);
procedure FlashList1(tab1,tab2:String);
procedure ListNode(L,H,id:integer;item:TfcTreeNode);
procedure fcTreeView1Click(Sender: TObject);
procedure exit_butExecute(Sender: TObject);
procedure help_butExecute(Sender: TObject);
private
CodeRule:string; //CodeRule:分级规则
CodeLen,ExprLen:integer; //CodeLen:代码长度 ExprLen:中文解释长度
RootItem,FirstChildItem:TTreeNode;
public
{ Public declarations }
end;
type
Tcode=record
parentid:integer; //父节点编码
id:integer; //ID编码
e_expr:string; //编码
c_brif:string; //字符:
end;
var
codemanager_form: Tcodemanager_form;
code:array of Tcode;
implementation
uses datashare, hh, hh_funcs, main;
{$R *.dfm}
procedure Tcodemanager_form.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
if query1.Active then
query1.Close;
end;
procedure Tcodemanager_form.ListView1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
//按键为enter,向上,向下,HOME,END,PAGEUP,PAGEDOWN
{if (key in [13,40,38,34,33,35,36]) then
ListView1Click(self);}
end;
procedure Tcodemanager_form.FormCreate(Sender: TObject);
var
Str:string;
NewItem,RootItem:TfcTreeNode;
begin
inherited;
try
with datashare_form.Query1 do
begin
close;
sql.Clear;
str:='select C_Expr,C_Brif,busy from code order by C_Expr';
sql.Add(str);
prepare;
open;
while not eof do
begin
NewItem:=fcTreeView2.Items.AddChild(fcTreeView2.Items.GetFirstNode,fieldbyname('C_Brif').asstring);
NewItem.StringData:=fieldbyname('C_Expr').AsString;
NewItem.StringData2:=fieldbyname('busy').AsString;
next;
end;
end;
except
on e:exception do
application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
end;
fcTreeView2.FullExpand;
end;
procedure Tcodemanager_form.fcTreeView2Click(Sender: TObject);
var
CurItem:TfcTreeNode;
begin
inherited;
query1.Close;
CurItem:=fcTreeView2.Selected;
if CurItem.Level=1 then
begin
if CurItem.StringData2='0' then
FlashList(CurItem.StringData,CurItem.Text)
else
FlashList1(CurItem.StringData,CurItem.Text);
end;
end;
procedure Tcodemanager_form.FlashList(tab1,tab2:string);
var
RootItem,NewItem:TfcTreeNode;
str:string;
i,k:integer;
begin
fcTreeView1.Items.Clear;
RootItem:=fcTreeView1.Items.Add(nil,tab2);
RootItem.StringData:='0';
try
with datashare_form.Query1 do
begin
close;
sql.Clear;
str:='select parentid,id,e_expr,c_brif from codetab where C_Expr=:p1 and choose=:p2 order by parentid,id';
sql.Add(str);
params[0].AsString:=tab1;
params[1].AsString:='0';
prepare;
open;
setlength(code,recordcount);
k:=0;
while not eof do
begin
code[k].parentid:=fieldbyname('parentid').AsInteger;
code[k].id:=fieldbyname('id').AsInteger;
code[k].e_expr:=fieldbyname('e_expr').AsString;
code[k].c_brif:=fieldbyname('c_brif').AsString;
inc(k);
next;
end;
end;
except
on e:exception do
application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
end;
for i:=low(code) to high(code) do
begin
if code[i].parentid=0 then
begin
NewItem:=fcTreeView1.Items.AddChild(RootItem,code[i].c_brif);
NewItem.StringData:=inttostr(code[i].id);
ListNode(i,high(code),code[i].id,NewItem);
end;
end;
end;
procedure Tcodemanager_form.FlashList1(tab1,tab2:string);
var
RootItem,NewItem:TfcTreeNode;
str:string;
i:integer;
begin
fcTreeView1.Items.Clear;
RootItem:=fcTreeView1.Items.Add(nil,tab2);
RootItem.StringData:='0';
try
with datashare_form.Query1 do
begin
close;
sql.Clear;
str:='select code,name from sbcode where type=:p1';
sql.Add(str);
params[0].AsString:=tab1;
prepare;
open;
while not eof do
begin
NewItem:=fctreeView1.Items.AddChild(RootItem,fieldbyname('name').Value);
next;
end;
end;
except
on e:exception do
application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
end;
end;
procedure Tcodemanager_form.ListNode(L,H,id:integer;item:TfcTreeNode);
var
i:integer;
NewItem:TfcTreeNode;
begin
for i:=L to H do
begin
if code[i].parentid=id then
begin
NewItem:=fcTreeView1.Items.AddChild(item,code[i].c_brif);
NewItem.StringData:=inttostr(code[i].id);
ListNode(i,H,code[i].id,NewItem);
end;
end;
end;
procedure Tcodemanager_form.fcTreeView1Click(Sender: TObject);
var
Str:string;
CurItem:TfcTreeNode;
begin
inherited;
if fcTreeView2.Selected.StringData2='0' then
begin
CurItem:=fcTreeView1.Selected;
try
with query1 do
begin
close;
sql.Clear;
Str:='select e_expr,c_brif from codetab where C_Expr=:p1 and choose=:p2 and parentid=:p3';
sql.Add(Str);
params[0].AsString:=fcTreeView2.Selected.StringData;
params[1].AsString:='0';
params[2].AsInteger:=strtoint(CurItem.StringData);
prepare;
open;
end;
except
on e:exception do
application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
end;
end else
begin
try
with query1 do
begin
close;
sql.Clear;
Str:='select code as e_expr,name as c_brif from sbcode where type=:p1';
sql.Add(str);
params[0].AsString:=fctreeview2.Selected.StringData;
prepare;
open;
end;
except
on e:exception do
application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
end;
end;
end;
procedure Tcodemanager_form.exit_butExecute(Sender: TObject);
begin
inherited;
//退出当前模块
if Application.MessageBox('您真的要退出当前操作吗?','退出确认',MB_OKCancel+MB_DEFBUTTON1+MB_IconQuestion+MB_SystemModal)=IdOk then
close;
end;
procedure Tcodemanager_form.help_butExecute(Sender: TObject);
begin
inherited;
if (HHCtrlHandle = 0) then
application.MessageBox('帮助文件不存在!','恩普软件',MB_OK+MB_IconStop+MB_SystemModal)
else
FHelpSystemHook.HelpContext(1080200);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -