Am_gdajs.pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:13k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Am_gdajs;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, XPBarMenu, DB, Menus, ActnList, Grids, DBGridEh, StdCtrls,
- ComCtrls, ExtCtrls, ToolWin, DBClient, ImgList;
- type
- TAm_gdaj = class(TForm)
- CoolBar1: TCoolBar;
- ToolBar1: TToolBar;
- AJCD: TToolButton;
- AJRK: TToolButton;
- AJCK: TToolButton;
- REFRESH1: TToolButton;
- ToolButton3: TToolButton;
- Panel1: TPanel;
- Splitter1: TSplitter;
- Panel2: TPanel;
- Tree: TTreeView;
- Panel3: TPanel;
- Panel4: TPanel;
- GroupBox1: TGroupBox;
- Ds_Ajgl: TDataSource;
- DBGridEh1: TDBGridEh;
- ImageList1: TImageList;
- PopupMenu1: TPopupMenu;
- N_ajcd: TMenuItem;
- N_AJRk: TMenuItem;
- N_ajCk: TMenuItem;
- AJTZH: TToolButton;
- N4: TMenuItem;
- N5: TMenuItem;
- ToolButton1: TToolButton;
- PopupMenu2: TPopupMenu;
- N6: TMenuItem;
- N7: TMenuItem;
- XPBarMenu1: TXPBarMenu;
- ToolButton2: TToolButton;
- procedure QuitExecute(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure TreeClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure AJCDClick(Sender: TObject);
- procedure AJCKClick(Sender: TObject);
- procedure AJRKClick(Sender: TObject);
- procedure DBGridEh1DblClick(Sender: TObject);
- procedure AJTZHClick(Sender: TObject);
- procedure DBGridEh1CellClick(Column: TColumnEh);
- procedure N4Click(Sender: TObject);
- procedure N5Click(Sender: TObject);
- procedure N6Click(Sender: TObject);
- procedure N7Click(Sender: TObject);
- procedure N_ajcdClick(Sender: TObject);
- procedure N_AJRkClick(Sender: TObject);
- procedure N_ajCkClick(Sender: TObject);
- procedure ToolButton2Click(Sender: TObject);
- procedure REFRESH1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- procedure loadTree1(treeDb1,treeDb2:TClientDataSet);//初始化树
- end;
- var
- Am_gdaj: TAm_gdaj;
- gnode:TtreeNode;//当前节点
- lbjs_sm1,lbjs_sm2:string;//类别级数
- lb_dmgz1,lb_dmgz2:string;//代码规则
- dsState:string;//增删改的状态
- s,gdaj_s1,gdaj_s2:string;//s1,s2分别是树节点:文本,代码
- implementation
- uses DMs, ajgls,u_public, ajgl_bjs, am_ajbj_rks, am_ajyjs,mainfrms,
- am_yjdys, Am_Gdaj_ps, Am_Ajtzs;
- {$R *.dfm}
- procedure TAm_gdaj.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_gdaj.QuitExecute(Sender: TObject);
- begin
- close;
- end;
- procedure TAm_gdaj.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- dm.V_ajgd.Active:=false;//归档视图
- dm.Am_ajgl.Active:=true;//案卷管理
- dm.sz_bgqx.Active:=true;//保管期限
- dm.sz_mj.active:=true;//密级
- //--------------------
- 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;//部门
- dm.v_ajgd.active:=false;
- action:=cafree;
- am_gdaj:=nil;
- end;
- procedure TAm_gdaj.TreeClick(Sender: TObject);
- var
- i,Epos:integer;
- begin
- 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
- begin
- Tree.Items[i].ImageIndex:=0;
- Tree.Items[i].SelectedIndex:=1;
- gdaj_s1:=Tree.Selected.Text;
- Epos:=pos('-',gdaj_s1);
- gdaj_s2:=copy(gdaj_s1,0,Epos-1);//为选中树节点的代码
- dm.V_ajgd.Close;
- dm.V_ajgd.CommandText:='select * from v_ajgd where ajlb_dm = '+''''+gdaj_s2+''''+'';
- dm.V_ajgd.Open;//查找当前代码
- if dm.V_AJGD.Active then showmessage('true');
- if dm.V_ajgd.RecordCount<>0 then
- begin
- if dbgrideh1.Columns[0].DisplayText='入库案卷' then
- begin
- AJCK.Enabled:=true;N_AJCK.Enabled:=true;
- ajrk.Enabled:=false;N_ajrk.Enabled:=false;
- ajcd.Enabled:=false;N_ajcd.Enabled:=false;
- ajtzh.Enabled:=false;
- N6.Enabled:=true;
- end
- else
- If dbgrideh1.Columns[0].DisplayText='归档案卷' then
- begin
- ajck.Enabled:=false;N_ajck.Enabled:=false;
- ajrk.Enabled:=true;N_ajrk.Enabled:=true;
- ajcd.Enabled:=true;N_ajcd.Enabled:=true;
- ajtzh.Enabled:=true;
- N6.Enabled:=true;
- end;//根据表格判断不用刷新数据库
- end//设置按钮的状态
- else
- begin
- AJCK.Enabled:=false;N_ajck.Enabled:=false;
- ajrk.Enabled:=false;N_ajrk.Enabled:=false;
- ajcd.Enabled:=false;N_ajcd.Enabled:=false;
- ajtzh.Enabled:=false;
- N6.Enabled:=false;
- end;
- end;
- end;
- end;
- end;
- procedure TAm_gdaj.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_bm.Active:=true;//部门
- dm.sz_kw.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;
- //调出二级表的编码规则
- 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;
- //装载树-------------------------------------------
- frm_name:='Am_Gdaj';
- dm.am_yjml.active:=true;//移交目录
- dm.Am_Ajyj.Active:=true;//案卷移交
- end;
- procedure TAm_gdaj.AJCDClick(Sender: TObject);
- var s2:string;
- begin
- if DBGrideh1.Columns[0].DisplayText='入库案卷' then
- begin
- AJCD.Enabled:=false;
- exit;
- end;
- s:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
- s2:=DM.v_ajgd.fieldbyname('ajlb_dm').AsString;
- dm.V_ajgd.Close;
- dm.V_ajgd.CommandText:='update v_ajgd set ajzt_mc=''案卷'' ,aj_gdjsrq=Null where aj_xh='+''''+s+''''+'';
- dm.V_ajgd.Execute;//对归档案卷进行管理
- dm.V_AJGD.Close;
- dm.v_ajgd.CommandText:='select * from v_Ajgd where ajlb_dm='+''''+s2+''''+'';
- dm.v_ajgd.Open;//案卷归档管理
- end;
- procedure TAm_gdaj.AJCKClick(Sender: TObject);
- var s:string;
- begin
- if DBGrideh1.Columns[0].DisplayText='归档案卷' then
- begin
- AJCK.Enabled:=false;
- exit;
- end;
- s:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
- dm.V_ajgd.Close;
- dm.V_ajgd.CommandText:='update v_ajgd set ajzt_mc=''归档案卷'',aj_bzjsrq=null,kw_dm=Null where aj_xh='+''''+s+''''+'';
- dm.V_ajgd.Execute;
- dm.V_AJGD.Close;
- dm.v_ajgd.CommandText:='select * from v_Ajgd where ajlb_dm='+''''+gdaj_s2+''''+'';
- dm.v_ajgd.Open;//案卷归档管理
- end;
- procedure TAm_gdaj.AJRKClick(Sender: TObject);
- var zcg_s:string;
- begin
- if DBGrideh1.Columns[0].DisplayText='入库案卷' then
- begin
- AJRK.Enabled:=false;
- exit;
- end;
- zcg_s:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
- dm.Am_ajgl.Close;
- dm.am_ajgl.CommandText:='select * from am_ajgl where aj_xh='+''''+zcg_s+''''+'';
- dm.Am_ajgl.Open;
- if am_ajgl_rk=Nil then
- begin
- am_ajgl_rk:=Tam_ajgl_rk.create(self);
- am_ajgl_rk.showmodal;
- end;
- end;
- procedure TAm_gdaj.DBGridEh1DblClick(Sender: TObject);
- var zcg_s:string;
- begin
- zcg_s:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
- dm.Am_ajgl.Close;
- dm.am_ajgl.CommandText:='select * from am_ajgl where aj_xh='+''''+zcg_s+''''+'';
- dm.Am_ajgl.Open;
- if am_ajgl_rk=Nil then
- begin
- am_ajgl_rk:=Tam_ajgl_rk.create(self);
- am_ajgl_rk.DBLookupComboboxEh4.Enabled:=false;
- am_ajgl_rk.DBLookupComboboxEh4.Color:=cl3dLight;
- am_ajgl_rk.Save.Visible:=false;
- am_ajgl_rk.Caption:='案卷浏览';
- am_ajgl_rk.showmodal;
- end;
- end;
- procedure TAm_gdaj.AJTZHClick(Sender: TObject);
- var
- s_xh:string;//序号
- s_dm:string;//代码
- begin
- s_xh:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
- s_dm:=dm.v_ajgd.fieldbyname('aj_dm').AsString;
- dm.Am_ajgl.Close;
- dm.am_ajgl.CommandText:='select * from am_ajgl where aj_xh='+''''+s_xh+''''+'';
- dm.Am_ajgl.Open;
- if am_ajtz=Nil then
- begin
- am_ajtz:=Tam_ajtz.create(self);
- am_ajtz.DBLookupComboboxEh4.Enabled:=false;
- am_ajtz.DBLookupComboboxEh4.Color:=cl3dLight;
- am_ajtz.DBLookupComboboxEh1.Enabled:=true;
- am_ajtz.DBLookupComboboxEh1.Color:=clWindow;
- am_ajtz.showmodal;
- end;
- end;
- procedure TAm_gdaj.DBGridEh1CellClick(Column: TColumnEh);
- begin
- if dbgrideh1.Columns[0].DisplayText='入库案卷' then
- begin
- AJCK.Enabled:=true;
- ajrk.Enabled:=false;
- ajcd.Enabled:=false;
- end
- else
- If dbgrideh1.Columns[0].DisplayText='归档案卷' then
- begin
- ajck.Enabled:=false;
- ajrk.Enabled:=true;
- ajcd.Enabled:=true;
- end;//根据表格判断不用刷新数据库
- end;
- procedure TAm_gdaj.N4Click(Sender: TObject);
- begin
- tree.Selected.Expand(true);
- end;
- procedure TAm_gdaj.N5Click(Sender: TObject);
- begin
- tree.Selected.Collapse(true);
- end;
- procedure TAm_gdaj.N6Click(Sender: TObject);
- var zcg_s:string;
- r:Trect;
- begin
- inherited;
- r:=mainfrm.MdiRect;
- zcg_s:=dm.V_ajgd.fieldbyname('aj_xh').AsString;
- dm.Am_ajgl.Close;
- dm.Am_ajgl.CommandText:='select * from Am_ajgl where aj_xh='+''''+zcg_s+''''+'';
- dm.Am_ajgl.Open;
- if am_ajyj=Nil then
- begin
- am_ajyj:=Tam_ajyj.create(self);
- dm.Am_Ajyj.Append;
- am_ajyj.show;
- am_ajyj.DBEdit8.SetFocus;
- am_ajyj.BoundsRect:=rect(r.left+90,r.top,r.right-r.Left-90,r.bottom-r.Top);
- end;//案卷移交
- end;
- procedure TAm_gdaj.N7Click(Sender: TObject);
- var r:Trect;
- begin
- inherited;
- r:=mainfrm.mdirect;
- if am_yjdy=nil then
- begin
- am_yjdy:=Tam_yjdy.create(self);
- am_yjdy.show;
- am_yjdy.BoundsRect:=rect(r.Left,r.Top,r.Right-r.Left,r.Bottom-r.Top);
- end;
- end;
- procedure TAm_gdaj.N_ajcdClick(Sender: TObject);
- begin
- Ajcd.Click;
- end;
- procedure TAm_gdaj.N_AJRkClick(Sender: TObject);
- begin
- ajrk.Click;
- end;
- procedure TAm_gdaj.N_ajCkClick(Sender: TObject);
- begin
- Ajck.Click;
- end;
- procedure TAm_gdaj.ToolButton2Click(Sender: TObject);
- begin
- am_gdaj_P:=Tam_gdaj_P.create(application);
- am_gdaj_P.quickrep1.preview;
- end;
- procedure TAm_gdaj.REFRESH1Click(Sender: TObject);
- begin
- dm.V_AJGD.close;
- dm.V_AJGD.CommandText:='select * from v_gdaj where aj_dm='+''''+gdaj_s2+''''+'';
- dm.v_ajgd.Open;
- end;
- end.