Unit12.~pas
资源名称:HIS.rar [点击查看]
上传用户:fjdqny
上传日期:2016-10-26
资源大小:6299k
文件大小:6k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Unit12;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, Grids, DBGrids, ComCtrls, DB, ADODB;
- type
- TForm12 = class(TForm)
- PageControl1: TPageControl;
- TabSheet1: TTabSheet;
- TabSheet2: TTabSheet;
- Label1: TLabel;
- Edit1: TEdit;
- Label2: TLabel;
- Label3: TLabel;
- Edit2: TEdit;
- Edit3: TEdit;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Edit4: TEdit;
- Edit5: TEdit;
- Edit6: TEdit;
- Label7: TLabel;
- Label8: TLabel;
- Edit8: TEdit;
- DBGrid1: TDBGrid;
- Button1: TButton;
- Button2: TButton;
- Label9: TLabel;
- Edit9: TEdit;
- Label10: TLabel;
- Edit10: TEdit;
- Button3: TButton;
- Button4: TButton;
- Button5: TButton;
- Button6: TButton;
- ComboBox1: TComboBox;
- ADOConnection1: TADOConnection;
- ADOQuery1: TADOQuery;
- DataSource1: TDataSource;
- DataSource2: TDataSource;
- ADOQuery2: TADOQuery;
- DBGrid2: TDBGrid;
- procedure FormCreate(Sender: TObject);
- procedure Button1Click(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
- Form12: TForm12;
- Docno,Doc,Sex,Birth,Duty,Post,Dep,Isfree,aaa:Char;
- Query : TADOQuery;
- implementation
- {$R *.dfm}
- procedure TForm12.FormCreate(Sender: TObject);
- begin
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yisheng');
- adoquery1.Open;
- end;
- procedure TForm12.Button1Click(Sender: TObject);
- begin
- if (Edit1.Text<>'') and (Edit4.text<>'') then
- begin
- Query := TADOQuery.Create(nil);
- Query.Connection :=ADOConnection1;
- Query.SQL.Add('select Docno from yisheng where Docno =: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 yisheng(Docno,Doc,Sex,Birth,Duty,Post,Dep,Isfree) values(:Docno,:Doc,:Sex,:Birth,:Duty,:Post,:Dep,:Isfree)');
- adoquery1.Parameters.ParamByName('Docno').Value:=Edit1.Text;
- adoquery1.Parameters.ParamByName('Doc').Value:=Edit4.Text;
- adoquery1.Parameters.ParamByName('Sex').Value:=ComboBox1.Text;
- adoquery1.Parameters.ParamByName('Birth').Value:=Edit2.Text;
- adoquery1.Parameters.ParamByName('Duty').Value:=Edit5.Text;
- adoquery1.Parameters.ParamByName('Post').Value:=Edit8.Text;
- adoquery1.Parameters.ParamByName('Dep').Value:=Edit3.Text;
- adoquery1.Parameters.ParamByName('Isfree').Value:=Edit6.Text;
- adoquery1.ExecSQL;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yisheng');
- adoquery1.Open;
- edit1.Clear;edit2.Clear;edit3.clear;edit4.clear;edit5.clear;edit6.clear;edit8.clear;ComboBox1.Text:='';
- showmessage('数据已经添加成功!');
- end
- end
- else
- if (Edit1.Text='') then
- showmessage('请输入医生编号!')
- else
- if (Edit4.Text='') then
- showmessage('请输入医生姓名!');
- end;
- procedure TForm12.Button3Click(Sender: TObject);
- begin
- if (Edit9.Text<>'') then
- begin
- Query := TADOQuery.Create(nil);
- Query.Connection :=ADOConnection1;
- Query.SQL.Add('select Docno from yisheng where Docno =:aaa');
- Query.Parameters.ParamByName('aaa').Value :=edit9.Text;
- Query.Open;
- if Query.RecordCount =0 then //非0表示存在,0表示不存在
- showmessage('此医生信息不存在!')
- else
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('select * from yisheng where Docno='''+edit9.Text+'''');
- adoquery2.Open;
- end
- end
- else
- if(Edit10.Text<>'') then
- begin
- Query := TADOQuery.Create(nil);
- Query.Connection :=ADOConnection1;
- Query.SQL.Add('select Doc from yisheng where Doc =:aaa');
- Query.Parameters.ParamByName('aaa').Value :=edit10.Text;
- Query.Open;
- if Query.RecordCount =0 then //非0表示存在,0表示不存在
- showmessage('此医生信息不存在!')
- else
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('select * from yisheng where Doc='''+edit10.Text+'''');
- adoquery2.Open;
- end
- end
- else
- showmessage('请输入医生编号或姓名!');
- end;
- procedure TForm12.Button4Click(Sender: TObject);
- begin
- if (edit9.Text<>'') then
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('delete from yisheng where Docno='''+edit9.Text+'''');
- adoquery2.ExecSQL;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yisheng');
- adoquery1.Open;
- showmessage('数据已经删除成功!');
- end
- else
- if(Edit10.Text<>'') then
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('delete from yisheng where Doc='''+edit10.Text+'''');
- adoquery2.ExecSQL;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yisheng');
- adoquery1.Open;
- showmessage('数据已经删除成功!');
- end
- end;
- procedure TForm12.Button5Click(Sender: TObject);
- begin
- adoquery2.Post;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yisheng');
- adoquery1.Open;
- showmessage('数据已经修改成功!');
- end;
- procedure TForm12.Button2Click(Sender: TObject);
- begin
- form12.Close;
- end;
- procedure TForm12.Button6Click(Sender: TObject);
- begin
- form12.Close;
- end;
- end.