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

Delphi控件源码

开发平台:

Delphi

  1. unit am_yhgl_xgs;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, DB, ExtCtrls, Buttons, StdCtrls, Mask, DBCtrlsEh;
  6. type
  7.   Tam_yhgl_xg = class(TForm)
  8.     GroupBox1: TGroupBox;
  9.     Label2: TLabel;
  10.     Label3: TLabel;
  11.     Label4: TLabel;
  12.     Label9: TLabel;
  13.     Label10: TLabel;
  14.     DBEditEh1: TDBEditEh;
  15.     DBEditEh2: TDBEditEh;
  16.     DBEditEh3: TDBEditEh;
  17.     GroupBox2: TGroupBox;
  18.     Label5: TLabel;
  19.     Label6: TLabel;
  20.     Label11: TLabel;
  21.     SpeedButton1: TSpeedButton;
  22.     DBEditEh4: TDBEditEh;
  23.     DBEditEh5: TDBEditEh;
  24.     Label1: TLabel;
  25.     Image1: TImage;
  26.     SpeedButton2: TSpeedButton;
  27.     SpeedButton3: TSpeedButton;
  28.     DataSource1: TDataSource;
  29.     procedure SpeedButton3Click(Sender: TObject);
  30.     procedure SpeedButton2Click(Sender: TObject);
  31.     procedure DBEditEh1KeyPress(Sender: TObject; var Key: Char);
  32.     procedure DBEditEh2KeyPress(Sender: TObject; var Key: Char);
  33.     procedure DBEditEh3KeyPress(Sender: TObject; var Key: Char);
  34.     procedure SpeedButton1Click(Sender: TObject);
  35.     procedure FormCreate(Sender: TObject);
  36.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  37.     procedure DBEditEh4KeyPress(Sender: TObject; var Key: Char);
  38.     procedure DBEditEh4Exit(Sender: TObject);
  39.   private
  40.     { Private declarations }
  41.   public
  42.     { Public declarations }
  43.   end;
  44. var
  45.   am_yhgl_xg: Tam_yhgl_xg;
  46. implementation
  47. uses DMs, Am_Ygxzs,u_public;
  48. {$R *.dfm}
  49. procedure Tam_yhgl_xg.SpeedButton3Click(Sender: TObject);
  50. begin
  51. close;
  52. end;
  53. procedure Tam_yhgl_xg.SpeedButton2Click(Sender: TObject);
  54. var s_dm:string;//员工代码
  55.     N:integer;//错误
  56. begin
  57.   if trim(dbediteh1.Text)='' then
  58.    begin
  59.      application.MessageBox('用户代码不能为空','提示',mb_ok+mb_iconinformation);
  60.      dbediteh1.SetFocus;
  61.      exit;
  62.    end;
  63.   if trim(dbediteh2.Text)='' then
  64.    begin
  65.      application.MessageBox('用户名称不能为空','提示',mb_ok+mb_iconinformation);
  66.      dbediteh2.SetFocus;
  67.      exit;
  68.    end;
  69.   if trim(dbediteh4.Text)='' then
  70.    begin
  71.      application.MessageBox('员工代码不能为空','提示',mb_ok+mb_iconinformation);
  72.      dbediteh4.SetFocus;
  73.      exit;
  74.    end;
  75.   //有效性验证
  76.   n:=dm.xt_user.ApplyUpdates(0);
  77.   if n<>0 then
  78.    begin
  79.      application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
  80.      exit;
  81.    end
  82.   else
  83.    begin
  84.      application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
  85.      close;
  86.    end;
  87. end;
  88. procedure Tam_yhgl_xg.DBEditEh1KeyPress(Sender: TObject; var Key: Char);
  89. begin
  90. if key=#13 then
  91.     dbediteh2.SetFocus;
  92. end;
  93. procedure Tam_yhgl_xg.DBEditEh2KeyPress(Sender: TObject; var Key: Char);
  94. begin
  95.  if key=#13 then
  96.     dbediteh3.SetFocus;
  97. end;
  98. procedure Tam_yhgl_xg.DBEditEh3KeyPress(Sender: TObject; var Key: Char);
  99. begin
  100.  if key=#13 then
  101.     dbediteh4.SetFocus;
  102. end;
  103. procedure Tam_yhgl_xg.SpeedButton1Click(Sender: TObject);
  104. begin
  105.  if am_ygxz=nil then
  106.   begin
  107.     am_ygxz:=Tam_ygxz.create(self);
  108.     am_ygxz.showmodal;
  109.   end;
  110. end;
  111. procedure Tam_yhgl_xg.FormCreate(Sender: TObject);
  112. begin
  113.  dm.sz_yg.Active:=true;
  114.  frm_name:='am_yhgl_xg';
  115. end;
  116. procedure Tam_yhgl_xg.FormClose(Sender: TObject; var Action: TCloseAction);
  117. begin
  118.  dm.sz_yg.Active:=false;
  119.  frm_name:='';
  120.  action:=cafree;
  121.  am_yhgl_xg:=nil;
  122. end;
  123. procedure Tam_yhgl_xg.DBEditEh4KeyPress(Sender: TObject; var Key: Char);
  124. begin
  125.  if key=#13 then
  126.     speedbutton2.Click;
  127. end;
  128. procedure Tam_yhgl_xg.DBEditEh4Exit(Sender: TObject);
  129. var s,s_dm:string;
  130. begin
  131.   {s:=trim(dbediteh4.Text);
  132.   if s<>'' then
  133.    begin
  134.      dm.sz_yg.Close;
  135.      dm.sz_yg.CommandText:='select * from sz_yg where yg_dm='+''''+s+''''+'';
  136.      dm.sz_yg.open;
  137.      if dm.sz_yg.RecordCount<>0 then
  138.       begin
  139.        s_dm:=trim(dm.sz_yg.FieldByName('yg_dm').AsString);
  140.          if s<>'' then
  141.             dbediteh5.Text:=s_dm
  142.       end
  143.      else
  144.       begin
  145.        application.MessageBox('当前表中没有该员工代码','提示',mb_ok+mb_iconinformation);
  146.        dbediteh4.Text:='';
  147.        dbediteh4.SetFocus;
  148.        exit;//end if
  149.       end;
  150.    end
  151.   else
  152.    begin
  153.      exit;
  154.    end; }
  155. end;
  156. end.