Unit27.~pas
资源名称:HIS.rar [点击查看]
上传用户:fjdqny
上传日期:2016-10-26
资源大小:6299k
文件大小:4k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Unit27;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, DB, ADODB, Grids, DBGrids, StdCtrls, ComCtrls;
- type
- TForm27 = class(TForm)
- PageControl1: TPageControl;
- TabSheet1: TTabSheet;
- TabSheet2: TTabSheet;
- Label1: TLabel;
- Edit1: TEdit;
- Label2: TLabel;
- Edit2: TEdit;
- Button1: TButton;
- Button2: TButton;
- DataSource1: TDataSource;
- DBGrid1: TDBGrid;
- ADOConnection1: TADOConnection;
- ADOQuery1: TADOQuery;
- ADOQuery2: TADOQuery;
- DataSource2: TDataSource;
- Label3: TLabel;
- Edit3: TEdit;
- Button3: TButton;
- DBGrid2: TDBGrid;
- Button4: TButton;
- Button5: TButton;
- Button6: TButton;
- procedure Button1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure Button5Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button6Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form27: TForm27;
- Query : TADOQuery;
- aaa,yonghu,mima:Char;
- implementation
- {$R *.dfm}
- procedure TForm27.FormCreate(Sender: TObject);
- begin
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from denglu');
- adoquery1.Open;
- end;
- procedure TForm27.Button1Click(Sender: TObject);
- begin
- if (Edit1.Text<>'') and (Edit2.text<>'') then
- begin
- Query := TADOQuery.Create(nil);
- Query.Connection :=ADOConnection1;
- Query.SQL.Add('select yonghu from denglu where yonghu =:aaa');
- Query.Parameters.ParamByName('aaa').Value :=edit1.Text;
- Query.Open;
- if Query.RecordCount <>0 then
- showmessage('此用户信息已存在!')
- else
- begin
- adoquery1.Open;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('insert into denglu(yonghu,mima) values(:yonghu,:mima)');
- adoquery1.Parameters.ParamByName('yonghu').Value:=Edit1.Text;
- adoquery1.Parameters.ParamByName('mima').Value:=Edit2.Text;
- adoquery1.ExecSQL;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from denglu');
- adoquery1.Open;
- edit1.Clear;edit2.Clear;
- showmessage('数据已经添加成功!');
- end
- end
- else
- if (Edit1.Text='') then
- showmessage('请输入用户!')
- else
- if (Edit2.Text='') then
- showmessage('请输入密码!');
- end;
- procedure TForm27.Button3Click(Sender: TObject);
- begin
- if (Edit3.Text<>'') then
- begin
- Query := TADOQuery.Create(nil);
- Query.Connection :=ADOConnection1;
- Query.SQL.Add('select yonghu from denglu where yonghu =:aaa');
- Query.Parameters.ParamByName('aaa').Value :=edit3.Text;
- Query.Open;
- if Query.RecordCount =0 then //非0表示存在,0表示不存在
- showmessage('此用户信息不存在!')
- else
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('select * from denglu where yonghu='''+edit3.Text+'''');
- adoquery2.Open;
- end
- end
- else
- showmessage('请输入用户名!');
- end;
- procedure TForm27.Button4Click(Sender: TObject);
- begin
- if (edit3.Text<>'') then
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('delete from denglu where yonghu='''+edit3.Text+'''');
- adoquery2.ExecSQL;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from denglu');
- adoquery1.Open;
- showmessage('数据已经删除成功!');
- end
- end;
- procedure TForm27.Button5Click(Sender: TObject);
- begin
- adoquery2.Post;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from denglu');
- adoquery1.Open;
- showmessage('数据已经修改成功!');
- end;
- procedure TForm27.Button2Click(Sender: TObject);
- begin
- form27.Close;
- end;
- procedure TForm27.Button6Click(Sender: TObject);
- begin
- form27.Close;
- end;
- end.