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

Delphi控件源码

开发平台:

Delphi

  1. unit am_jygl_bjs;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, ExtCtrls, DB, Mask, DBCtrls, Buttons, DBCtrlsEh,
  6.   DBLookupEh;
  7. type
  8.   Tam_jygl_bj = class(TForm)
  9.     Image1: TImage;
  10.     Label1: TLabel;
  11.     Panel1: TPanel;
  12.     Label2: TLabel;
  13.     Label3: TLabel;
  14.     DBEdit2: TDBEdit;
  15.     Label5: TLabel;
  16.     Label6: TLabel;
  17.     Label7: TLabel;
  18.     Label9: TLabel;
  19.     Label10: TLabel;
  20.     Label11: TLabel;
  21.     SpeedButton1: TSpeedButton;
  22.     SpeedButton2: TSpeedButton;
  23.     Label4: TLabel;
  24.     Label8: TLabel;
  25.     Label12: TLabel;
  26.     SpeedButton3: TSpeedButton;
  27.     SpeedButton4: TSpeedButton;
  28.     DBLookupComboboxEh1: TDBLookupComboboxEh;
  29.     DBLookupComboboxEh2: TDBLookupComboboxEh;
  30.     DBEditEh1: TDBEditEh;
  31.     DBEditEh2: TDBEditEh;
  32.     Ds_Jygl: TDataSource;
  33.     Ds_Jyfs: TDataSource;
  34.     Ds_Jymd: TDataSource;
  35.     DBEditEh3: TDBEditEh;
  36.     DBEditEh4: TDBEditEh;
  37.     Label13: TLabel;
  38.     DBEditEh5: TDBEditEh;
  39.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  40.     procedure SpeedButton2Click(Sender: TObject);
  41.     procedure SpeedButton1Click(Sender: TObject);
  42.     procedure FormKeyPress(Sender: TObject; var Key: Char);
  43.     procedure SpeedButton3Click(Sender: TObject);
  44.     procedure SpeedButton4Click(Sender: TObject);
  45.     procedure DBEditEh2Change(Sender: TObject);
  46.   private
  47.     { Private declarations }
  48.   public
  49.     { Public declarations }
  50.   end;
  51. var
  52.   am_jygl_bj: Tam_jygl_bj;
  53. implementation
  54. uses DMs,am_jygls, am_dz_xzs, am_dzbjs, am_dz_ajxzs;
  55. {$R *.dfm}
  56. procedure Tam_jygl_bj.FormClose(Sender: TObject; var Action: TCloseAction);
  57. begin
  58.  dm.am_jygl.Close;
  59.  dm.am_jygl.CommandText:='select * from am_jygl';
  60.  dm.am_jygl.Open;
  61.  am_jygl.ToolButton4.Click;
  62.  action:=cafree;
  63.  am_jygl_bj:=nil;
  64. end;
  65. procedure Tam_jygl_bj.SpeedButton2Click(Sender: TObject);
  66. begin
  67.  close;
  68. end;
  69. procedure Tam_jygl_bj.SpeedButton1Click(Sender: TObject);
  70. var i:integer;
  71. begin
  72.   if DBEditEh2.Text='' then
  73.   begin
  74.       application.MessageBox('读者代码不能为空!','提示',mb_ok+mb_iconinformation);
  75.       exit;
  76.   end;
  77.   if dbedit2.Text='' then
  78.   begin
  79.       application.MessageBox('案卷序号不能为空!','提示',mb_ok+mb_iconinformation);
  80.       exit;
  81.   end;
  82.     if DBLookupComboboxEh1.Text='' then
  83.   begin
  84.       application.MessageBox('借阅方式代码不能为空!','提示',mb_ok+mb_iconinformation);
  85.       exit;
  86.   end;
  87.   if DBLookupComboboxEh2.Text='' then
  88.   begin
  89.       application.MessageBox('借阅目的不能为空!','提示',mb_ok+mb_iconinformation);
  90.       exit;
  91.   end;
  92.    dm.am_jygl.edit;
  93.    {dm.Am_jygl.FieldByName('dz_dm').AsString:=DBEditEh2.Text;
  94.    dm.am_jygl.FieldByName('jy_jyrq').AsDateTime:=DbDateTimeEditEh1.Value;
  95.    dm.am_jygl.FieldByName('jy_yhrq').AsDateTime:=StrToDatetime(dbediteh1.Text);}
  96.    //showmessage(datetimeTostr(Dbediteh));
  97.    dm.am_jygl.FieldByName('jy_jyzt').AsString:='借阅中';
  98.    i:=Dm.am_jygl.ApplyUpdates(0);
  99.    if i=0 then
  100.    begin
  101.       application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
  102.       am_jygl.ToolButton4.Click;
  103.       close;
  104.    end
  105.    else
  106.    begin
  107.      application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
  108.      exit;
  109.    end;
  110. end;
  111. procedure Tam_jygl_bj.FormKeyPress(Sender: TObject; var Key: Char);
  112. begin
  113.  if key=#13 then
  114.   begin
  115.      key:=#0;
  116.      perform(WM_NEXTDLGCTL,0,0);
  117.   end;
  118. end;
  119. procedure Tam_jygl_bj.SpeedButton3Click(Sender: TObject);
  120. begin
  121.   if am_dz_xz=nil then
  122.   begin
  123.      am_dz_xz:=Tam_dz_xz.Create(self);
  124.      am_dz_xz.ShowModal;
  125.   end;
  126. end;
  127. procedure Tam_jygl_bj.SpeedButton4Click(Sender: TObject);
  128. begin
  129.  if am_dz_ajxz=nil then
  130.   begin
  131.     am_dz_ajxz:=Tam_dz_ajxz.create(self);
  132.     am_dz_ajxz.showmodal;
  133.   end;
  134. end;
  135. procedure Tam_jygl_bj.DBEditEh2Change(Sender: TObject);
  136. var S_jyts:integer;//借阅天数
  137.     S_Dzdm:String;//分别是读者代码,借阅规则序号
  138. begin
  139.   if trim(DBEditEh2.Text)<>'' then
  140.   begin
  141.     DBEditEh5.Text:=formatdatetime('yyyy-mm-dd',now);
  142.     S_Dzdm:=DBEditEh2.Text;
  143.     dm.V_DZ.Close;
  144.     dm.V_DZ.CommandText:='select Jygz_Xjts from v_dz where dz_dm='+''''+S_Dzdm+''''+'';
  145.     dm.v_dz.Open;
  146.     S_jyts:=dm.V_DZ.fieldbyname('jygz_Xjts').AsInteger;
  147.     dbediteh1.Text:=datetostr(StrToDate(DBEditEh5.Text)+S_jyts);
  148.   end; 
  149. end;
  150. end.