Unit16.~pas
资源名称:HIS.rar [点击查看]
上传用户:fjdqny
上传日期:2016-10-26
资源大小:6299k
文件大小:4k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Unit16;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Grids, DBGrids, StdCtrls, ComCtrls, DB, ADODB;
- type
- TForm16 = class(TForm)
- PageControl1: TPageControl;
- TabSheet1: TTabSheet;
- TabSheet2: TTabSheet;
- Label1: TLabel;
- Edit1: TEdit;
- Label2: TLabel;
- Label3: TLabel;
- Edit2: TEdit;
- Edit3: TEdit;
- Label4: TLabel;
- Edit4: TEdit;
- Label5: TLabel;
- Edit5: TEdit;
- Label6: TLabel;
- Edit6: TEdit;
- Label7: TLabel;
- Edit7: TEdit;
- Button1: TButton;
- Button2: TButton;
- DBGrid1: TDBGrid;
- Label8: TLabel;
- Edit8: TEdit;
- Label9: TLabel;
- Edit9: TEdit;
- Button3: TButton;
- Button4: TButton;
- Button5: TButton;
- Button6: TButton;
- ADOConnection1: TADOConnection;
- ADOQuery1: TADOQuery;
- ADOQuery2: TADOQuery;
- DataSource1: TDataSource;
- DataSource2: TDataSource;
- 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
- Form16: TForm16;
- Medno,Med,Byname,Price,Func,Dat,Valid:Char;
- implementation
- {$R *.dfm}
- procedure TForm16.FormCreate(Sender: TObject);
- begin
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yaopin');
- adoquery1.Open;
- end;
- procedure TForm16.Button1Click(Sender: TObject);
- begin
- if (Edit1.Text<>'') and (Edit2.text<>'') and(Edit4.Text<>'') then
- begin
- adoquery1.Open;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('insert into yaopin(Medno,Med,Byname,Price,Func,Dat,Valid) values(:Medno,:Med,:Byname,:Price,:Func,:Dat,:Valid)');
- adoquery1.Parameters.ParamByName('Medno').Value:=Edit1.Text;
- adoquery1.Parameters.ParamByName('Med').Value:=Edit2.Text;
- adoquery1.Parameters.ParamByName('Byname').Value:=Edit3.Text;
- adoquery1.Parameters.ParamByName('Price').Value:=strtoint(Edit4.Text);
- adoquery1.Parameters.ParamByName('Func').Value:=Edit5.Text;
- adoquery1.Parameters.ParamByName('Dat').Value:=Edit6.Text;
- adoquery1.Parameters.ParamByName('Valid').Value:=Edit7.Text;
- adoquery1.ExecSQL;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yaopin');
- adoquery1.Open;
- edit1.Clear;edit2.Clear;edit3.clear;edit4.clear;edit5.clear;edit6.clear;edit7.clear;
- showmessage('数据已经添加成功!');
- end
- else
- if (Edit1.Text='') then
- showmessage('请输入药品编号!')
- else
- if (Edit2.Text='') then
- showmessage('请输入药品姓名!')
- else
- if (Edit4.Text='') then
- showmessage('请输入药品价格!');
- end;
- procedure TForm16.Button3Click(Sender: TObject);
- begin
- if (Edit8.Text<>'') then
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('select * from yaopin where Medno='''+edit8.Text+'''');
- adoquery2.Open;
- end
- else
- if(Edit9.Text<>'') then
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('select * from yaopin where Med='''+edit9.Text+'''');
- adoquery2.Open;
- end
- else
- showmessage('请输入药品编号或姓名!');
- end;
- procedure TForm16.Button4Click(Sender: TObject);
- begin
- if (edit8.Text<>'') then
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('delete from yaopin where Medno='''+edit8.Text+'''');
- adoquery2.ExecSQL;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yaopin');
- adoquery1.Open;
- showmessage('数据已经删除成功!');
- end
- else
- if(Edit9.Text<>'') then
- begin
- adoquery2.Close;
- adoquery2.SQL.Clear;
- adoquery2.SQL.Add('delete from yaopin where Med='''+edit9.Text+'''');
- adoquery2.ExecSQL;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yaopin');
- adoquery1.Open;
- showmessage('数据已经删除成功!');
- end
- end;
- procedure TForm16.Button5Click(Sender: TObject);
- begin
- adoquery2.Post;
- adoquery1.Close;
- adoquery1.SQL.Clear;
- adoquery1.SQL.Add('select * from yaopin');
- adoquery1.Open;
- showmessage('数据已经修改成功!');
- end;
- procedure TForm16.Button2Click(Sender: TObject);
- begin
- form16.Close;
- end;
- procedure TForm16.Button6Click(Sender: TObject);
- begin
- form16.Close;
- end;
- end.