📄 spzl_unit.~pas
字号:
unit spzl_unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, DBGrids, ComCtrls, Menus;
type
Tspzl_form = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label11: TLabel;
Label13: TLabel;
Label16: TLabel;
Label17: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
DBGrid1: TDBGrid;
GroupBox6: TGroupBox;
SpeedButton15: TSpeedButton;
SpeedButton16: TSpeedButton;
SpeedButton17: TSpeedButton;
SpeedButton18: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
StatusBar1: TStatusBar;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
U1: TMenuItem;
F1: TMenuItem;
R1: TMenuItem;
Edit13: TEdit;
procedure SpeedButton18Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpeedButton15Click(Sender: TObject);
procedure SpeedButton16Click(Sender: TObject);
procedure SpeedButton17Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure N1Click(Sender: TObject);
procedure U1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure F1Click(Sender: TObject);
procedure R1Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit4KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit5KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit6KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit7KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit8KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit9KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit10KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit11KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit12KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit11KeyPress(Sender: TObject; var Key: Char);
procedure Edit12KeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
spzl_form: Tspzl_form;
implementation
uses data_unit, spzl_find_unit, spfl_unit, spzl_spfl_find_unit,
spzl_dw_find_unit;
{$R *.dfm}
procedure Tspzl_form.SpeedButton18Click(Sender: TObject);
begin
close;
end;
procedure Tspzl_form.FormCreate(Sender: TObject);
begin
self.Top :=74;
self.Left :=11;
self.Height :=491;
self.Width :=767;
with database do
begin
adoq1.Connection :=adoc;
adoq1.SQL.Clear ;
adoq1.SQL.Add('select * from spzl ');
adoq1.active:=true;
statusbar1.Panels[1].Text :=inttostr(adoq1.Recordset.RecordCount);
datas1.DataSet :=adoq1;
dbgrid1.DataSource:=datas1;
end;
end;
procedure Tspzl_form.SpeedButton15Click(Sender: TObject);
begin
if (length(edit1.Text)<>0) and (length(edit2.Text)<>0) then
begin
with database do
begin
adoq1.Connection :=adoc;
adoq1.SQL.Clear ;
adoq1.SQL.Add('select 商品编码 from spzl where 商品编码=:spbm');
adoq1.Parameters.ParamByName('spbm').Value:=edit1.Text;
adoq1.Active :=true;
if adoq1.Recordset.RecordCount >0 then
begin
showmessage('已有此信息,请重输!');
adoq1.SQL.Clear ;
adoq1.SQL.Add('select * from spzl order by 商品编码');
adoq1.Active :=true;
statusbar1.Panels[1].Text :=inttostr(adoq1.Recordset.RecordCount);
datas1.DataSet :=adoq1;
dbgrid1.DataSource:=datas1;
edit1.SetFocus ;
end
else
begin
adoq1.SQL.Clear ;
adoq1.SQL.Add('insert into spzl(商品编码,商品名称,拼音简码,简称,类别,规格,型号,单位,产地,备注,库存上限,库存下限) values(:spbm,:spmc,:pyjm,:jc,:lb,:gg,:xh,:dw,:cd,:bz,:kcsx,:kcxx)');
adoq1.parameters.ParamByName('spbm').value :=edit1.text;
adoq1.parameters.ParamByName('spmc').value :=edit2.text;
adoq1.parameters.ParamByName('pyjm').value :=edit3.text;
adoq1.Parameters.ParamByName('jc').Value :=edit4.Text;
adoq1.Parameters.ParamByName('lb').Value :=edit5.text;
adoq1.parameters.ParamByName('gg').value :=edit6.text;
adoq1.parameters.ParamByName('xh').value :=edit7.text;
adoq1.parameters.ParamByName('dw').value :=edit8.text;
adoq1.Parameters.ParamByName('cd').Value :=edit9.Text;
adoq1.Parameters.ParamByName('bz').Value :=edit10.text;
adoq1.parameters.ParamByName('kcsx').value :=strtofloat(edit11.text);
adoq1.parameters.ParamByName('kcxx').value :=strtofloat(edit12.text);
adoq1.ExecSQL ;
adoq1.SQL.Clear ;
adoq1.SQL.Add('select * from spzl');
adoq1.Active :=true;
datas1.DataSet :=adoq1;
dbgrid1.DataSource:=datas1;
statusbar1.Panels[1].Text :=inttostr(adoq1.Recordset.RecordCount);
edit1.Clear ;edit2.Clear ;edit3.Clear ;edit4.clear;edit5.Clear;edit6.Text ;
edit7.Clear ;edit8.Clear ;edit9.Clear ;edit10.clear;
edit11.text:='0';
edit12.text:='0';
edit1.SetFocus ;
end;
end ;
end
else
begin
showmessage('请输入商品编码和商品名称');
edit1.SetFocus ;
end;
end;
procedure Tspzl_form.SpeedButton16Click(Sender: TObject);
begin
speedbutton15.Enabled :=false;
speedbutton17.Enabled :=false;
with database do
begin
adoq1.Connection :=adoc;
adoq1.SQL.Clear ;
adoq1.SQL.Add('select * from spzl where 商品编码=:spbm');
adoq1.Parameters.ParamByName('spbm').Value:=edit13.Text;
adoq1.Active :=true;
if adoq1.Recordset.RecordCount >0 then
begin
edit1.Text :=adoq1.Fields.Fields[0].AsString ;
edit2.Text :=adoq1.Fields.Fields[1].AsString ;
edit3.Text :=adoq1.Fields.Fields[2].AsString ;
edit4.Text :=adoq1.Fields.Fields[3].AsString ;
edit5.Text :=adoq1.Fields.Fields[4].AsString ;
edit6.Text :=adoq1.Fields.Fields[5].AsString ;
edit7.Text :=adoq1.Fields.Fields[6].AsString ;
edit8.Text :=adoq1.Fields.Fields[7].AsString ;
edit9.Text :=adoq1.Fields.Fields[8].AsString ;
edit10.Text :=adoq1.Fields.Fields[9].AsString ;
edit11.Text :=adoq1.Fields.Fields[10].AsString ;
edit12.Text :=adoq1.Fields.Fields[11].AsString ;
edit1.ReadOnly :=true;
edit2.SetFocus ;
end
else
showmessage('请刷新选择记录!');
end;
end;
procedure Tspzl_form.SpeedButton17Click(Sender: TObject);
begin
with database do
begin
adoq1.Connection :=adoc;
if application.MessageBox('是否真的删除?','记录删除',4)=6 then
begin
adoq1.SQL.Clear ;
adoq1.SQL.Add('delete from spzl where 商品编码=:spbm');
adoq1.Parameters.ParamByName('spbm').Value:=edit13.Text;
adoq1.ExecSQL ;
end;
adoq1.SQL.Clear ;
adoq1.SQL.Add('select * from spzl');
adoq1.Active :=true;
datas1.DataSet:=adoq1;
dbgrid1.DataSource :=datas1;
statusbar1.Panels[1].Text :=inttostr(adoq1.Recordset.RecordCount);
end;
end;
procedure Tspzl_form.SpeedButton3Click(Sender: TObject);
begin
with database do
begin
adoq2.Connection :=adoc;
adoq2.SQL.Clear ;
adoq2.SQL.Add('update spzl set 商品名称=:spmc,拼音简码=:pyjm ,简称=:jc,类别=:lb,规格=:gg,');
adoq2.SQL.Add('型号=:xh,单位=:dw,产地=:cd,备注=:bz,库存上限=:kcsx,库存下限=:kcxx where 商品编码=:spbm');
adoq2.parameters.ParamByName('spbm').value :=edit13.text;
adoq2.parameters.ParamByName('spmc').value :=edit2.text;
adoq2.parameters.ParamByName('pyjm').value :=edit3.text;
adoq2.Parameters.ParamByName('jc').Value :=edit4.Text;
adoq2.Parameters.ParamByName('lb').Value :=edit5.text;
adoq2.parameters.ParamByName('gg').value :=edit6.text;
adoq2.parameters.ParamByName('xh').value :=edit7.text;
adoq2.parameters.ParamByName('dw').value :=edit8.text;
adoq2.Parameters.ParamByName('cd').Value :=edit9.Text;
adoq2.Parameters.ParamByName('bz').Value :=edit10.text;
adoq2.parameters.ParamByName('kcsx').value :=edit11.text;
adoq2.parameters.ParamByName('kcxx').value :=edit12.text;
adoq2.ExecSQL ;
adoq2.SQL.Clear ;
adoq2.SQL.Add('select * from spzl');
adoq2.Active :=true;
datas1.DataSet :=adoq2;
dbgrid1.DataSource:=datas1;
statusbar1.Panels[1].Text :=inttostr(adoq2.Recordset.RecordCount);
edit1.Clear ;edit2.Clear ;edit3.Clear ;edit4.clear;edit5.Clear;edit6.Text ;
edit7.Clear ;edit8.Clear ;edit9.Clear ;edit10.clear;
edit11.Text :='0';edit12.Text :='0';
edit1.SetFocus ;
edit1.ReadOnly :=false;
speedbutton15.Enabled :=true;
speedbutton17.Enabled :=true;
end;
end;
procedure Tspzl_form.SpeedButton4Click(Sender: TObject);
begin
speedbutton15.Enabled :=true;
speedbutton17.Enabled :=true;
edit1.ReadOnly :=false;
edit1.Clear ;edit2.Clear ;edit3.Clear ;edit4.clear;edit5.Clear;edit6.Text ;
edit7.Clear ;edit8.Clear ;edit9.Clear ;edit10.clear;
edit11.Text :='0';edit12.Text :='0';
edit1.SetFocus ;
end;
procedure Tspzl_form.SpeedButton6Click(Sender: TObject);
begin
speedbutton15.Enabled :=true;
speedbutton17.Enabled :=true;
edit1.ReadOnly :=false;
edit1.SetFocus ;
with database do
begin
adoq1.Connection :=adoc;
adoq1.SQL.Clear ;
adoq1.SQL.Add('select * from spzl order by 商品编码');
adoq1.Active :=true;
datas1.DataSet:=adoq1;
dbgrid1.DataSource :=datas1;
statusbar1.Panels[1].Text :=inttostr(adoq1.Recordset.RecordCount);
end;
end;
procedure Tspzl_form.DBGrid1CellClick(Column: TColumn);
begin
if dbgrid1.DataSource.DataSet.RecordCount>0 then
edit13.Text :=dbgrid1.DataSource.DataSet.FieldValues['商品编码'];
end;
procedure Tspzl_form.N1Click(Sender: TObject);
begin
speedbutton15click(nil);
end;
procedure Tspzl_form.U1Click(Sender: TObject);
begin
speedbutton16click(nil);
end;
procedure Tspzl_form.N2Click(Sender: TObject);
begin
speedbutton17click(nil);
end;
procedure Tspzl_form.F1Click(Sender: TObject);
begin
speedbutton5click(nil);
end;
procedure Tspzl_form.R1Click(Sender: TObject);
begin
speedbutton6click(nil);
end;
procedure Tspzl_form.SpeedButton5Click(Sender: TObject);
begin
edit1.Clear ;edit2.Clear ;edit3.Clear ;edit4.clear;edit5.Clear;edit6.Text ;
edit7.Clear ;edit8.Clear ;edit9.Clear ;edit10.clear;
edit11.Text :='0';edit12.Text :='0';
edit1.SetFocus ;
speedbutton15.Enabled :=true;
speedbutton17.Enabled :=true;
edit1.ReadOnly :=false;
edit1.SetFocus ;
spzl_find_form:=Tspzl_find_form.create(application);
spzl_find_form.show;
end;
procedure Tspzl_form.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
edit2.SetFocus ;
end;
procedure Tspzl_form.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
edit3.SetFocus ;
end;
procedure Tspzl_form.Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
edit4.SetFocus ;
end;
procedure Tspzl_form.Edit4KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
edit5.SetFocus ;
end;
procedure Tspzl_form.Edit5KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
speedbutton1click(nil);
end;
procedure Tspzl_form.Edit6KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
edit7.SetFocus ;
end;
procedure Tspzl_form.Edit7KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
edit8.SetFocus ;
end;
procedure Tspzl_form.Edit8KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
speedbutton2click(nil);
end;
procedure Tspzl_form.Edit9KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
edit10.SetFocus ;
end;
procedure Tspzl_form.Edit10KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
edit11.SetFocus ;
end;
procedure Tspzl_form.Edit11KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
edit12.SetFocus ;
end;
procedure Tspzl_form.Edit12KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
speedbutton15click(nil);
end;
procedure Tspzl_form.Edit11KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9','.',#8,#13]) then
begin
showmessage('请正确输入数值');
key:=#0;
edit11.SetFocus;
end;
end;
procedure Tspzl_form.Edit12KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9','.',#8,#13]) then
begin
showmessage('请正确输入数值');
key:=#0;
edit12.SetFocus;
end;
end;
procedure Tspzl_form.SpeedButton1Click(Sender: TObject);
begin
spzl_spfl_find_form:=Tspzl_spfl_find_form.create(application);
spzl_spfl_find_form.show;
end;
procedure Tspzl_form.SpeedButton2Click(Sender: TObject);
begin
spzl_dw_find_form:=Tspzl_dw_find_form.Create(application);
spzl_dw_find_form.Show ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -