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

Delphi控件源码

开发平台:

Delphi

  1. unit am_ghgls;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, ComCtrls, ToolWin, Grids, DBGridEh, XPBarMenu, DB, PrnDbgeh,
  6.   StdCtrls, ExtCtrls, DBClient;
  7. type
  8.   Tam_ghgl = class(TForm)
  9.     CoolBar1: TCoolBar;
  10.     ToolBar1: TToolBar;
  11.     ToolButton1: TToolButton;
  12.     ToolButton4: TToolButton;
  13.     ToolButton5: TToolButton;
  14.     ToolButton6: TToolButton;
  15.     ToolButton2: TToolButton;
  16.     XPBarMenu1: TXPBarMenu;
  17.     DBGridEh1: TDBGridEh;
  18.     jygl: TDataSource;
  19.     DataSource1: TDataSource;
  20.     PrintDBGridEh1: TPrintDBGridEh;
  21.     RadioGroup1: TRadioGroup;
  22.     ClientDataSet1: TClientDataSet;
  23.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  24.     procedure ToolButton7Click(Sender: TObject);
  25.     procedure ToolButton1Click(Sender: TObject);
  26.     procedure ToolButton2Click(Sender: TObject);
  27.     procedure ToolButton4Click(Sender: TObject);
  28.     procedure ToolButton6Click(Sender: TObject);
  29.     procedure RadioGroup1Click(Sender: TObject);
  30.     procedure ToolButton5Click(Sender: TObject);
  31.     procedure FormCreate(Sender: TObject);
  32.   private
  33.     { Private declarations }
  34.   public
  35.     { Public declarations }
  36.   end;
  37. var
  38.   am_ghgl: Tam_ghgl;
  39. implementation
  40. uses dms, am_ghgl_cxs, AM_Ghgl_Ps;
  41. {$R *.dfm}
  42. procedure Tam_ghgl.FormClose(Sender: TObject; var Action: TCloseAction);
  43. begin
  44.   action:=cafree;
  45.   am_ghgl:=nil;
  46. end;
  47. procedure Tam_ghgl.ToolButton7Click(Sender: TObject);
  48. begin
  49.  close;
  50. end;
  51. procedure Tam_ghgl.ToolButton1Click(Sender: TObject);
  52. var s,DateNOw:string;
  53. begin
  54.  If dm.v_gh.RecordCount<>0 then
  55.    begin
  56.     if application.MessageBox('您确认归还案卷','提示',mb_okcancel+mb_iconinformation)=idok then
  57.     begin
  58.       s:=dm.v_gh.fieldbyname('jy_xh').AsString;
  59.       dm.v_gh.Close;
  60.       dm.v_gh.CommandText:='select * from am_jygl where jy_xh='+''''+s+''''+'';
  61.       dm.v_gh.Open;
  62.       dm.am_jygl.FieldByName('jy_jyzt').AsString:='''已归还''';
  63.       dm.am_jygl.fieldbyname('jy_ghrq').AsString:=formatdatetime('Yyyy-mm-dd',NOw);
  64.       dm.am_jygl.ApplyUpdates(0);
  65.       dm.v_gh.Close;
  66.       dm.v_gh.CommandText:='select * from v_gh where jy_jyzt<>''已归还''';
  67.       dm.v_gh.Open;
  68.     end;
  69.    end
  70.  else
  71.    begin
  72.     application.MessageBox('当前表中没有数据,'+#13#10+'不能归还!','提示',mb_ok+mb_iconinformation);
  73.     ToolButton1.Enabled:=false;
  74.     exit;
  75.    end;
  76. end;
  77. procedure Tam_ghgl.ToolButton2Click(Sender: TObject);
  78. var DateNOw:Tdatetime;
  79.     sql_str:integer;
  80.     S_Dzdm,s_jyzt,s_Jyxh,s_Kfxj,s_sfyq:string;//读者代码,借阅状态,借阅序号,是否逾期
  81.     s_P,s_jyrq:string;//更改数据,借阅日期
  82.     N_Xjts:integer;//限借天数
  83. begin
  84.   dateNow:=strToDatetime(formatdatetime('yyyy-mm-dd',now));
  85.   sql_str:=dm.v_gh.fieldbyname('jy_xh').AsInteger;
  86.   N_Xjts:=dm.v_gh.fieldbyname('jygz_xjts').AsInteger;
  87.   s_Jyxh:=dm.v_gh.fieldbyname('JY_xh').asstring;
  88.   s_sfyq:='Jy_Yhrq>'+'Getdate()'+' and '+'jy_jyzt<>'+'''已归还'''+' and '+'Jy_xh='+''''+s_Jyxh+''''+'';
  89.   Clientdataset1.Close;
  90.   Clientdataset1.CommandText:='select * from V_gh where '+s_sfyq;
  91.   Clientdataset1.Open;
  92.   s_kfxj:=Clientdataset1.FieldByName('jygz_Xjtj').AsString;
  93.   if s_kfxj='不可以' then
  94.    begin
  95.      application.MessageBox('逾期未还,无法续借','提示',mb_ok+mb_iconinformation);
  96.      exit;
  97.    end;
  98.     s_jyrq:=dm.v_gh.FieldByName('jy_jyrq').AsString;
  99.     if s_Jyrq=datetimetostr(dateNOw) then
  100.      begin
  101.        application.MessageBox('今天刚借,无法续借','提示',mb_ok+mb_iconinformation);
  102.        exit;
  103.      end
  104.     else
  105.      begin
  106.        s_jyzt:=trim(dm.v_gh.FieldByName('jy_jyzt').AsString);
  107.        if s_jyzt='续借中' then
  108.         begin
  109.           application.MessageBox('今天刚续借,不能续借','提示',mb_ok+mb_iconinformation);
  110.           exit;
  111.         end
  112.         else
  113.         begin
  114.           dm.am_jygl.Close;
  115.           dm.am_jygl.CommandText:='select * from am_jygl where jy_xh='+''''+INtToStr(sql_str)+''''+'';
  116.           dm.am_jygl.Open;//续借
  117.           dm.am_jygl.Edit;
  118.           dm.am_jygl.FieldByName('jy_Jyrq').AsDateTime:=dateNOw;
  119.           dm.am_jygl.FieldByName('jy_Yhrq').AsDateTime:=dateNOw+N_xjts;
  120.           dm.am_jygl.ApplyUpdates(0);
  121.           if dm.am_jygl.RecordCount=0 then
  122.              application.MessageBox('续借成功','提示',mb_ok+mb_iconinformation);
  123.              dm.v_gh.Close;
  124.              dm.v_gh.CommandText:='select * from v_gh where jy_jyzt<>''已归还''';
  125.              dm.v_gh.Open;
  126.             exit;
  127.         end;//end if
  128.      end;
  129. end;
  130. procedure Tam_ghgl.ToolButton4Click(Sender: TObject);
  131. begin
  132.  RadioGroup1Click(nil);
  133. end;
  134. procedure Tam_ghgl.ToolButton6Click(Sender: TObject);
  135. begin
  136.   //PrintDBGridEh1.Preview;
  137.   Am_Ghgl_P:=TAm_Ghgl_P.create(application);
  138.   Am_Ghgl_P.QuickRep1.Preview;
  139. end;
  140. procedure Tam_ghgl.RadioGroup1Click(Sender: TObject);
  141. var s:string;
  142.     N:integer;
  143. begin
  144.  case RadioGroup1.ItemIndex of
  145.   0: begin
  146.       dm.v_gh.Close;
  147.       dm.v_gh.CommandText:='select * from v_gh where jy_jyzt<>''已归还''';
  148.       dm.v_gh.Open;
  149.       Toolbutton1.Enabled:=true;
  150.       ToolButton2.Enabled:=true;
  151.      end;//未归还
  152.   1: begin
  153.       dm.v_gh.Close;
  154.       dm.v_gh.CommandText:='select * from v_gh where jy_jyzt=''已归还''';
  155.       dm.v_gh.Open;
  156.       Toolbutton1.Enabled:=false;
  157.        if dm.v_gh.recordcount<>0 then
  158.         begin
  159.           Toolbutton1.Enabled:=true;
  160.           ToolButton2.Enabled:=true;
  161.         end
  162.        else
  163.         begin
  164.           Toolbutton1.Enabled:=false;
  165.           ToolButton2.Enabled:=false;
  166.         end;
  167.      end;//未还列表
  168.   2: begin
  169.       S:='Jy_Yhrq>'+'Getdate()'+' and '+'jy_jyzt<>'+'''已归还''';
  170.       dm.v_gh.Close;
  171.       dm.v_gh.CommandText:='select * from v_gh where '+s;
  172.       dm.v_gh.Open;
  173.       Toolbutton1.Enabled:=true;
  174.       ToolButton2.Enabled:=true;
  175.      end;
  176.  end;
  177. end;
  178. //*****************************************************************************
  179. procedure Tam_ghgl.ToolButton5Click(Sender: TObject);
  180. begin
  181.  if am_ghgl_cx=nil then
  182.   begin
  183.     am_ghgl_cx:=Tam_ghgl_cx.create(self);
  184.     am_ghgl_cx.showmodal;
  185.   end;
  186. end;
  187. procedure Tam_ghgl.FormCreate(Sender: TObject);
  188. var s,hint:string;
  189. begin
  190.   S:='Jy_Yhrq>'+'Getdate()'+' and '+'jy_jyzt<>'+'''已归还''';
  191.   dm.v_gh.Close;
  192.   dm.v_gh.CommandText:='select * from v_gh where '+s;
  193.   dm.v_gh.Open;
  194.   if dm.v_gh.RecordCount<>0 then
  195.     begin
  196.      Hint:='有'+INtToStr(dm.v_gh.RecordCount)+'应还纪录!';
  197.      Application.MessageBox(Pchar(Hint),'提示',mb_ok+mb_iconinformation);
  198.     end;
  199. end;
  200. end.