📄 spjcxxgl.~pas
字号:
begin
Close;
SQL.Clear;
SQL.Add('select * from 商品基础信息表 where 商品编号 = :a');
Parameters.ParamByName('a').Value := Trim(Edit1.Text);
Open;
end;
if Data.ADOQuery1.RecordCount > 0 then
begin
Application.MessageBox('该商品已经存在。','提示',0+64);
Exit;
end;
if StrToFloat(Trim(Edit8.Text))>StrToFloat(Trim(Edit9.Text))then
if Application.MessageBox('批发价确实要大于零售价吗?','提示',MB_YESNO)<> ID_Yes then
Exit;
Try
With Data.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('Insert 商品基础信息表 values ( :a,:b,:c,:d,:e,:f,:h,:i,:j,:k,:l,:aa,:m )');
Parameters.ParamByName('a').Value := Trim(Edit1.Text);
Parameters.ParamByName('b').Value := Trim(Edit2.Text);
Parameters.ParamByName('c').Value := Trim(Edit3.Text);
Parameters.ParamByName('d').Value := Trim(Edit4.Text);
Parameters.ParamByName('e').Value := Trim(Edit5.Text);
Parameters.ParamByName('f').Value := Trim(Edit6.Text);
Parameters.ParamByName('h').Value := StrToInt(Trim(Edit11.Text));
Parameters.ParamByName('i').Value := StrToFloat(Trim(Edit7.Text));
Parameters.ParamByName('j').Value := StrToFloat(Trim(Edit8.Text));
Parameters.ParamByName('k').Value := StrToFloat(Trim(Edit9.Text));
Parameters.ParamByName('l').Value := Trim(Edit12.Text);
Parameters.ParamByName('aa').Value := Trim(ComboBox1.Text);
Parameters.ParamByName('m').Value := Trim(Edit10.Text);
ExecSQL;
end;
Application.MessageBox('保存成功。','提示',0+64);
BitBtn1.Enabled := True;
BitBtn2.Enabled := True;
ComboBox1.Enabled := False;
self.OnShow(Sender);
Except
Application.MessageBox('系统出错。','提示',0+64);
Close;
end;
end;
procedure TForm7.EditClear;
begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
Edit6.Clear;
Edit7.Clear;
Edit8.Clear;
Edit9.Clear;
Edit10.Clear;
Edit11.Clear;
Edit12.Clear;
end;
procedure TForm7.Edit7KeyPress(Sender: TObject; var Key: Char);
var
m: Boolean;
begin
m := (key <#8)or(Key>#8)and(key < #46)or(key>#46)and(key <#48)or(key > #57);
if m then
key := #0;
end;
procedure TForm7.FormShow(Sender: TObject);
begin
ComboBox1.Clear;
with Data.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select distinct 供应商全称 from 供应商基础信息表');
Open
end;
while not Data.ADOQuery1.Eof do
begin
ComboBox1.Items.Add(Data.ADOQuery1.FieldByName('供应商全称').Value);
Data.ADOQuery1.Next;
end;
with Data.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 商品基础信息表');
Open;
end;
If Data.ADOQuery2.FieldByName('商品编号').Value = null then
begin
Application.MessageBox('该表数据为空,请向该表中插入数据。','提示',0+64);
BitBtn1.Enabled := False;
BitBtn2.Enabled := False;
BitBtn5.Enabled := False;
BitBtn6.Enabled := False;
BitBtn7.Enabled := False;
end
else
EditValue;
DisableEdit;
end;
procedure TForm7.EditValue;
begin
if Data.ADOQuery2.FieldByName('商品编号').Value <> null then
begin
Edit1.Text := Data.ADOQuery2.FieldByName('商品编号').Value;
Edit2.Text := Data.ADOQuery2.FieldByName('商品名称').Value;
Edit3.Text := Data.ADOQuery2.FieldByName('简称').Value;
Edit4.Text := Data.ADOQuery2.FieldByName('规格').Value;
Edit5.Text := Data.ADOQuery2.FieldByName('产地').Value;
Edit6.Text := Data.ADOQuery2.FieldByName('单位').Value;
Edit11.Text:= IntToStr(Data.ADOQuery2.FieldByName('保质期').Value);
Edit7.Text := FloatToStr(Data.ADOQuery2.FieldByName('进价').Value);
Edit8.Text := FloatToStr(Data.ADOQuery2.FieldByName('批发价').Value);
Edit9.Text := FloatToStr(Data.ADOQuery2.FieldByName('零售价').Value);
Edit12.Text := Data.ADOQuery2.FieldByName('供应商编号').Value;
ComboBox1.Text := Data.ADOQuery2.FieldByName('供应商全称').Value;
Edit10.Text := Data.ADOQuery2.FieldByName('备注').Value;
end
else
begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
Edit7.Clear;
Edit8.Clear;
Edit9.Clear;
Edit10.Clear;
Edit11.Clear;
Edit12.Clear;
ComboBox1.Text := '';
end;
end;
procedure TForm7.Edit11KeyPress(Sender: TObject; var Key: Char);
var
m: Boolean;
begin
m := (key <#8)or(Key>#8)and(key <#48)or(key>#57);
if m then
key := #0;
end;
procedure TForm7.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = vk_return then
FindNext
else if key = vk_Up then
FindPrior;
end;
procedure TForm7.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = vk_return then
begin
if Trim(ComboBox1.Text)<>'' then
begin
with Data.ADOQuery4 do
begin
Close;
SQL.Clear;
SQL.Add('select * From 供应商基础信息表 where 供应商全称 = :a');
Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
Open;
end;
if Data.ADOQuery4.RecordCount >1 then
begin
Application.CreateForm(TForm36,Form36);
Form36.DataSource1.DataSet := Data.ADOQuery4;
Form36.ShowModal;
Form36.Free;
end
else if Data.ADOQuery4.RecordCount =1 then
begin
Edit12.Text := Trim(Data.ADOQuery4.FieldByName('供应商编号').Value);
Edit10.SetFocus;
end
else
begin
Application.MessageBox('对不起,您输入的供应商不存在,请重新输入。','提示',64);
ComboBox1.Text := '';
ComboBox1.SetFocus;
end;
end;
Edit1.OnChange(Sender);
end;
end;
procedure TForm7.ComboBox1Change(Sender: TObject);
begin
Edit12.Clear;
end;
procedure TForm7.DisableEdit;
begin
Edit7.Enabled := False;
Edit8.Enabled := False;
Edit9.Enabled := False;
end;
function TForm7.IsNullEdit: Boolean;
var
Count: Integer;
begin
IsNullEdit := False;
For Count := 0 to Panel3.ControlCount-1 do
if Panel3.Controls[Count]is TEdit then
if Trim(TEdit(Panel3.Controls[Count]).Text)='' then
begin
IsNullEdit := True;
Break;
end;
end;
procedure TForm7.FindNext;
begin
if (FindNextControl(ActiveControl,True,False,False)is TEdit) then
begin
if (TEdit(FindNextControl(ActiveControl,True,False,False)).Enabled = True) then
TEdit(FindNextControl(ActiveControl,True,False,False)).SetFocus
else
begin
ActiveControl := FindNextControl(ActiveControl,True,False,False);
FindNext;
end;
end
else if FindNextControl(ActiveControl,True,False,False)is TComboBox then
begin
if (TComboBox(FindNextControl(ActiveControl,True,False,False)).Enabled = True) then
TComboBox(FindNextControl(ActiveControl,True,False,False)).SetFocus
else
begin
ActiveControl := FindNextControl(ActiveControl,True,False,False);
FindNext;
end;
end;
end;
procedure TForm7.FindPrior;
begin
if (FindNextControl(ActiveControl,False,False,False)is TEdit) then
begin
if (TEdit(FindNextControl(ActiveControl,False,False,False)).Enabled = True) then
TEdit(FindNextControl(ActiveControl,False,False,False)).SetFocus
else
begin
ActiveControl := FindNextControl(ActiveControl,False,False,False);
FindPrior;
end;
end
else if FindNextControl(ActiveControl,False,False,False)is TComboBox then
begin
if (TComboBox(FindNextControl(ActiveControl,False,False,False)).Enabled = True) then
TComboBox(FindNextControl(ActiveControl,False,False,False)).SetFocus
else
begin
ActiveControl := FindNextControl(ActiveControl,False,False,False);
FindPrior;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -