Am_yljs.pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:15k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Am_yljs;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ImgList, DB, DBClient, XPBarMenu, Grids, DBGrids, StdCtrls,
- ComCtrls, ExtCtrls, ToolWin, Menus, ActnList, DBGridEh;
- type
- TAm_ylj = class(TForm)
- CoolBar1: TCoolBar;
- ToolBar1: TToolBar;
- add1: TToolButton;
- dele1: TToolButton;
- YLJ1: TToolButton;
- WJCZ: TToolButton;
- Panel1: TPanel;
- Splitter1: TSplitter;
- Panel2: TPanel;
- Tree: TTreeView;
- Panel3: TPanel;
- Splitter2: TSplitter;
- Panel4: TPanel;
- GroupBox1: TGroupBox;
- Panel5: TPanel;
- GroupBox2: TGroupBox;
- 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;
- xiugai: TToolButton;
- ToolButton3: TToolButton;
- V_ylj: TDataSource;
- DBGridEh1: TDBGridEh;
- ToolButton1: TToolButton;
- PopupMenu2: TPopupMenu;
- N7: TMenuItem;
- N8: TMenuItem;
- N9: TMenuItem;
- N11: TMenuItem;
- Ds_Wjgl: TDataSource;
- DBGridEh2: TDBGridEh;
- XPBarMenu2: TXPBarMenu;
- ClientDataSet1: TClientDataSet;
- ClientDataSet2: TClientDataSet;
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure AddExecute(Sender: TObject);
- procedure QuitExecute(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure EditExecute(Sender: TObject);
- procedure TreeClick(Sender: TObject);
- procedure RefreshExecute(Sender: TObject);
- procedure DeleteExecute(Sender: TObject);
- procedure N7Click(Sender: TObject);
- procedure N8Click(Sender: TObject);
- procedure DBGridEh1DblClick(Sender: TObject);
- procedure N9Click(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure DBGridEh2DblClick(Sender: TObject);
- procedure YLJ1Click(Sender: TObject);
- procedure N5Click(Sender: TObject);
- procedure N6Click(Sender: TObject);
- procedure TreeChange(Sender: TObject; Node: TTreeNode);
- private
- { Private declarations }
- public
- { Public declarations }
- epos1,EPos2,s_ajlb:string;//代码,名称值
- procedure loadTree1(treeDb1,treeDb2:TClientDataSet);//初始化树
- end;
- var
- Am_ylj: TAm_ylj;
- gnode:TtreeNode;//当前节点
- lbjs_sm1,lbjs_sm2:string;//类别级数
- lb_dmgz1,lb_dmgz2:string;//代码规则
- dsState:string;//增删改的状态
- ylj_s1,ylj_s2:string;
- s_ajxh:string;//案卷序号
- implementation
- uses mainfrms,dms, Am_ylj_bjs,u_public, Am_wjbjs;
- {$R *.dfm}
- procedure Tam_ylj.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_ylj.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- dm.V_ylj.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_Wjgl.Active:=false;//文件视图
- dm.sz_ztlb.Active:=false;//载体类别
- dm.sz_wjlb.active:=false;//文件类别
- dm.sz_bm.Active:=false;//部门
- action:=cafree;
- Am_ylj:=nil;
- end;
- procedure TAm_ylj.AddExecute(Sender: TObject);//增加
- var n:integer;
- begin
- if tree.Selected=nil then exit//为空退出
- else
- if tree.Selected.HasChildren=false then
- begin
- dsState:='add';
- n:=pos('-',tree.selected.Text)-1;
- epos1:=copy(tree.Selected.Text,1,n);//案卷代码
- Epos2:=copy(tree.Selected.Text,n+2,length(tree.Selected.Text));
- if am_ylj_bj=nil then
- begin
- am_ylj_bj:=Tam_ylj_bj.create(application);
- am_ylj_bj.DBEditEh1.Text:=Epos2;
- dm.Am_ajgl.Close;
- dm.am_ajgl.CommandText:='select * from am_ajgl where aj_dm='+''''+''''+'';
- dm.Am_ajgl.Open;
- am_ylj_bj.showmodal;
- end;
- end;//判断是否到达最底层
- end;
- procedure TAm_ylj.QuitExecute(Sender: TObject);
- begin
- close;
- end;
- procedure TAm_ylj.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;
- //装载树------------------
- end;
- end;
- //******************************************************************************
- procedure TAm_ylj.EditExecute(Sender: TObject);
- var s:string;
- begin
- s:=dm.V_ylj.fieldbyname('aj_xh').AsString;
- if am_ylj_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_ylj_bj:=Tam_ylj_bj.Create(self);
- am_ylj_bj.ShowModal;
- dm.Am_ajgl.Edit;
- end;
- end;
- //******************************************************************************
- procedure TAm_ylj.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;
- tree.Items[i].EndEdit(true) ;
- ylj_s1:=Tree.Selected.Text;
- Epos:=pos('-',ylj_s1);
- ylj_s2:=copy(ylj_s1,0,Epos-1);//案卷类别代码
- dm.V_ylj.Close;
- dm.V_ylj.CommandText:='select * from V_ylj where ajlb_dm='+''''+ylj_s2+''''+'';
- dm.V_ylj.Open;//查询有问题
- dm.Am_wjgl.Close;
- dm.Am_wjgl.CommandText:='select * from am_wjgl';
- dm.Am_wjgl.Open;//文件管理
- dm.V_Wjgl.Close;
- dm.V_Wjgl.CommandText:='select * from v_wjgl';
- dm.V_Wjgl.Open;//文件视图
- dm.V_wjgl.MasterSource:=V_ylj;
- dm.V_wjgl.MasterFields:='aj_xh';//说明当前ylj表中无值
- s_ajxh:=dm.v_ylj.fieldbyname('aj_xh').AsString;
- if dm.V_ylj.RecordCount<>0 then
- begin
- add1.Enabled:=true;A1.Enabled:=true;
- xiugai.Enabled:=true;E1.Enabled:=true;
- dele1.Enabled:=true;D1.Enabled:=true;
- wjcz.Enabled:=true;
- ylj1.Enabled:=true;
- end//设置按钮的状态
- else
- begin
- add1.Enabled:=true;A1.Enabled:=true;
- xiugai.Enabled:=false;E1.Enabled:=false;
- dele1.Enabled:=false;D1.Enabled:=false;
- wjcz.Enabled:=false;
- ylj1.Enabled:=false;
- end;//数据表中无值
- end;
- end;//end for
- end;
- end;
- //******************************************************************************
- procedure TAm_ylj.RefreshExecute(Sender: TObject);
- begin
- dm.V_ylj.Close;
- dm.V_ylj.CommandText:='select * from V_ylj where ajlb_dm='+''''+ylj_s2+''''+'';
- dm.V_ylj.Open;//刷新视图
- dm.V_Wjgl.Close;
- dm.V_Wjgl.Close;
- dm.V_Wjgl.CommandText:='select * from v_wjgl';
- dm.V_Wjgl.Open;//文件视图
- dm.V_wjgl.MasterSource:=V_ylj;
- dm.V_wjgl.MasterFields:='aj_xh';//说明当前ylj表中无值
- end;
- //******************************************************************************
- procedure TAm_ylj.DeleteExecute(Sender: TObject);
- var
- s:string;
- begin
- s:=dm.V_ylj.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;
- dm.V_ylj.Close;
- dm.V_ylj.CommandText:='select * from V_ylj where ajlb_dm='+''''+ylj_s2+''''+'';
- dm.V_ylj.Open;//刷新视图
- If dm.v_ylj.RecordCount=0 then
- begin
- xiugai.Enabled:=false;
- dele1.Enabled:=false;
- Ylj1.Enabled:=false;
- Wjcz.Enabled:=false;
- end
- end else
- exit;
- end;
- procedure TAm_ylj.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_ylj.N8Click(Sender: TObject);
- var s:string;
- begin
- s:=dm.V_Wjgl.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_ylj.DBGridEh1DblClick(Sender: TObject);
- begin
- edit.Execute;//修改
- end;
- procedure TAm_ylj.N9Click(Sender: TObject);
- var
- s:string;
- begin
- s:=dm.V_Wjgl.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_Wjgl.Close;
- dm.V_Wjgl.CommandText:='select * from v_Wjgl';
- dm.V_Wjgl.Open;
- end else
- exit;
- end;
- procedure TAm_ylj.FormShow(Sender: TObject);
- begin
- frm_name:='am_ylj';
- end;
- procedure TAm_ylj.DBGridEh2DblClick(Sender: TObject);
- begin
- n8.Click;
- end;
- procedure TAm_ylj.YLJ1Click(Sender: TObject);
- var s:string;
- begin
- s:=dbgrideh1.Fields[0].Text;
- dm.V_ylj.Close;
- dm.V_ylj.CommandText:='update v_ylj set ajzt_mc=''案卷'',aj_bzqsrq=getdate(),aj_gdqsrq=getdate() where aj_xh='+''''+s+''''+'';
- dm.V_ylj.Execute;
- dm.V_ylj.Close;
- dm.V_ylj.CommandText:='select * from v_ylj where ajlb_dm='+''''+ylj_s2+''''+'';
- dm.v_ylj.Open;
- If dm.v_ylj.RecordCount=0 then
- begin
- xiugai.Enabled:=false;
- dele1.Enabled:=false;
- Ylj1.Enabled:=false;
- Wjcz.Enabled:=false;
- end;
- //预立卷归卷
- dm.V_Wjgl.Close;
- dm.V_Wjgl.CommandText:='update V_Wjgl set wj_rq=getdate(),wj_gdrq=getdate() where aj_xh='+''''+s+''''+'';
- dm.V_Wjgl.Execute;
- dm.V_Wjgl.Close;
- dm.V_Wjgl.CommandText:='select * from V_Wjgl where aj_xh='+''''+s+''''+'';
- dm.V_Wjgl.Open;//文件管理
- end;
- procedure TAm_ylj.N5Click(Sender: TObject);
- begin
- tree.Selected.Expand(true);
- end;
- procedure TAm_ylj.N6Click(Sender: TObject);
- begin
- tree.Selected.Collapse(true);
- end;
- procedure TAm_ylj.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;
- ylj1.Enabled:=false;
- end
- else if tree.Items[1].Selected then
- begin
- add1.Enabled:=false;
- xiugai.Enabled:=false;
- dele1.Enabled:=false;
- wjcz.Enabled:=false;
- ylj1.Enabled:=false;
- end;
- end;//end for}
- end;
- end.