am_dzbjs.pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:5k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit am_dzbjs;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Buttons, ExtCtrls, StdCtrls, DB, Mask, DBCtrls, DBCtrlsEh;
- type
- Tam_dzbj = class(TForm)
- Image1: TImage;
- Label1: TLabel;
- Panel1: TPanel;
- SpeedButton1: TSpeedButton;
- SpeedButton2: TSpeedButton;
- Label2: TLabel;
- DBEdit1: TDBEdit;
- Label3: TLabel;
- DBEdit2: TDBEdit;
- Label4: TLabel;
- DBEdit3: TDBEdit;
- Label5: TLabel;
- Label6: TLabel;
- DBEdit5: TDBEdit;
- Label7: TLabel;
- DBEdit6: TDBEdit;
- Label8: TLabel;
- Label9: TLabel;
- DBEdit8: TDBEdit;
- Label10: TLabel;
- Label11: TLabel;
- Label12: TLabel;
- Label13: TLabel;
- zjlb: TDBLookupComboBox;
- jyjb: TDBLookupComboBox;
- DBDateTimeEditEh1: TDBDateTimeEditEh;
- DataSource1: TDataSource;
- Label14: TLabel;
- Label15: TLabel;
- MaskEdit1: TMaskEdit;
- procedure FormKeyPress(Sender: TObject; var Key: Char);
- procedure SpeedButton2Click(Sender: TObject);
- procedure SpeedButton1Click(Sender: TObject);
- procedure DBEdit6Exit(Sender: TObject);
- procedure DBEdit8Exit(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure DBEdit4KeyPress(Sender: TObject; var Key: Char);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormCreate(Sender: TObject);
- procedure DBEdit8KeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- am_dzbj: Tam_dzbj;
- implementation
- uses DMs,am_dzs, mainfrms;
- {$R *.dfm}
- procedure Tam_dzbj.FormKeyPress(Sender: TObject; var Key: Char);
- begin
- if key=#13 then
- begin
- key:=#0;
- perform(WM_NEXTDLGCTL,0,0);
- END;
- end;
- procedure Tam_dzbj.SpeedButton2Click(Sender: TObject);
- begin
- close;
- end;
- procedure Tam_dzbj.SpeedButton1Click(Sender: TObject);
- var i:integer;
- begin
- if dbedit1.Text='' then
- begin
- application.MessageBox('读者代码不能为空!','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- if dbedit2.Text='' then
- begin
- application.MessageBox('读者姓名不能为空!','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- if zjlb.Text='' then
- begin
- application.MessageBox('证件类别不能为空!','提示',mb_ok+mb_iconinformation);
- zjlb.SetFocus;
- exit;
- end;
- if jyjb.Text='' then
- begin
- application.MessageBox('借阅级别不能为空!','提示',mb_ok+mb_iconinformation);
- jyjb.SetFocus;
- exit;
- end;
- //-----------------------------------------
- dm.am_dz.Edit;
- dm.am_dz.FieldByName('dz_djsj').AsString:=DBDateTimeEditEh1.Text;
- dm.am_dz.FieldByName('dz_lxdh').AsString:=maskedit1.Text;
- Dm.am_dz.ApplyUpdates(0);
- i:=Dm.am_dz.ApplyUpdates(0);
- if i=0 then
- begin
- application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
- dm.am_dz.Close;
- dm.am_dz.CommandText:='select * from am_dz';
- dm.am_dz.Open;
- //刷新视图
- dm.V_DZ.Close;
- dm.V_DZ.CommandText:='select * from V_DZ';
- dm.V_DZ.Open;
- close;
- end
- else
- begin
- application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- end;
- procedure Tam_dzbj.DBEdit6Exit(Sender: TObject);
- var
- Email,s:string;
- Etpos:integer;
- begin
- Email:=dbEdit6.Text;
- etpos:=pos('@',Email);
- if etpos>1 then
- begin
- s:=copy(email,etpos+1,length(email));
- if (pos('.',s)>1)and(pos('.',s)<length(s)) then
- begin
- end
- else
- begin
- application.MessageBox('电子邮件格式不对!','提示',mb_ok+mb_iconinformation);
- dbedit6.SetFocus;
- end
- end
- else
- begin
- application.MessageBox('电子邮件格式不对!','提示',mb_ok+mb_iconinformation);
- dbedit6.SetFocus;
- end;
- end;
- procedure Tam_dzbj.DBEdit8Exit(Sender: TObject);
- begin
- if trim(zjlb.Text)='身份证' then
- begin
- if length(dbedit8.Text)<>0 then
- if (length(dbedit8.Text)=15) or(length(dbedit8.Text)=18) then
- begin
- try
- strtofloat(dbedit8.Text)
- except
- application.MessageBox('身份证号码不对!','提示',mb_ok+mb_iconinformation);
- dbedit8.SetFocus;
- exit;
- end
- end
- else
- begin
- application.MessageBox('身份证号码必须为15或18位!','提示',mb_ok+mb_iconinformation);
- dbedit8.SetFocus;
- exit;
- end;
- //---------------------
- end;
- end;
- procedure Tam_dzbj.FormShow(Sender: TObject);
- begin
- dbdatetimeediteh1.Value:=now;
- end;
- procedure Tam_dzbj.DBEdit4KeyPress(Sender: TObject; var Key: Char);
- //var Epos:integer;
- begin
- {if not (Key in ['0'..'9','-'] ) then
- begin
- Key:=#0;
- application.MessageBox('请输入正确的电话格式:','提示',mb_ok+mb_iconinformation);
- end
- else
- if length(trim(dbedit4.Text))=4 then
- begin
- dbedit4.Text:=dbedit4.Text+'-';
- end;}
- end;
- procedure Tam_dzbj.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- action:=cafree;
- am_dzbj:=Nil;
- end;
- procedure Tam_dzbj.FormCreate(Sender: TObject);
- begin
- Dm.am_dz.Active:=true;
- dm.am_jygz.Active:=true;
- DM.sz_zjlb.Active:=true;
- dm.V_DZ.Close;
- dm.V_DZ.CommandText:='select * from v_dz';
- dm.V_DZ.Open;
- end;
- procedure Tam_dzbj.DBEdit8KeyPress(Sender: TObject; var Key: Char);
- begin
- mainfrm.DbInputNum(DbEdit8,key);
- end;
- end.