📄 unit2.pas
字号:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Mask, StdCtrls, Grids, DBGrids, ExtCtrls, DB, ADODB, ComCtrls,
Buttons, FR_DSet, FR_DBSet, FR_Class, FR_Shape, FR_Chart, FR_BarC,
FR_Rich, FR_RRect,SHELLAPI,comobj;
type
TShebei_F = class(TForm)
Bevel1: TBevel;
DBGrid1: TDBGrid;
ComboBox1: TComboBox;
x: TGroupBox;
BH_Bt: TEdit;
XH_Bt: TEdit;
GroupBox2: TGroupBox;
MCH_Bt: TEdit;
JYLB_Bt: TEdit;
CLJD_Bt: TEdit;
CJDH_Bt: TEdit;
SJDH_Bt: TEdit;
GYS_Bt: TEdit;
SCCJ_Bt: TEdit;
FBL_Bt: TEdit;
ZHT_Bt: TEdit;
XLH_Bt: TEdit;
CLFW_Bt: TEdit;
BGR_Bt: TEdit;
JG_Bt: TEdit;
CFDD_Bt: TEdit;
DABH_Bt: TEdit;
MaskEdit1: TMaskEdit;
MaskEdit2: TMaskEdit;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
StaticText7: TStaticText;
StaticText8: TStaticText;
StaticText9: TStaticText;
StaticText10: TStaticText;
StaticText11: TStaticText;
StaticText12: TStaticText;
StaticText13: TStaticText;
StaticText14: TStaticText;
StaticText15: TStaticText;
StaticText16: TStaticText;
StaticText2: TStaticText;
StaticText17: TStaticText;
StaticText18: TStaticText;
StaticText19: TStaticText;
StaticText20: TStaticText;
StaticText21: TStaticText;
Button1: TButton;
Button2: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
ComboBox2: TComboBox;
StatusBar1: TStatusBar;
frReport1: TfrReport;
frDBDataSet1: TfrDBDataSet;
frShapeObject1: TfrShapeObject;
Button3: TButton;
frBarCodeObject1: TfrBarCodeObject;
frShapeObject2: TfrShapeObject;
frRichObject1: TfrRichObject;
StaticText22: TStaticText;
CheckBox1: TCheckBox;
StaticText23: TStaticText;
CheckBox2: TCheckBox;
Button4: TButton;
Edit1: TEdit;
frRoundRectObject1: TfrRoundRectObject;
Edit2: TEdit;
Button5: TButton;
StaticText1: TStaticText;
StaticText24: TStaticText;
StaticText25: TStaticText;
frReport2: TfrReport;
frReport3: TfrReport;
sopn: TEdit;
zjgcn: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
bz: TMemo;
Label4: TLabel;
procedure ClearAll;
procedure Button1Click(Sender: TObject);
procedure JG_BtKeyPress(Sender: TObject; var Key: Char);
procedure DBGrid1CellClick(Column: TColumn);
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button5Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure SpeedButton1Click(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Shebei_F: TShebei_F;
implementation
uses Unit4;
{$R *.dfm}
procedure Tshebei_F.ClearAll;
begin
bh_bt.Text:='';
mch_bt.Text:='';
combobox2.Text:='';
xh_bt.Text:='';
xlh_bt.Text:='';
cfdd_bt.Text:='';
jylb_bt.Text:='';
zht_bt.Text:='';
jg_bt.Text:='';
clfw_bt.Text:='';
fbl_bt.Text:='';
dabh_bt.Text:='';
cljd_bt.Text:='';
maskedit1.Text:='9999-12-31';
maskedit2.Text:='9999-12-31';
sccj_bt.Text:='';
cjdh_bt.Text:='';
gys_bt.Text:='';
sjdh_bt.Text:='';
bgr_bt.Text:='';
checkbox1.Checked:=false;
checkbox2.Checked:=false;
sopn.Text:='';
zjgcn.Text:='';
bz.Text:='';
end;
procedure TShebei_F.Button1Click(Sender: TObject);
var
sql:string;
adoquery2:TAdoquery;
searchOptions:TlocateOptions;
begin
if RadioButton1.Checked then
begin
AdoQuery1.Close;
Adoquery2:=TAdoquery.Create(self);
Adoquery2.Connection:=adoconnection1;
if (trim(bh_bt.text)='')then
begin
MessageBox(handle,'唯一号不能少!','警告',MB_ok or MB_ICONwarning);
exit;
end;
adoquery2.sql.Add('select * from jibenxinxi order by 唯一号');
adoquery2.Open;
if adoquery2.Locate(adoquery2.Fields[0].FieldName,bh_bt.Text,searchOptions)
then
begin
Application.MessageBox('这个唯一号已经存在!','提示',0+64);
exit;
end;
if zjgcn.Text<>'' then
if adoquery2.Locate('自检规程号',zjgcn.Text,searchOptions)
then
begin
Application.MessageBox('已经存在相同的自检规程号!','提示',0+64);
exit;
end;
if sopn.Text<>'' then
if adoquery2.Locate('sop号',sopn.Text,searchOptions)
then
begin
Application.MessageBox('已经存在相同的SOP号!','提示',0+64);
exit;
end;
if (trim(jg_Bt.Text)='') then
begin
messagedlg('仪器不会白送给您!^_^',mtinformation,[mbOK],0);
jg_bt.SetFocus;
exit;
end;
if (trim(combobox2.Text)='') then
begin
messagedlg('哪个科室用的?',mtinformation,[mbOK],0);
exit;
end;
if (trim(mch_Bt.Text)='') then
begin
messagedlg('好歹取个名字吧~',mtinformation,[mbOK],0);
mch_bt.SetFocus;
exit;
end;
adoquery2.close;
Adoquery2.sql.clear;
adoquery2.sql.add('insert into JibenXinxi values(:BH,:MCH,:XH,:XLH,:JYLB,:ZHT,:CLFW,:FBL,:CLJD,:SCCJ,:CJDH,:GYS,:SJDH,:DATE1,:DATE2,:KS,:CFDD,:BGR,:JG,:DABH,:sop,:zjgc,:sopn,:zjgcn,:bz)');
adoquery2.Parameters.clear;
adoquery2.Parameters.CreateParameter('BH',ftstring,pdinput,20,BH_BT.text);
adoquery2.Parameters.CreateParameter('MCH',ftstring,pdinput,20,MCH_BT.text);
adoquery2.Parameters.CreateParameter('XH',ftstring,pdinput,20,XH_bT.text);
adoquery2.Parameters.CreateParameter('XLH',ftstring,pdinput,30,XLH_BT.text);
adoquery2.Parameters.CreateParameter('JYLB',ftstring,pdinput,20,JYLB_BT.text);
adoquery2.Parameters.CreateParameter('ZHT',ftstring,pdinput,20,ZHT_bT.Text);
adoquery2.Parameters.CreateParameter('CLFW',ftstring,pdinput,20,CLFW_BT.Text);
adoquery2.Parameters.CreateParameter('FBL',ftstring,pdinput,20,FBL_BT.Text);
adoquery2.Parameters.CreateParameter('CLJD',ftstring,pdinput,20,CLJD_BT.Text);
adoquery2.Parameters.CreateParameter('SCCJ',ftstring,pdinput,20,SCCJ_BT.Text);
adoquery2.Parameters.CreateParameter('CJDH',ftstring,pdinput,20,CJDH_BT.Text);
adoquery2.Parameters.CreateParameter('GYS',ftstring,pdinput,20,GYS_bt.Text);
adoquery2.Parameters.CreateParameter('SJDH',ftstring,pdinput,20,SJDH_bt.Text);
adoquery2.Parameters.CreateParameter('DATE1',ftDATETIME,pdinput,8,STRTODATE(MASKEDIT1.Text));
adoquery2.Parameters.CreateParameter('DATE2',ftDATETIME,pdinput,8,STRTODATE(MASKEDIT2.Text));
adoquery2.Parameters.CreateParameter('KS',ftstring,pdinput,20,combobox2.Text);
adoquery2.Parameters.CreateParameter('CFDD',ftstring,pdinput,20,CFDD_BT.Text);
adoquery2.Parameters.CreateParameter('BGR',ftstring,pdinput,20,BGR_bt.Text);
adoquery2.Parameters.CreateParameter('JG',ftCurrency,pdinput,20,strtofloat(JG_bt.Text));
adoquery2.Parameters.CreateParameter('DABH',ftstring,pdinput,20,DABH_bt.Text);
adoquery2.Parameters.CreateParameter('sop',ftboolean,pdinput,1,checkbox1.Checked);
adoquery2.Parameters.CreateParameter('zjgc',ftboolean,pdinput,1,checkbox2.Checked);
adoquery2.Parameters.CreateParameter('sopn',ftstring,pdinput,20,sopn.Text);
adoquery2.Parameters.CreateParameter('zjgcn',ftstring,pdinput,20,zjgcn.Text);
adoquery2.Parameters.CreateParameter('bz',ftstring,pdinput,100,bz.Text);
adoquery2.Prepared;
adoquery2.ExecSQL;
ADOquery1.Open;
application.MessageBox('已经添加','提示',0+64);
ClearAll;
end
else if radiobutton2.Checked then
begin
AdoQuery1.Close;
adoquery2:=TAdoquery.Create(self);
adoquery2.Connection:=adoconnection1;
if (trim(bh_bt.text)='')then
begin
messagedlg('请选定记录!!',mtwarning,[mbOK],0);
exit;
end;
adoquery2.sql.Add('select * from jibenxinxi order by 唯一号');
adoquery2.Open;
if not adoquery2.Locate(adoquery2.Fields[0].FieldName,bh_bt.Text,searchOptions)
then
begin
messagedlg('这个记录不存在!!',mtwarning,[mbOK],0);
exit;
end;
adoquery2.Close;
adoquery2.SQL.Clear;
sql:='delete from jibenxinxi where 唯一号="'+bh_bt.Text+'"';
adoquery2.SQL.Add(sql);
adoquery2.ExecSQL;
adoquery1.Open;
showmessage('已经删除!');
clearall;
end
else if radiobutton3.Checked then
begin
AdoQuery1.Close;
adoquery2:=TAdoquery.Create(self);
adoquery2.Connection:=adoconnection1;
if (trim(bh_bt.text)='')then
begin
messagedlg('请选定记录!!',mtwarning,[mbOK],0);
exit;
end;
adoquery2.sql.Add('select * from jibenxinxi order by 唯一号');
adoquery2.Open;
if not adoquery2.Locate(adoquery2.Fields[0].FieldName,bh_bt.Text,searchOptions)
then
begin
messagedlg('这个记录不存在!!',mtwarning,[mbOK],0);
exit;
end;
with adoquery2 do
begin
try
edit;
fieldbyname('唯一号').AsString:=bh_bt.Text;
fieldbyname('名称').AsString:=mch_bt.Text;
fieldbyname('科室').AsString:=combobox2.Text;
fieldbyname('型号').AsString:=xh_bt.Text;
fieldbyname('产品系列号').AsString:=xlh_bt.Text;
fieldbyname('存放地点').AsString:=cfdd_bt.Text;
fieldbyname('检定方式').AsString:=jylb_bt.Text;
fieldbyname('状态').AsString:=zht_bt.Text;
fieldbyname('价格').AsCurrency:=strtofloat(jg_bt.Text);
fieldbyname('测量范围').AsString:=clfw_bt.Text;
fieldbyname('分辨率').AsString:=fbl_bt.Text;
fieldbyname('档案编号').AsString:=dabh_bt.Text;
fieldbyname('测量精度').AsString:=cljd_bt.Text;
fieldbyname('保管人').AsString:=bgr_bt.Text;
fieldbyname('购入日期').AsDateTime:=strtodate(maskedit1.Text);
fieldbyname('生产厂家').AsString:=sccj_bt.Text;
fieldbyname('厂家电话').AsString:=cjdh_bt.Text;
fieldbyname('使用日期').AsDateTime:=strtodate(maskedit2.Text);
fieldbyname('供应商').AsString:=gys_bt.Text;
fieldbyname('商家电话').AsString:=sjdh_bt.Text;
fieldbyname('有否SOP').AsBoolean:=checkbox1.Checked;
fieldbyname('自检规程').AsBoolean:=checkbox2.Checked;
fieldbyname('SOP号').AsString:=sopn.Text;
fieldbyname('自检规程号').AsString:=zjgcn.Text;
fieldbyname('备注').AsString:=bz.Text;
post;
Application.MessageBox('修改成功!','提示',0+64);
Except
Application.MessageBox('系统出错,注意数据输入完整','提示',0+64);
close;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -