Am_gdajs.~pas
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:13k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit Am_gdajs;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, XPBarMenu, DB, Menus, ActnList, Grids, DBGridEh, StdCtrls,
  6.   ComCtrls, ExtCtrls, ToolWin, DBClient, ImgList;
  7. type
  8.   TAm_gdaj = class(TForm)
  9.     CoolBar1: TCoolBar;
  10.     ToolBar1: TToolBar;
  11.     AJCD: TToolButton;
  12.     AJRK: TToolButton;
  13.     AJCK: TToolButton;
  14.     REFRESH1: TToolButton;
  15.     ToolButton3: TToolButton;
  16.     Panel1: TPanel;
  17.     Splitter1: TSplitter;
  18.     Panel2: TPanel;
  19.     Tree: TTreeView;
  20.     Panel3: TPanel;
  21.     Panel4: TPanel;
  22.     GroupBox1: TGroupBox;
  23.     Ds_Ajgl: TDataSource;
  24.     DBGridEh1: TDBGridEh;
  25.     ImageList1: TImageList;
  26.     PopupMenu1: TPopupMenu;
  27.     N_ajcd: TMenuItem;
  28.     N_AJRk: TMenuItem;
  29.     N_ajCk: TMenuItem;
  30.     AJTZH: TToolButton;
  31.     N4: TMenuItem;
  32.     N5: TMenuItem;
  33.     ToolButton1: TToolButton;
  34.     PopupMenu2: TPopupMenu;
  35.     N6: TMenuItem;
  36.     N7: TMenuItem;
  37.     XPBarMenu1: TXPBarMenu;
  38.     ToolButton2: TToolButton;
  39.     procedure QuitExecute(Sender: TObject);
  40.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  41.     procedure TreeClick(Sender: TObject);
  42.     procedure FormCreate(Sender: TObject);
  43.     procedure AJCDClick(Sender: TObject);
  44.     procedure AJCKClick(Sender: TObject);
  45.     procedure AJRKClick(Sender: TObject);
  46.     procedure DBGridEh1DblClick(Sender: TObject);
  47.     procedure AJTZHClick(Sender: TObject);
  48.     procedure DBGridEh1CellClick(Column: TColumnEh);
  49.     procedure N4Click(Sender: TObject);
  50.     procedure N5Click(Sender: TObject);
  51.     procedure N6Click(Sender: TObject);
  52.     procedure N7Click(Sender: TObject);
  53.     procedure N_ajcdClick(Sender: TObject);
  54.     procedure N_AJRkClick(Sender: TObject);
  55.     procedure N_ajCkClick(Sender: TObject);
  56.     procedure ToolButton2Click(Sender: TObject);
  57.     procedure REFRESH1Click(Sender: TObject);
  58.   private
  59.     { Private declarations }
  60.   public
  61.     { Public declarations }
  62.     procedure loadTree1(treeDb1,treeDb2:TClientDataSet);//初始化树
  63.   end;
  64. var
  65.   Am_gdaj: TAm_gdaj;
  66.   gnode:TtreeNode;//当前节点
  67.   lbjs_sm1,lbjs_sm2:string;//类别级数
  68.   lb_dmgz1,lb_dmgz2:string;//代码规则
  69.   dsState:string;//增删改的状态
  70.   s,gdaj_s1,gdaj_s2:string;//s1,s2分别是树节点:文本,代码
  71. implementation
  72. uses DMs, ajgls,u_public, ajgl_bjs, am_ajbj_rks, am_ajyjs,mainfrms,
  73.   am_yjdys, Am_Gdaj_ps, Am_Ajtzs;
  74. {$R *.dfm}
  75. procedure TAm_gdaj.loadTree1(treeDb1,treeDb2:TClientDataSet);//初始化树
  76. var
  77.   nodeId1,nodeTxt1,nodeId2,nodeTxt2:string;
  78.   SCodeFormat1,SCodeFormat2,SFirstNodeTxt:string;
  79.   level1,level2:integer;
  80.   mynode:array[0..6] of Ttreenode;
  81.   i,j:integer;//循环标志
  82. begin
  83.    //初始化变量
  84.    SCodeFormat1:=lbjs_sm1 ;//系统案卷类别代码结构
  85.    SCodeFormat2:=lbjs_sm2;//文件类别代码结构
  86.    SFirstNodeTxt:= '案卷类别';//首节点显示的文字
  87.    Screen.Cursor:=crHourGlass;
  88.    Tree.enabled:=true;
  89.    Tree.Items.Clear;
  90.    level1:=0;
  91.    //设置根节点
  92.  mynode[level1]:=Tree.Items.Add(Tree.TopItem,SFirstNodeTxt);
  93.  mynode[level1].ImageIndex:=0;
  94.  mynode[level1].SelectedIndex:=1;
  95.  //遍历数据表,利用编码字段记录排序规律,依次添加树节点
  96.   for i:=0 to treedb1.RecordCount-1 do
  97.   begin
  98.     nodeId1:=trim(treedb1.fieldbyname('qz_dm').AsString);
  99.     nodeTxt1:=nodeId1+'-'+trim(treedb1.fieldbyname('qz_mc').AsString);
  100.     level1:=GetNodeLevel(SCodeFormat1,nodeId1);//获得节点层树
  101.     if level1>0 then
  102.      begin
  103.        mynode[level1]:=tree.Items.AddChild(mynode[level1-1],nodeTxt1);
  104.        mynode[level1].ImageIndex:=0;
  105.        mynode[level1].SelectedIndex:=1;
  106.       //----------
  107.      end;
  108.   //增加第一层主表
  109.      treedb2.close;
  110.      treedb2.commandtext:='select * from sz_ajlb where qz_dm='+''''+nodeId1+''''+'';
  111.      treedb2.open;
  112.      if trim(treedb2.FieldByName('qz_dm').AsString)<>'' then
  113.       begin
  114.        for j:=0 to treedb2.recordcount-1 do
  115.        begin
  116.            nodeId2:=trim(treedb2.fieldbyname('ajlb_dm').asstring);
  117.            nodeTxt2:=NodeId2+'-'+trim(treedb2.fieldbyname('ajlb_mc').asstring);
  118.            level2:=getNodeLevel(SCodeFormat2,nodeId2);//从表的层数
  119.           if level2>1 then
  120.            begin
  121.              mynode[level2]:=tree.Items.AddChild(mynode[level2-1],nodeTxt2);
  122.              mynode[level2].ImageIndex:=0;
  123.              mynode[level2].SelectedIndex:=1;
  124.            end;
  125.          treedb2.Next;
  126.        end;
  127.        end
  128.        else
  129.           treedb2.Next;//不是符合条件的纪录
  130.     treedb1.Next;//下一条纪录
  131.   end;//end for
  132.   mynode[0].Expand(false);
  133.   screen.Cursor:=crdefault;
  134. end;
  135. //**************************************************************
  136. procedure TAm_gdaj.QuitExecute(Sender: TObject);
  137. begin
  138.   close;
  139. end;
  140. procedure TAm_gdaj.FormClose(Sender: TObject; var Action: TCloseAction);
  141. begin
  142.   dm.V_ajgd.Active:=false;//归档视图
  143.   dm.Am_ajgl.Active:=true;//案卷管理
  144.   dm.sz_bgqx.Active:=true;//保管期限
  145.   dm.sz_mj.active:=true;//密级
  146.   //--------------------
  147.   dm.sz_qz.Active:=false;//全宗
  148.   dm.sz_ajlb.Active:=false;//案卷类别
  149.   //---------------
  150.   dm.sz_xtajlb.Active:=false;//系统案卷类别
  151.   //---------------
  152.   dm.xt_lbjs.Active:=false;//类别级数
  153.   dm.Am_wjgl.active:=false;//文件管理
  154.   dm.V_Wjgl.Active:=false;//文件视图
  155.   dm.sz_ztlb.Active:=false;//载体类别
  156.   dm.sz_wjlb.active:=false;//文件类别
  157.   dm.sz_bm.Active:=false;//部门
  158.   dm.v_ajgd.active:=false;
  159.   action:=cafree;
  160.   am_gdaj:=nil;
  161. end;
  162. procedure TAm_gdaj.TreeClick(Sender: TObject);
  163. var
  164.    i,Epos:integer;
  165. begin
  166.   if tree.selected=nil then
  167.      exit
  168.   else
  169.  if Tree.Items[0].HasChildren<>false then
  170.  begin   //选中和不选中的图片显示
  171.     for i:=0 to Tree.items.count-1 do
  172.     begin
  173.       if tree.Selected.HasChildren then
  174.          exit
  175.       else
  176.          begin
  177.            Tree.Items[i].ImageIndex:=0;
  178.            Tree.Items[i].SelectedIndex:=1;
  179.            gdaj_s1:=Tree.Selected.Text;
  180.            Epos:=pos('-',gdaj_s1);
  181.            gdaj_s2:=copy(gdaj_s1,0,Epos-1);//为选中树节点的代码
  182.            dm.V_AJGD.Active:=true;
  183.            dm.V_ajgd.Close;
  184.            dm.V_ajgd.CommandText:='select * from v_ajgd where ajlb_dm = '+''''+gdaj_s2+''''+'';
  185.            dm.V_ajgd.Open;//查找当前代码
  186.           if dm.V_AJGD.Active then showmessage('true');           
  187.            if dm.V_ajgd.RecordCount<>0 then
  188.             begin
  189.               if dbgrideh1.Columns[0].DisplayText='入库案卷' then
  190.                 begin
  191.                   AJCK.Enabled:=true;N_AJCK.Enabled:=true;
  192.                   ajrk.Enabled:=false;N_ajrk.Enabled:=false;
  193.                   ajcd.Enabled:=false;N_ajcd.Enabled:=false;
  194.                   ajtzh.Enabled:=false;
  195.                   N6.Enabled:=true;
  196.                 end
  197.                 else
  198.                 If dbgrideh1.Columns[0].DisplayText='归档案卷' then
  199.                  begin
  200.                    ajck.Enabled:=false;N_ajck.Enabled:=false;
  201.                    ajrk.Enabled:=true;N_ajrk.Enabled:=true;
  202.                    ajcd.Enabled:=true;N_ajcd.Enabled:=true;
  203.                    ajtzh.Enabled:=true;
  204.                    N6.Enabled:=true;
  205.                  end;//根据表格判断不用刷新数据库
  206.             end//设置按钮的状态
  207.            else
  208.             begin
  209.                AJCK.Enabled:=false;N_ajck.Enabled:=false;
  210.                ajrk.Enabled:=false;N_ajrk.Enabled:=false;
  211.                ajcd.Enabled:=false;N_ajcd.Enabled:=false;
  212.                ajtzh.Enabled:=false;
  213.                N6.Enabled:=false;
  214.             end;
  215.          end;
  216.     end;
  217.  end;
  218. end;
  219. procedure TAm_gdaj.FormCreate(Sender: TObject);
  220. begin
  221.    dm.Am_ajgl.Active:=true;//案卷管理
  222.    dm.sz_bgqx.Active:=true;//保管期限
  223.    dm.sz_mj.active:=true;//密级
  224.    dm.sz_ztlb.Active:=true;//载体类别
  225.    dm.sz_bm.Active:=true;//部门
  226.    dm.sz_kw.Active:=true;//库位
  227.    //-------
  228.    dm.sz_qz.Close;
  229.    dm.sz_qz.CommandText:='select * from sz_qz';
  230.    dm.sz_qz.Open;//全宗
  231.    dm.sz_ajlb.Close;
  232.    dm.sz_ajlb.CommandText:='select * from sz_ajlb';
  233.    dm.sz_ajlb.Open;//案卷类别
  234.    //---------------
  235.    dm.sz_xtajlb.close;
  236.    dm.sz_xtajlb.CommandText:='select * from sz_xtajlb';
  237.    dm.sz_xtajlb.Open;//系统案卷类别
  238.    //刷新两个表
  239.    dm.xt_lbjs.Close;
  240.    dm.xt_lbjs.CommandText:='select * from xt_lbjs where lb_dm='+''''+'sz_qz'+''''+'';
  241.    dm.xt_lbjs.Open;//类别级数
  242.    lbjs_sm1:=dm.xt_lbjs.fieldbyname('lbjs_sm').AsString;
  243.    //调出主表的编码规则
  244.    dm.xt_lbjs.Close;
  245.    dm.xt_lbjs.CommandText:='select * from xt_lbjs where lb_dm='+''''+'sz_ajlb'+''''+'';
  246.    dm.xt_lbjs.Open;
  247.    lbjs_sm2:=dm.xt_lbjs.fieldbyname('lbjs_sm').asstring;
  248.    //调出二级表的编码规则
  249.    loadtree1(dm.sz_qz,dm.sz_ajlb);
  250.    dm.sz_qz.Close;
  251.    dm.sz_qz.CommandText:='select * from sz_qz';
  252.    dm.sz_qz.Open;
  253.    dm.sz_ajlb.Close;
  254.    dm.sz_ajlb.CommandText:='select * from sz_ajlb';
  255.    dm.sz_ajlb.Open;
  256.    //装载树-------------------------------------------
  257.    frm_name:='Am_Gdaj';
  258.    dm.am_yjml.active:=true;//移交目录
  259.    dm.Am_Ajyj.Active:=true;//案卷移交
  260. end;
  261. procedure TAm_gdaj.AJCDClick(Sender: TObject);
  262. var s2:string;
  263. begin
  264.   if DBGrideh1.Columns[0].DisplayText='入库案卷' then
  265.     begin
  266.      AJCD.Enabled:=false;
  267.      exit;
  268.     end;
  269.    s:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
  270.    s2:=DM.v_ajgd.fieldbyname('ajlb_dm').AsString;
  271.    dm.V_ajgd.Close;
  272.    dm.V_ajgd.CommandText:='update v_ajgd set ajzt_mc=''案卷'' ,aj_gdjsrq=Null where aj_xh='+''''+s+''''+'';
  273.    dm.V_ajgd.Execute;//对归档案卷进行管理
  274.    dm.V_AJGD.Close;
  275.    dm.v_ajgd.CommandText:='select * from v_Ajgd where ajlb_dm='+''''+s2+''''+'';
  276.    dm.v_ajgd.Open;//案卷归档管理
  277. end;
  278. procedure TAm_gdaj.AJCKClick(Sender: TObject);
  279. var s:string;
  280. begin
  281.   if DBGrideh1.Columns[0].DisplayText='归档案卷' then
  282.     begin
  283.      AJCK.Enabled:=false;
  284.      exit;
  285.     end;
  286.   s:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
  287.   dm.V_ajgd.Close;
  288.   dm.V_ajgd.CommandText:='update v_ajgd set ajzt_mc=''归档案卷'',aj_bzjsrq=null,kw_dm=Null where aj_xh='+''''+s+''''+'';
  289.   dm.V_ajgd.Execute;
  290.   dm.V_AJGD.Close;
  291.   dm.v_ajgd.CommandText:='select * from v_Ajgd where ajlb_dm='+''''+gdaj_s2+''''+'';
  292.   dm.v_ajgd.Open;//案卷归档管理
  293. end;
  294. procedure TAm_gdaj.AJRKClick(Sender: TObject);
  295. var zcg_s:string;
  296. begin
  297.  if DBGrideh1.Columns[0].DisplayText='入库案卷' then
  298.     begin
  299.      AJRK.Enabled:=false;
  300.      exit;
  301.     end;
  302.  zcg_s:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
  303.  dm.Am_ajgl.Close;
  304.  dm.am_ajgl.CommandText:='select * from am_ajgl where aj_xh='+''''+zcg_s+''''+'';
  305.  dm.Am_ajgl.Open;
  306.   if am_ajgl_rk=Nil then
  307.   begin
  308.      am_ajgl_rk:=Tam_ajgl_rk.create(self);
  309.      am_ajgl_rk.showmodal;
  310.   end;
  311. end;
  312. procedure TAm_gdaj.DBGridEh1DblClick(Sender: TObject);
  313. var zcg_s:string;
  314. begin
  315.  zcg_s:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
  316.  dm.Am_ajgl.Close;
  317.  dm.am_ajgl.CommandText:='select * from am_ajgl where aj_xh='+''''+zcg_s+''''+'';
  318.  dm.Am_ajgl.Open;
  319.  if am_ajgl_rk=Nil then
  320.   begin
  321.      am_ajgl_rk:=Tam_ajgl_rk.create(self);
  322.      am_ajgl_rk.DBLookupComboboxEh4.Enabled:=false;
  323.      am_ajgl_rk.DBLookupComboboxEh4.Color:=cl3dLight;
  324.      am_ajgl_rk.Save.Visible:=false;
  325.      am_ajgl_rk.Caption:='案卷浏览';
  326.      am_ajgl_rk.showmodal;
  327.   end;
  328. end;
  329. procedure TAm_gdaj.AJTZHClick(Sender: TObject);
  330. var
  331.   s_xh:string;//序号
  332.   s_dm:string;//代码
  333. begin
  334.  s_xh:=dm.v_ajgd.fieldbyname('aj_xh').AsString;
  335.  s_dm:=dm.v_ajgd.fieldbyname('aj_dm').AsString;
  336.  dm.Am_ajgl.Close;
  337.  dm.am_ajgl.CommandText:='select * from am_ajgl where aj_xh='+''''+s_xh+''''+'';
  338.  dm.Am_ajgl.Open;
  339.  if am_ajtz=Nil then
  340.   begin
  341.      am_ajtz:=Tam_ajtz.create(self);
  342.      am_ajtz.DBLookupComboboxEh4.Enabled:=false;
  343.      am_ajtz.DBLookupComboboxEh4.Color:=cl3dLight;
  344.      am_ajtz.DBLookupComboboxEh1.Enabled:=true;
  345.      am_ajtz.DBLookupComboboxEh1.Color:=clWindow;
  346.      am_ajtz.showmodal;
  347.   end;
  348. end;
  349. procedure TAm_gdaj.DBGridEh1CellClick(Column: TColumnEh);
  350. begin
  351.  if dbgrideh1.Columns[0].DisplayText='入库案卷' then
  352.   begin
  353.     AJCK.Enabled:=true;
  354.     ajrk.Enabled:=false;
  355.     ajcd.Enabled:=false;
  356.   end
  357.   else
  358.   If dbgrideh1.Columns[0].DisplayText='归档案卷' then
  359.    begin
  360.      ajck.Enabled:=false;
  361.      ajrk.Enabled:=true;
  362.      ajcd.Enabled:=true;
  363.    end;//根据表格判断不用刷新数据库
  364. end;
  365. procedure TAm_gdaj.N4Click(Sender: TObject);
  366. begin
  367.  tree.Selected.Expand(true);
  368. end;
  369. procedure TAm_gdaj.N5Click(Sender: TObject);
  370. begin
  371.   tree.Selected.Collapse(true);
  372. end;
  373. procedure TAm_gdaj.N6Click(Sender: TObject);
  374. var zcg_s:string;
  375.     r:Trect;
  376. begin
  377.  inherited;
  378.  r:=mainfrm.MdiRect;
  379.  zcg_s:=dm.V_ajgd.fieldbyname('aj_xh').AsString;
  380.  dm.Am_ajgl.Close;
  381.  dm.Am_ajgl.CommandText:='select * from Am_ajgl where aj_xh='+''''+zcg_s+''''+'';
  382.  dm.Am_ajgl.Open;
  383.   if am_ajyj=Nil then
  384.   begin
  385.      am_ajyj:=Tam_ajyj.create(self);
  386.      dm.Am_Ajyj.Append;
  387.      am_ajyj.show;
  388.      am_ajyj.DBEdit8.SetFocus;
  389.      am_ajyj.BoundsRect:=rect(r.left+90,r.top,r.right-r.Left-90,r.bottom-r.Top);
  390.   end;//案卷移交
  391. end; 
  392. procedure TAm_gdaj.N7Click(Sender: TObject);
  393. var r:Trect;
  394. begin
  395.  inherited;
  396.  r:=mainfrm.mdirect;
  397.  if am_yjdy=nil then
  398.  begin
  399.     am_yjdy:=Tam_yjdy.create(self);
  400.     am_yjdy.show;
  401.     am_yjdy.BoundsRect:=rect(r.Left,r.Top,r.Right-r.Left,r.Bottom-r.Top);
  402.  end;
  403. end;
  404. procedure TAm_gdaj.N_ajcdClick(Sender: TObject);
  405. begin
  406.  Ajcd.Click;
  407. end;
  408. procedure TAm_gdaj.N_AJRkClick(Sender: TObject);
  409. begin
  410.  ajrk.Click;
  411. end;
  412. procedure TAm_gdaj.N_ajCkClick(Sender: TObject);
  413. begin
  414.  Ajck.Click;
  415. end;
  416. procedure TAm_gdaj.ToolButton2Click(Sender: TObject);
  417. begin
  418.  am_gdaj_P:=Tam_gdaj_P.create(application);
  419.  am_gdaj_P.quickrep1.preview;
  420. end;
  421. procedure TAm_gdaj.REFRESH1Click(Sender: TObject);
  422. begin
  423.  dm.V_AJGD.close;
  424.  dm.V_AJGD.CommandText:='select * from v_gdaj where aj_dm='+''''+gdaj_s2+''''+'';
  425.  dm.v_ajgd.Open;
  426. end;
  427. end.