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

Delphi控件源码

开发平台:

Delphi

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