xt_yhzs.~pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:5k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit xt_yhzs;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, Buttons, DBCtrls, DB, Grids, DBGridEh, ExtCtrls, Mask,
- DBCtrlsEh, DBLookupEh, DBClient;
- type
- Txt_fpyhz = class(TForm)
- GroupBox1: TGroupBox;
- Label37: TLabel;
- Label5: TLabel;
- SpeedButton19: TSpeedButton;
- SpeedButton21: TSpeedButton;
- SpeedButton22: TSpeedButton;
- SpeedButton23: TSpeedButton;
- Refresh: TSpeedButton;
- SpeedButton25: TSpeedButton;
- Panel6: TPanel;
- DBGridEh6: TDBGridEh;
- DataSource1: TDataSource;
- Label1: TLabel;
- Label2: TLabel;
- DBLookupComboboxEh1: TDBLookupComboboxEh;
- DBLookupComboboxEh2: TDBLookupComboboxEh;
- Ds_user: TDataSource;
- Ds_Yhz: TDataSource;
- Ds_UandG: TDataSource;
- ClientDataSet1: TClientDataSet;
- procedure FormCreate(Sender: TObject);
- procedure SpeedButton25Click(Sender: TObject);
- procedure SpeedButton19Click(Sender: TObject);
- procedure SpeedButton21Click(Sender: TObject);
- procedure SpeedButton22Click(Sender: TObject);
- procedure SpeedButton23Click(Sender: TObject);
- procedure RefreshClick(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- xt_fpyhz: Txt_fpyhz;
- implementation
- uses dms,U_public,ljszs;
- {$R *.dfm}
- procedure Txt_fpyhz.FormCreate(Sender: TObject);
- begin
- dm.xt_yhz.Active:=true;
- dm.xt_user.active:=true;
- dm.xt_uandg.Active:=true;
- dm.V_UandG.Active:=true;
- end;
- procedure Txt_fpyhz.SpeedButton25Click(Sender: TObject);
- begin
- close;
- end;
- procedure Txt_fpyhz.SpeedButton19Click(Sender: TObject);
- begin
- dm.xt_UandG.Append;//增加
- DbLookUpComboboxeh1.Color:=clwindow;
- DbLookUpComboboxeh2.Color:=clwindow;
- DbLookUpComboboxeh1.Enabled:=true;
- DbLookUpComboboxeh2.Enabled:=true;
- end;
- procedure Txt_fpyhz.SpeedButton21Click(Sender: TObject);
- var s_xh:string;
- begin
- s_xh:=dm.V_UandG.fieldbyname('ug_xh').AsString;
- dm.xt_UandG.Close;
- dm.xt_UandG.CommandText:='select * from xt_UandG where ug_xh='+''''+s_xh+''''+'';
- dm.xt_UandG.Open;
- dm.xt_uandg.Edit;//修改数据
- DbLookUpComboboxeh1.Color:=clwindow;
- DbLookUpComboboxeh2.Color:=clwindow;
- DbLookUpComboboxeh1.Enabled:=true;
- DbLookUpComboboxeh2.Enabled:=true;
- end;
- procedure Txt_fpyhz.SpeedButton22Click(Sender: TObject);
- var s_xh:string;
- begin
- s_xh:=dm.V_UandG.fieldbyname('ug_xh').AsString;
- if dm.V_UandG.RecordCount=0 then
- begin
- application.MessageBox('当前表中没有数据,'+#13#10+'不能删除','警告',mb_ok+mb_iconinformation);
- exit;
- end
- else
- begin//删除选中的书并且更新表和视图
- if application.MessageBox('您确定要删除吗?','警告',mb_ok+mb_iconinformation)=Idok then
- begin
- dm.xt_UandG.Close;
- dm.xt_UandG.CommandText:='delete xt_UandG where ug_xh='+''''+s_xh+''''+'';
- dm.xt_UandG.Execute;
- dm.xt_UandG.Close;
- dm.xt_uandg.CommandText:='select * from xt_uandG';
- dm.xt_uandg.open;
- dm.V_UandG.Close;
- dm.V_UandG.CommandText:='select * from v_UandG';
- dm.V_UandG.Open;
- end;
- end;
- end;
- procedure Txt_fpyhz.SpeedButton23Click(Sender: TObject);
- var N:integer;
- s:string;
- begin
- if DbLookupComboboxeh1.Text='' then
- begin
- application.MessageBox('用户名称不能为空','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- if DbLookupComboboxeh2.Text='' then
- begin
- application.MessageBox('用户组名称不能为空','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- //数据有效性验证
- s:=DbLookUpComboboxeh1.KeyValue;
- ClientdataSet1.Close;
- Clientdataset1.CommandText:='select * from xt_UandG where User_dm='+''''+s+''''+'';
- Clientdataset1.Open;
- if clientdataset1.RecordCount<> then
- begin
- application.MessageBox('当前表中已有该用户存在','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- N:=dm.xt_UandG.ApplyUpdates(0);
- if N=0 then
- begin
- application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
- dm.xt_UandG.Close;
- dm.xt_uandg.CommandText:='select * from xt_UandG';
- dm.xt_UandG.open;
- dm.v_uandg.Close;
- dm.V_UandG.CommandText:='select * from v_UandG';
- dm.V_UandG.Open;
- end
- else
- begin
- application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
- end;
- end;
- procedure Txt_fpyhz.RefreshClick(Sender: TObject);
- begin
- dm.V_UandG.Close;
- dm.v_Uandg.CommandText:='select * from v_UandG';
- dm.V_UandG.Open;//刷新
- end;
- procedure Txt_fpyhz.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- dm.xt_UandG.Active:=false;
- dm.V_UandG.Active:=false;
- dm.xt_user.Active:=false;
- dm.xt_yhz.Active:=false;
- end;
- end.