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

Delphi控件源码

开发平台:

Delphi

  1. unit Am_Ygxzs;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, DB, Buttons, Grids, DBGridEh, ExtCtrls, DBClient;
  6. type
  7.   TAm_Ygxz = class(TForm)
  8.     Panel1: TPanel;
  9.     Panel2: TPanel;
  10.     SpeedButton1: TSpeedButton;
  11.     SpeedButton2: TSpeedButton;
  12.     SpeedButton3: TSpeedButton;
  13.     DataSource1: TDataSource;
  14.     DBGridEh1: TDBGridEh;
  15.     ClientDataSet1: TClientDataSet;
  16.     procedure SpeedButton3Click(Sender: TObject);
  17.     procedure FormCreate(Sender: TObject);
  18.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  19.     procedure DBGridEh1DblClick(Sender: TObject);
  20.     procedure SpeedButton2Click(Sender: TObject);
  21.   private
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26. var
  27.   Am_Ygxz: TAm_Ygxz;
  28. implementation
  29. uses dms, Am_Yhgl_Zcs, am_yhgl_xgs,u_public;
  30. {$R *.dfm}
  31. procedure TAm_Ygxz.SpeedButton3Click(Sender: TObject);
  32. begin
  33.  close;
  34. end;
  35. procedure TAm_Ygxz.FormCreate(Sender: TObject);
  36. begin
  37.  //dm.v_yggl.active:=true;
  38.  dm.v_yggl.Close;
  39.  dm.v_yggl.CommandText:='select * from v_yggl';
  40.  dm.v_yggl.open;
  41. end;
  42. procedure TAm_Ygxz.FormClose(Sender: TObject; var Action: TCloseAction);
  43. begin
  44.  dm.v_yggl.Active:=false;
  45.  action:=cafree;
  46.  am_ygxz:=nil;
  47. end;
  48. procedure TAm_Ygxz.DBGridEh1DblClick(Sender: TObject);
  49. var s:string;
  50. begin
  51.   s:=dm.v_yggl.fieldbyname('yg_dm').AsString;
  52.   Clientdataset1.Close;
  53.   clientdataset1.CommandText:='select * from xt_user where user_ygdm='+''''+s+''''+'';
  54.   Clientdataset1.Open;
  55.   if clientdataset1.FieldByName('user_ygdm').AsString<>'' then
  56.   begin
  57.     application.MessageBox('一个员工只能对应一个用户,'+#13#10+'该用户资料已经存在','提示',mb_ok+mb_iconinformation);
  58.     exit;
  59.   end
  60.   else
  61.    begin//判断是修改还是增加
  62.     if frm_name='am_yhgl_zc' then
  63.      begin
  64.        Am_Yhgl_Zc.DBEditeh4.Text:=dm.v_yggl.fieldbyname('yg_dm').AsString;
  65.        am_yhgl_zc.dbediteh5.Text:=dm.v_yggl.fieldbyname('yg_xm').AsString;
  66.        close;
  67.      end
  68.     else
  69.      begin
  70.        Am_Yhgl_xg.DBEditeh4.Text:=dm.v_yggl.fieldbyname('yg_dm').AsString;
  71.        am_yhgl_xg.dbediteh5.Text:=dm.v_yggl.fieldbyname('yg_xm').AsString;
  72.        close;
  73.      end;
  74.    end;
  75. end;
  76. procedure TAm_Ygxz.SpeedButton2Click(Sender: TObject);
  77. var s:string;
  78. begin
  79.   s:=dm.v_yggl.fieldbyname('yg_dm').AsString;
  80.   Clientdataset1.Close;
  81.   clientdataset1.CommandText:='select * from xt_user where user_ygdm='+''''+s+''''+'';
  82.   Clientdataset1.Open;
  83.   if clientdataset1.FieldByName('user_ygdm').AsString<>'' then
  84.   begin
  85.     application.MessageBox('一个员工只能对应一个用户,'+#13#10+'该用户资料已经存在','提示',mb_ok+mb_iconinformation);
  86.     exit;
  87.   end
  88.   else
  89.    begin//判断是修改还是增加
  90.     if frm_name='am_yhgl_zc' then
  91.      begin
  92.        Am_Yhgl_Zc.DBEditeh4.Text:=dm.v_yggl.fieldbyname('yg_dm').AsString;
  93.        am_yhgl_zc.dbediteh5.Text:=dm.v_yggl.fieldbyname('yg_xm').AsString;
  94.        close;
  95.      end
  96.     else
  97.      begin
  98.        Am_Yhgl_xg.DBEditeh4.Text:=dm.v_yggl.fieldbyname('yg_dm').AsString;
  99.        am_yhgl_xg.dbediteh5.Text:=dm.v_yggl.fieldbyname('yg_xm').AsString;
  100.        close;
  101.      end;
  102.    end;
  103. end;
  104. end.