📄 addproduct.pas
字号:
unit addproduct;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, Buttons, Grids, DBGrids, ExtCtrls;
type
Taddproductfrm = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
ComboBox1: TComboBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
ADOQuery1: TADOQuery;
Label7: TLabel;
Edit6: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
Panel1: TPanel;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
addproductfrm: Taddproductfrm;
implementation
uses main;
{$R *.dfm}
procedure Taddproductfrm.BitBtn1Click(Sender: TObject);
begin
if edit1.text='' then
messagebox(addproductfrm.Handle,'请输入货品名称','警告',mb_ok+mb_iconwarning)
else
if edit4.text='' then
messagebox(addproductfrm.Handle,'请输入底线库存','警告',mb_ok+mb_iconwarning)
else
if edit5.Text='' then
messagebox(addproductfrm.Handle,'请输入高线库存','警告',mb_ok+mb_iconwarning)
else
begin
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('insert into PRODUCT(productid,productname,class,spec,unit,min_sto,max_sto)values(');
sql.Add(''''+edit6.Text+''''+','+''''+edit1.Text+''''+','+''''+combobox1.Text+''''+','+''''+edit2.Text+'''');
sql.add(','+''''+edit3.Text+''''+','+''''+edit4.Text+''''+','+''''+edit5.Text+''''+')');
execsql;
end;
messagebox(addproductfrm.Handle,'货品信息已经成功添加','恭喜',mb_ok);
end;
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from PRODUCT where productid='+''''+edit6.Text+'''' );
open;
first;
dbgrid1.Columns[0].FieldName:='productid';
dbgrid1.Columns[1].FieldName:='productname';
dbgrid1.Columns[2].FieldName:='spec';
dbgrid1.Columns[3].FieldName:='min_sto';
dbgrid1.Columns[4].FieldName:='class';
dbgrid1.Columns[5].FieldName:='unit';
dbgrid1.Columns[6].FieldName:='max_sto';
end;
end;
procedure Taddproductfrm.BitBtn2Click(Sender: TObject);
begin
edit1.text:='';
combobox1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
end;
procedure Taddproductfrm.BitBtn3Click(Sender: TObject);
begin
addproductfrm.Hide;
mainfrm.Show;
end;
procedure Taddproductfrm.FormCreate(Sender: TObject);
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from PRODUCT' );
open;
first;
dbgrid1.Columns[0].FieldName:='productid';
dbgrid1.Columns[1].FieldName:='productname';
dbgrid1.Columns[2].FieldName:='spec';
dbgrid1.Columns[3].FieldName:='min_sto';
dbgrid1.Columns[4].FieldName:='class';
dbgrid1.Columns[5].FieldName:='unit';
dbgrid1.Columns[6].FieldName:='max_sto';
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -