U_fzlr_zgxm.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:5k
- unit U_fzlr_zgxm;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ExtCtrls, Db, DBClient, Menus, ImgList, ComCtrls, Buttons, Grids, DBGrids;
- type
- TfrmZgda_fzlr = class(TForm)
- Panel1: TPanel;
- Panel2: TPanel;
- PopupMenu2: TPopupMenu;
- Panel3: TPanel;
- btnOK: TSpeedButton;
- btnCancel: TSpeedButton;
- DataSource1: TDataSource;
- DBGrid: TDBGrid;
- N1: TMenuItem;
- N2: TMenuItem;
- N3: TMenuItem;
- N4: TMenuItem;
- N5: TMenuItem;
- N6: TMenuItem;
- N7: TMenuItem;
- N8: TMenuItem;
- N9: TMenuItem;
- Panel4: TPanel;
- TreeView: TTreeView;
- ImageList1: TImageList;
- procedure btnOKClick(Sender: TObject);
- procedure btnCancelClick(Sender: TObject);
- procedure N2Click(Sender: TObject);
- procedure N1Click(Sender: TObject);
- procedure N3Click(Sender: TObject);
- procedure N4Click(Sender: TObject);
- procedure N5Click(Sender: TObject);
- procedure N6Click(Sender: TObject);
- procedure N7Click(Sender: TObject);
- procedure N8Click(Sender: TObject);
- procedure N9Click(Sender: TObject);
- procedure DBGridTitleClick(Column: TColumn);
- procedure DBGridDblClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure TreeViewClick(Sender: TObject);
- private
- procedure refreshTree;
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmZgda_fzlr: TfrmZgda_fzlr;
- pub_zgxm: string;
- implementation
- uses U_mainform, u_public, WzglDB;
- {$R *.DFM}
- procedure TfrmZgda_fzlr.refreshTree;
- var
- mynode_1, mynode_2, mynode_3: Ttreenode;
- s_bm_1, s_bm_2, s_bm_3: string;
- s_mc_1, s_mc_2, s_mc_3: string;
- begin
- DM.CDS_BMDA_INDEX.Active := True;
- treeview.Items.clear;
- mynode_1 := Treeview.Items.Add(Treeview.topitem, '部门档案');
- mynode_1.imageindex := 0;
- mynode_1.stateindex := -1;
- mynode_1.selectedindex := 1;
- DM.CDS_BMDA_INDEX.indexfieldnames := '部门编码';
- DM.CDS_BMDA_INDEX.First;
- while not DM.CDS_BMDA_INDEX.Eof do
- begin
- s_bm_1 := DM.CDS_BMDA_INDEX.fieldbyname('部门编码').asstring;
- s_mc_1 := DM.CDS_BMDA_INDEX.fieldbyname('部门名称').asstring;
- if length(trim(s_bm_1)) = 2 then
- begin
- mynode_2 := Treeview.items.addchild(mynode_1, '(' + s_bm_1 + ') ' + s_mc_1);
- mynode_2.imageindex := 0;
- mynode_2.stateindex := -1;
- mynode_2.selectedindex := 1;
- end;
- if length(trim(s_bm_1)) = 5 then
- begin
- mynode_3 := Treeview.items.addchild(mynode_2, '(' + s_bm_1 + ') ' + s_mc_1);
- mynode_3.imageindex := 0;
- mynode_3.stateindex := -1;
- mynode_3.selectedindex := 1;
- end;
- DM.CDS_BMDA_INDEX.next;
- end;
- end;
- procedure TfrmZgda_fzlr.TreeViewClick(Sender: TObject);
- var
- mynode: Ttreenode;
- s_value_1, s_value_2, s_value_3, s_value_4: string;
- begin
- if Treeview.Items.Count = 0 then
- exit;
- mynode := Treeview.selected;
- case mynode.Level of
- 0:
- begin
- DM.CDS_ZGDA_INDEX.Filter := '';
- end;
- 1: begin
- s_value_1 := copy(mynode.text, 2, 2);
- DM.CDS_ZGDA_INDEX.Filter := '所属部门编码=' + '''' + s_value_1 + '''';
- end;
- 2: begin
- s_value_1 := copy(mynode.text, 2, 6);
- DM.CDS_ZGDA_INDEX.Filter := '所属部门编码=' + '''' + s_value_1 + '''';
- end;
- end;
- DM.CDS_ZGDA_INDEX.Filtered := True;
- end;
- procedure TfrmZgda_fzlr.btnOKClick(Sender: TObject);
- begin
- //判断是否选择具体职工
- if DM.CDS_ZGDA_INDEX.recordcount = 0 then
- begin
- application.messagebox('请选择具体职工', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- //将职工姓名传递给全局变量pub_zgxm
- pub_zgxm := DM.CDS_ZGDA_INDEX.fieldbyname('职工姓名').asstring;
- close;
- end;
- procedure TfrmZgda_fzlr.btnCancelClick(Sender: TObject);
- begin
- close;
- end;
- procedure TfrmZgda_fzlr.N2Click(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.indexfieldnames := '职工编号';
- end;
- procedure TfrmZgda_fzlr.N1Click(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.indexfieldnames := '职工姓名';
- end;
- procedure TfrmZgda_fzlr.N3Click(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.indexfieldnames := '部门名称';
- end;
- procedure TfrmZgda_fzlr.N4Click(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.indexfieldnames := '性别';
- end;
- procedure TfrmZgda_fzlr.N5Click(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.indexfieldnames := '出生年月';
- end;
- procedure TfrmZgda_fzlr.N6Click(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.indexfieldnames := '政治面貌';
- end;
- procedure TfrmZgda_fzlr.N7Click(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.indexfieldnames := '职称';
- end;
- procedure TfrmZgda_fzlr.N8Click(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.indexfieldnames := '职务';
- end;
- procedure TfrmZgda_fzlr.N9Click(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.indexfieldnames := '职工属性';
- end;
- procedure TfrmZgda_fzlr.DBGridTitleClick(Column: TColumn);
- begin
- DBGridSort(dbgrid, column);
- end;
- procedure TfrmZgda_fzlr.DBGridDblClick(Sender: TObject);
- begin
- BtnOK.Click;
- end;
- procedure TfrmZgda_fzlr.FormCreate(Sender: TObject);
- begin
- DM.CDS_ZGDA_INDEX.Active := True;
- RefreshTree;
- end;
- end.