ajgls.pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:14k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit ajgls;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ComCtrls, ToolWin, ExtCtrls, TFlatPanelUnit, TFlatSplitterUnit,
- TFlatGroupBoxUnit, StdCtrls, Grids, DBGrids, XPBarMenu, DB, DBClient,
- ImgList, Menus, ActnList, DBGridEh;
- type
- TAm_ajgl = class(TForm)
- StatusBar1: TStatusBar;
- CoolBar1: TCoolBar;
- ToolBar1: TToolBar;
- Panel1: TPanel;
- Panel2: TPanel;
- Tree: TTreeView;
- Splitter1: TSplitter;
- Panel3: TPanel;
- Panel4: TPanel;
- Splitter2: TSplitter;
- Panel5: TPanel;
- GroupBox1: TGroupBox;
- GroupBox2: TGroupBox;
- XPBarMenu1: TXPBarMenu;
- V_Ajgl: TDataSource;
- Ds_Wjgl2: TDataSource;
- ActionList1: TActionList;
- Add: TAction;
- Edit: TAction;
- Delete: TAction;
- Save: TAction;
- Refresh: TAction;
- Print: TAction;
- Quit: TAction;
- PopupMenu1: TPopupMenu;
- A1: TMenuItem;
- D1: TMenuItem;
- E1: TMenuItem;
- N5: TMenuItem;
- N6: TMenuItem;
- Add1: TToolButton;
- xiugai: TToolButton;
- dele1: TToolButton;
- refresh1: TToolButton;
- Ajgd1: TToolButton;
- ToolButton6: TToolButton;
- WJCZ: TToolButton;
- DBGridEh1: TDBGridEh;
- DBGridEh2: TDBGridEh;
- PopupMenu2: TPopupMenu;
- N7: TMenuItem;
- N8: TMenuItem;
- N9: TMenuItem;
- N11: TMenuItem;
- ClientDataSet1: TClientDataSet;
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure AddExecute(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure EditExecute(Sender: TObject);
- procedure QuitExecute(Sender: TObject);
- procedure TreeClick(Sender: TObject);
- procedure N7Click(Sender: TObject);
- procedure N8Click(Sender: TObject);
- procedure N9Click(Sender: TObject);
- procedure DBGridEh1DblClick(Sender: TObject);
- procedure RefreshExecute(Sender: TObject);
- procedure DeleteExecute(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure DBGridEh2DblClick(Sender: TObject);
- procedure TreeChange(Sender: TObject; Node: TTreeNode);
- procedure Ajgd1Click(Sender: TObject);
- procedure N5Click(Sender: TObject);
- procedure N6Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- procedure loadTree1(treeDb1,treeDb2:TClientDataSet);//初始化树
- end;
- var
- Am_ajgl: TAm_ajgl;
- gnode:TtreeNode;//当前节点
- lbjs_sm1,lbjs_sm2:string;//类别级数
- lb_dmgz1,lb_dmgz2:string;//代码规则
- dsState:string;//增删改的状态
- epos1,epos2:string;//取选中树节点的代码和名称
- s,ajgl_s1,ajgl_s2:string;//树节点文本,树节点代码
- implementation
- uses ajgl_bjs,ljszs,mainfrms, DMs,u_public, Am_ylj_bjs, Am_wjbjs,
- Am_ajgl_Ps;
- {$R *.dfm}
- procedure TAm_ajgl.loadTree1(treeDb1,treeDb2:TClientDataSet);//初始化树
- var
- nodeId1,nodeTxt1,nodeId2,nodeTxt2:string;
- SCodeFormat1,SCodeFormat2,SFirstNodeTxt:string;
- level1,level2:integer;
- mynode:array[0..6] of Ttreenode;
- i,j:integer;//循环标志
- begin
- //初始化变量
- SCodeFormat1:=lbjs_sm1 ;//系统案卷类别代码结构
- SCodeFormat2:=lbjs_sm2;//文件类别代码结构
- SFirstNodeTxt:= '案卷类别';//首节点显示的文字
- Screen.Cursor:=crHourGlass;
- Tree.enabled:=true;
- Tree.Items.Clear;
- level1:=0;
- //设置根节点
- mynode[level1]:=Tree.Items.Add(Tree.TopItem,SFirstNodeTxt);
- mynode[level1].ImageIndex:=0;
- mynode[level1].SelectedIndex:=1;
- //遍历数据表,利用编码字段记录排序规律,依次添加树节点
- for i:=0 to treedb1.RecordCount-1 do
- begin
- nodeId1:=trim(treedb1.fieldbyname('qz_dm').AsString);
- nodeTxt1:=nodeId1+'-'+trim(treedb1.fieldbyname('qz_mc').AsString);
- level1:=GetNodeLevel(SCodeFormat1,nodeId1);//获得节点层树
- if level1>0 then
- begin
- mynode[level1]:=tree.Items.AddChild(mynode[level1-1],nodeTxt1);
- mynode[level1].ImageIndex:=0;
- mynode[level1].SelectedIndex:=1;
- //----------
- end;
- //增加第一层主表
- treedb2.close;
- treedb2.commandtext:='select * from sz_ajlb where qz_dm='+''''+nodeId1+''''+'';
- treedb2.open;
- if trim(treedb2.FieldByName('qz_dm').AsString)<>'' then
- begin
- for j:=0 to treedb2.recordcount-1 do
- begin
- nodeId2:=trim(treedb2.fieldbyname('ajlb_dm').asstring);
- nodeTxt2:=NodeId2+'-'+trim(treedb2.fieldbyname('ajlb_mc').asstring);
- level2:=getNodeLevel(SCodeFormat2,nodeId2);//从表的层数
- if level2>1 then
- begin
- mynode[level2]:=tree.Items.AddChild(mynode[level2-1],nodeTxt2);
- mynode[level2].ImageIndex:=0;
- mynode[level2].SelectedIndex:=1;
- end;
- treedb2.Next;
- end;
- end
- else
- treedb2.Next;//不是符合条件的纪录
- treedb1.Next;//下一条纪录
- end;//end for
- mynode[0].Expand(false);
- screen.Cursor:=crdefault;
- end;
- //**************************************************************
- procedure TAm_ajgl.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- dm.V_ajgl.Active:=false;//预立卷视图
- dm.Am_ajgl.Active:=false;//案卷管理
- dm.sz_bgqx.Active:=false;//保管期限
- dm.sz_mj.active:=false;//密级
- //--------------------
- dm.sz_qz.Active:=false;//全宗
- dm.sz_ajlb.Active:=false;//案卷类别
- //---------------
- dm.sz_xtajlb.Active:=false;//系统案卷类别
- //---------------
- dm.xt_lbjs.Active:=false;//类别级数
- dm.Am_wjgl.active:=false;//文件管理
- dm.V_Wjgl2.Active:=false;//文件视图
- dm.sz_ztlb.Active:=false;//载体类别
- dm.sz_wjlb.active:=false;//文件类别
- dm.sz_bm.Active:=false;//部门
- action:=cafree;
- Am_ajgl:=nil;
- end;
- procedure TAm_ajgl.AddExecute(Sender: TObject);
- var n:integer;
- begin
- if tree.Selected=nil then exit//为空退出
- else
- if tree.Selected.HasChildren=false then
- begin
- dsState:='add';
- if AM_ajgl_bj=nil then
- begin
- AM_ajgl_bj:=TAM_ajgl_bj.create(application);
- dm.Am_ajgl.Close;
- dm.am_ajgl.CommandText:='select * from am_ajgl where aj_xh='+''''+''''+'';
- dm.Am_ajgl.Open;
- AM_ajgl_bj.showmodal;
- end;
- end;//判断是否到达最底层
- end;
- procedure TAm_ajgl.FormCreate(Sender: TObject);
- begin
- dm.Am_ajgl.Active:=true;//案卷管理
- dm.sz_bgqx.Active:=true;//保管期限
- dm.sz_mj.active:=true;//密级
- dm.sz_ztlb.Active:=true;//载体类别
- dm.sz_wjlb.active:=true;//文件类别
- dm.sz_bm.Active:=true;//部门
- //-------
- dm.sz_qz.Close;
- dm.sz_qz.CommandText:='select * from sz_qz';
- dm.sz_qz.Open;//全宗
- dm.sz_ajlb.Close;
- dm.sz_ajlb.CommandText:='select * from sz_ajlb';
- dm.sz_ajlb.Open;//案卷类别
- //---------------
- dm.sz_xtajlb.close;
- dm.sz_xtajlb.CommandText:='select * from sz_xtajlb';
- dm.sz_xtajlb.Open;//系统案卷类别
- //刷新两个表
- dm.xt_lbjs.Close;
- dm.xt_lbjs.CommandText:='select * from xt_lbjs where lb_dm='+''''+'sz_qz'+''''+'';
- dm.xt_lbjs.Open;//类别级数
- lbjs_sm1:=dm.xt_lbjs.fieldbyname('lbjs_sm').AsString;
- //调出主表的编码规则
- dm.xt_lbjs.Close;
- dm.xt_lbjs.CommandText:='select * from xt_lbjs where lb_dm='+''''+'sz_ajlb'+''''+'';
- dm.xt_lbjs.Open;
- lbjs_sm2:=dm.xt_lbjs.fieldbyname('lbjs_sm').asstring;
- //调出二级表的编码规则
- if dm.sz_qz.RecordCount<>0 then
- begin
- loadtree1(dm.sz_qz,dm.sz_ajlb);
- dm.sz_qz.Close;
- dm.sz_qz.CommandText:='select * from sz_qz';
- dm.sz_qz.Open;
- dm.sz_ajlb.Close;
- dm.sz_ajlb.CommandText:='select * from sz_ajlb';
- dm.sz_ajlb.Open;
- //装载树-------------------------------------------
- //dm.V_Wjgl2.Active:=true;
- end;
- end;
- procedure TAm_ajgl.EditExecute(Sender: TObject);
- var s:string;
- begin
- s:=dm.V_ajgl.fieldbyname('aj_xh').AsString;//修改是还有点问题,和表格有关
- if AM_ajgl_bj=Nil then
- begin
- dm.Am_ajgl.Close;
- dm.am_ajgl.CommandText:='select * from am_ajgl where aj_xh='+''''+s+''''+'';
- dm.Am_ajgl.Open;
- AM_ajgl_bj:=TAM_ajgl_bj.Create(self);
- AM_ajgl_bj.ShowModal;
- dm.Am_ajgl.Edit;
- end;
- end;
- procedure TAm_ajgl.QuitExecute(Sender: TObject);
- begin
- close;
- end;
- procedure TAm_ajgl.TreeClick(Sender: TObject);
- var
- i,Epos:integer;
- level:integer;
- begin
- Level:=tree.Selected.Level;
- if tree.selected=nil then
- exit
- else
- if Tree.Items[0].HasChildren<>false then
- begin //选中和不选中的图片显示
- for i:=0 to Tree.items.count-1 do
- begin
- if tree.Selected.HasChildren then
- exit //判断节点可否选中
- else
- if Level=1 then
- add1.Enabled:=false
- else
- begin
- Tree.Items[i].ImageIndex:=0;
- Tree.Items[i].SelectedIndex:=1;
- ajgl_s1:=Tree.Selected.Text;
- Epos:=pos('-',ajgl_s1);
- ajgl_s2:=copy(ajgl_s1,0,Epos-1);
- dm.V_Ajgl.Close;
- dm.V_ajgl.CommandText:='P_Ajgl'+''''+ajgl_s2+'''';
- dm.V_ajgl.Open; //案卷视图
- {dm.V_Wjgl2.Close;
- dm.V_Wjgl2.CommandText:='P_Wjgl';
- dm.V_Wjgl2.Open;//文件视图}
- dm.V_Wjgl2.Active:=true;
- dm.V_wjgl2.MasterSource:=V_ajgl;
- dm.V_wjgl2.MasterFields:='aj_xh';
- If dm.V_ajgl.RecordCount<>0 then
- begin
- add1.Enabled:=true;A1.Enabled:=true;
- xiugai.Enabled:=true;D1.Enabled:=true;
- dele1.Enabled:=true;E1.Enabled:=true;
- wjcz.Enabled:=true;
- ajgd1.Enabled:=true;
- end//设置按钮的状态
- else
- begin
- add1.Enabled:=true;A1.Enabled:=true;
- xiugai.Enabled:=false;D1.Enabled:=false;
- dele1.Enabled:=false;E1.Enabled:=false;
- wjcz.Enabled:=false;
- ajgd1.Enabled:=false;
- end;//数据表中无值
- end;
- end;
- end;
- end;
- procedure TAm_ajgl.N7Click(Sender: TObject);
- begin
- if am_ylj_bj=nil then
- begin
- Am_wjgl_bj:=TAm_wjgl_bj.create(application);
- dm.Am_wjgl.Close;
- dm.am_wjgl.CommandText:='select * from am_wjgl where wj_dm='+''''+''''+'';
- dm.Am_wjgl.Open;
- dm.Am_wjgl.Edit;
- Am_wjgl_bj.showmodal;
- end;
- end;
- procedure TAm_ajgl.N8Click(Sender: TObject);
- var s:string;
- begin
- s:=dm.V_Wjgl2.fieldbyname('wj_xh').AsString;
- if am_ylj_bj=Nil then
- begin
- dm.Am_wjgl.Close;
- dm.am_wjgl.CommandText:='select * from am_wjgl where wj_xh='+''''+s+''''+'';
- dm.Am_wjgl.Open;
- am_wjgl_bj:=Tam_wjgl_bj.Create(self);
- am_wjgl_bj.ShowModal;
- dm.Am_wjgl.Edit;
- end;
- end;
- procedure TAm_ajgl.N9Click(Sender: TObject);
- var
- s:string;
- begin
- s:=dm.V_Wjgl2.fieldbyname('wj_xh').AsString;
- if application.MessageBox('您确定要删除吗?','警告',mb_okcancel+mb_iconquestion)=idok then
- begin
- dm.Am_wjgl.Close;
- dm.Am_wjgl.CommandText:='delete from am_wjgl where wj_xh='+''''+s+''''+'';
- dm.Am_wjgl.Execute;
- dm.Am_wjgl.Close;
- dm.am_wjgl.CommandText:='select * from am_wjgl';
- dm.Am_wjgl.Open;
- dm.V_Wjgl2.Close;
- dm.V_Wjgl2.CommandText:='select * from v_Wjgl2';
- dm.V_Wjgl2.Open;
- end else
- exit;
- end;
- procedure TAm_ajgl.DBGridEh1DblClick(Sender: TObject);
- begin
- edit.Execute;
- end;
- procedure TAm_ajgl.RefreshExecute(Sender: TObject);
- begin
- dm.v_ajgl.Close;
- dm.v_ajgl.CommandText:='select * from v_ajgl where ajlb_dm='+''''+ajgl_s2+''''+'';
- dm.v_ajgl.Open;//刷新视图
- dm.V_wjgl2.MasterSource:=V_ajgl;
- dm.V_wjgl2.MasterFields:='aj_xh';
- end;
- procedure TAm_ajgl.DeleteExecute(Sender: TObject);
- var
- s,s1,s2:string;
- Epos:integer;
- begin
- s:=dm.V_ajgl.fieldbyname('aj_xh').AsString;
- if application.MessageBox('您确定要删除吗?','警告',mb_okcancel+mb_iconquestion)=idok then
- begin
- dm.Am_ajgl.Close;
- dm.Am_ajgl.CommandText:='delete from am_ajgl where aj_xh='+''''+s+''''+'';
- dm.Am_ajgl.Execute;
- dm.Am_ajgl.Close;
- dm.am_ajgl.CommandText:='select * from am_ajgl';
- dm.Am_ajgl.Open;
- s1:=Tree.Selected.Text;
- Epos:=pos('-',s1);
- s2:=copy(s1,0,Epos-1);
- dm.V_ajgl.Close;
- dm.V_ajgl.CommandText:='select * from V_ajgl where ajlb_dm='+''''+s2+''''+'';
- dm.V_ajgl.Open;
- if dm.v_ajgl.RecordCount=0 then
- begin
- ajgd1.Enabled:=false;
- xiugai.Enabled:=false;
- dele1.Enabled:=false;
- Wjcz.Enabled:=false;
- end
- end else
- exit;
- end;
- procedure TAm_ajgl.FormShow(Sender: TObject);
- begin
- frm_name:='am_ajgl';
- end;
- procedure TAm_ajgl.DBGridEh2DblClick(Sender: TObject);
- begin
- n8.Click;
- end;
- procedure TAm_ajgl.TreeChange(Sender: TObject; Node: TTreeNode);
- var i:integer;
- begin
- for i:=0 to Tree.items.count-1 do
- begin
- if tree.Selected.HasChildren then
- begin
- add1.Enabled:=false;
- xiugai.Enabled:=false;
- dele1.Enabled:=false;
- wjcz.Enabled:=false;
- ajgd1.Enabled:=false;
- end;
- end;//end for}
- end;
- procedure TAm_ajgl.Ajgd1Click(Sender: TObject);
- var s:string;
- begin
- s:=dbgrideh1.Fields[0].Text;
- dm.v_ajgl.Close;
- dm.v_ajgl.CommandText:='update v_ajgl set ajzt_mc=''归档案卷'',aj_gdjsrq=getdate() where aj_xh='+''''+s+''''+'';
- dm.v_ajgl.Execute;
- dm.v_ajgl.Close;
- dm.v_ajgl.CommandText:='select * from v_ajgl where ajlb_dm='+''''+ajgl_s2+''''+'';
- dm.v_ajgl.Open;
- if dm.v_ajgl.RecordCount=0 then
- begin
- ajgd1.Enabled:=false;
- xiugai.Enabled:=false;
- dele1.Enabled:=false;
- Wjcz.Enabled:=false;
- end;
- //案卷归档
- dm.V_Wjgl2.Close;
- dm.V_Wjgl2.CommandText:='update V_Wjgl2 set wj_gdrq=getdate() where aj_xh='+''''+s+''''+'';
- dm.V_Wjgl2.Execute;
- dm.V_Wjgl2.Close;
- dm.V_Wjgl2.CommandText:='select * from V_Wjgl2 where aj_xh='+''''+s+''''+'';
- dm.V_Wjgl2.Open;//文件归档
- end;
- procedure TAm_ajgl.N5Click(Sender: TObject);
- begin
- tree.Selected.Expand(true);
- end;
- procedure TAm_ajgl.N6Click(Sender: TObject);
- begin
- tree.Selected.Collapse(true);
- end;
- end.