📄 spxxgl.pas
字号:
FieldByName('简称').Value := Edit3.Text;
FieldByName('规格').Value := Edit4.Text ;
FieldByName('产地').Value := Edit5.Text ;
FieldByName('单位').Value := Edit6.Text ;
FieldByName('保质期').Value := StrToInt(Trim(Edit11.Text)) ;
FieldByName('进价').Value := StrToFloat(Edit7.Text);
FieldByName('批发价').Value := StrToFloat(Edit8.Text) ;
FieldByName('零售价').Value := StrToFloat(Edit9.Text) ;
FieldByName('供应商编号').Value := Edit12.Text ;
FieldByName('供应商全称').Value := Trim(ComboBox1.Text) ;
FieldByName('备注').Value := Edit10.Text ;
Post;
Application.MessageBox('修改成功。','提示',64);
end
else
begin
Application.MessageBox('数据项不能为空.','提示',64);
Exit;
end;
end
else
EditValue;
Except
Application.MessageBox('系统出错。','提示',0+64);
Close;
end;
end;
procedure TForm4.BitBtn6Click(Sender: TObject);
begin
BitBtn4.Enabled := False;
AddState := False;
Try
if Application.MessageBox('确实要删除该条记录吗?','提示',MB_YESNO )= ID_Yes then
begin
with Data.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('delete 商品基础信息表 where 商品编号 = :a');
Parameters.ParamByName('a').Value := Trim(Edit1.Text);
ExecSQL;
end;
Application.MessageBox('该条记录已经删除。','提示',0+64);
OnShow(Sender);
end;
Except
Application.MessageBox('系统出错。','提示',0+64);
Close;
end;
end;
procedure TForm4.BitBtn7Click(Sender: TObject);
begin
Self.OnShow(Sender);
BitBtn4.Enabled := False;
BitBtn6.Enabled := True;
BitBtn5.Enabled := True;
BitBtn2.Enabled := True;
ComboBox1.Enabled := False;
DisableEdit;
AddState := False;
end;
procedure TForm4.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 TForm4.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;
function TForm4.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 TForm4.Panel2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Screen.Cursor := -2;
BitBtn1.Font.Color := clBlue;
BitBtn2.Font.Color := clBlue;
BitBtn3.Font.Color := clBlue;
BitBtn4.Font.Color := clBlue;
BitBtn5.Font.Color := clBlue;
BitBtn6.Font.Color := clBlue;
BitBtn7.Font.Color := clBlue;
BitBtn8.Font.Color := clBlue;
end;
procedure TForm4.Edit1Change(Sender: TObject);
begin
if (Trim(Edit1.Text)<>'')and (Trim(Edit2.Text)<>'')and(Trim(Edit3.Text)<>'')and
(Trim(Edit4.Text)<>'') and(Trim(Edit5.Text)<>'')and(Trim(Edit6.Text)<>'')and
(Trim(Edit7.Text)<>'')and(Trim(Edit8.Text)<>'')and(Trim(Edit9.Text)<>'')and
(Trim(Edit10.Text)<>'')and(Trim(Edit12.Text)<>'')and(Trim(ComboBox1.Text)<>'')and(aa = True)then
BitBtn4.Enabled := True
else
BitBtn4.Enabled := False;
end;
procedure TForm4.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 TForm4.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = vk_return then
FindNext
else if key = vk_Up then
FindPrior;
end;
procedure TForm4.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 TForm4.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(TForm9,Form9);
Form9.DataSource1.DataSet := Data.ADOQuery4;
Form9.ShowModal;
Form9.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 TForm4.ComboBox1Change(Sender: TObject);
begin
Edit12.Clear;
end;
procedure TForm4.BitBtn4Click(Sender: TObject);
begin
AddState := false;
With Data.ADOQuery1 do
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;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -