sz_yggls.~pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:5k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit sz_yggls;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, DB, StdCtrls, Mask, DBCtrls, ExtCtrls, DBCtrlsEh, DBLookupEh,
- Grids, DBGridEh, Buttons;
- type
- Tsz_yggl = class(TForm)
- sz_yg: TDataSource;
- GroupBox1: TGroupBox;
- Label1: TLabel;
- DBEdit1: TDBEdit;
- Label2: TLabel;
- DBEdit2: TDBEdit;
- Label3: TLabel;
- Panel5: TPanel;
- DBGridEh1: TDBGridEh;
- Label36: TLabel;
- Label37: TLabel;
- sz_bm: TDataSource;
- Add1: TSpeedButton;
- Edit1: TSpeedButton;
- Dele1: TSpeedButton;
- Save1: TSpeedButton;
- Refresh1: TSpeedButton;
- Quit1: TSpeedButton;
- v_yggl: TDataSource;
- DBLookupComboBox1: TDBLookupComboBox;
- procedure Quit1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Add1Click(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure Dele1Click(Sender: TObject);
- procedure Edit1Click(Sender: TObject);
- procedure Refresh1Click(Sender: TObject);
- procedure Save1Click(Sender: TObject);
- procedure DBGridEh1CellClick(Column: TColumnEh);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- sz_yggl: Tsz_yggl;
- implementation
- uses DMs;
- {$R *.dfm}
- procedure Tsz_yggl.Quit1Click(Sender: TObject);
- begin
- close;
- end;
- procedure Tsz_yggl.FormCreate(Sender: TObject);
- begin
- // refresh1.Click;
- dm.sz_bm.Close;
- dm.sz_bm.CommandText:='select * from sz_bm';
- dm.sz_bm.Open;
- dm.sz_yg.Close;
- dm.sz_yg.CommandText:='select * from sz_yg';
- dm.sz_yg.Open;
- dm.v_yggl.Close;
- dm.v_yggl.CommandText:='select * from v_yggl';
- dm.v_yggl.Open;
- end;
- procedure Tsz_yggl.Add1Click(Sender: TObject);
- begin
- dm.sz_yg.Close;
- dm.sz_yg.CommandText:='select * from sz_yg where yg_dm='+''''+''''+'';
- dm.sz_yg.Open;
- end;
- procedure Tsz_yggl.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- action:=cafree;
- sz_yggl:=nil;
- dm.sz_yg.Active:=false;
- dm.sz_bm.Active:=false;
- dm.v_yggl.active:=false;
- end;
- procedure Tsz_yggl.Dele1Click(Sender: TObject);
- var s:string;
- begin
- s:=dm.v_yggl.fieldbyname('bm_dm').AsString;
- if Dm.sz_yg.RecordCount=0 then
- begin
- application.MessageBox('表中没有数据不能删除!','提示',mb_iconquestion+mb_defbutton1);
- Abort;
- end
- else
- if application.MessageBox('您确定删除吗?','警告',mb_okcancel+mb_iconquestion)=idok then
- begin
- Dm.sz_yg.Close;
- dm.sz_yg.CommandText:='select * from sz_yg where bm_dm='+''''+s+''''+'';
- dm.sz_yg.Open;
- Dm.sz_yg.Delete;
- Dm.sz_yg.ApplyUpdates(0);
- refresh1.Click;
- end;
- end;
- procedure Tsz_yggl.Edit1Click(Sender: TObject);
- var s:string;
- begin
- s:=dm.v_yggl.fieldbyname('bm_dm').AsString;
- dm.sz_yg.Close;
- dm.sz_yg.CommandText:='select * from sz_yg where bm_dm='+''''+s+''''+'';
- dm.sz_yg.Open;
- dm.sz_yg.edit;
- dbedit1.SetFocus;
- end;
- procedure Tsz_yggl.Refresh1Click(Sender: TObject);
- begin
- dm.sz_bm.Close;
- dm.sz_bm.CommandText:='select * from sz_bm';
- dm.sz_bm.Open;
- dm.sz_yg.Close;
- dm.sz_yg.CommandText:='select * from sz_yg';
- dm.sz_yg.Open;
- dm.v_yggl.Close;
- dm.v_yggl.CommandText:='select * from v_yggl';
- dm.v_yggl.Open;
- end;
- procedure Tsz_yggl.Save1Click(Sender: TObject);
- var i:integer;
- begin
- if dbedit1.Text='' then
- begin
- application.MessageBox('员工代码不能为空!','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- if dbedit2.Text='' then
- begin
- application.MessageBox('员工姓名不能为空!','提示',mb_ok+mb_iconinformation);
- exit;
- end;//以上位验证数据是否完整
- Dm.sz_yg.ApplyUpdates(0);
- i:=Dm.sz_yg.ApplyUpdates(0);
- if i=0 then
- begin
- application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
- refresh1.click;
- end
- else
- begin
- application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- end;
- procedure Tsz_yggl.DBGridEh1CellClick(Column: TColumnEh);
- var
- s1,s2:string;
- i:integer;
- begin//--1单击每一行时,使树形控件也变化
- s1:=DBGridEh1.Columns[2].DisplayText;
- // showmessage(s1);
- //s2:=DBGridEh1.Columns[2].DisplayText;
- // dm.v_yggl.Locate('bm_dm','+''''+s1+''''+',[]);
- //过滤要搜索的数据
- dm.sz_yg.Close;
- dm.sz_yg.CommandText:='select * from sz_yg where yg_dm='+''''+s1+''''+'';
- dm.sz_yg.Open;
- { dbedit1.Text:=dm.v_yggl.fieldbyname('yg_dm').AsString;
- dbedit2.Text:=dm.v_yggl.fieldbyname('yg_xm').AsString;
- showmessage('yg_dm'+dm.v_yggl.fieldbyname('yg_dm').AsString);
- DBLookupComboBox1.ListField:=dm.v_yggl.fieldbyname('bm_mc').AsString;
- }
- end;
- end.