📄 pssqgl.~pas
字号:
Key := #0;
end;
procedure TForm29.BitBtn3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clRed;
end;
procedure TForm29.BitBtn3MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clBlue;
end;
procedure TForm29.Edit8Exit(Sender: TObject);
begin
if Edit8.Text = '' then
begin
Application.MessageBox('折扣不能为空。','提示',0+64);
Edit8.SetFocus;
end;
if (StrToFloat(Edit8.Text)>1)or(StrToFloat(Edit8.Text)<0)then
begin
Application.MessageBox('折扣不能大于1或小于0。','提示',0+64);
Edit8.Clear;
Edit8.SetFocus;
end;
try
StrToFloat(Edit8.Text);
except
Application.MessageBox('请输入合法字符。','提示',0+64);
Edit8.Clear;
Edit8.SetFocus;
end;
end;
procedure TForm29.Edit8KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
CloseForm(Key);
if key = VK_return then
if (Trim(Edit8.Text)<>'')and(Trim(StringGrid1.Cells[2,x])='') then
begin
StringGrid1.Cells[4,StringGrid1.RowCount-1]:= Edit8.Text;
StringGrid1.Col := 2;
StringGrid1.SetFocus;
end;
end;
procedure TForm29.StringGrid1SetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
var
Jg: Real;
a1: Integer;
begin
Jg := 0.0;
if (Trim(StringGrid1.Cells[0,x])<>'')and(Trim(StringGrid1.Cells[1,x])<>'')then
if Trim(StringGrid1.Cells[2,x])<>'' then
begin
with DataModule1.ADOQuery4 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 商品基础信息表 where 商品编号 =:a');
Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[0,x]);
Open;
end;
Jg:= DataModule1.ADOQuery4.FieldByName('批发价').Value;
StringGrid1.Cells[3,x]:= FloatToStr(StrToInt(StringGrid1.Cells[2,x])* Jg*(StrToFloat(StringGrid1.Cells[4,x])));
if jcxmlb = True then
begin
Label18.Caption := FloatToStr(SumPrice);
Label17.Caption := IntToStr(SumSL);
Label16.Caption := IntToStr(Kinds);
end;
Exit;
end
else
begin
StringGrid1.Cells[3,x]:='';
Exit;
end;
if (ss = False)and(s1 = False) then
begin
if (ACol = 1)and(AfterIsNull = False) then
begin
with DataModule1.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 商品基础信息表 where 商品名称 like :b ');
Parameters.ParamByName('b').Value := Trim(StringGrid1.Cells[1,x])+'%';
Open;
end;
if DataModule1.ADOQuery1.RecordCount>0 then
begin
DataSource1.DataSet := DataModule1.ADOQuery1;
DBGrid1.Visible := True;
end
else
begin
DataSource1.DataSet := nil;
DBGrid1.Visible := False;
S1 := True;
Application.MessageBox('该商品不存在。','提示',64 ) ;
ClearString;
end;
end;
end ;
end;
procedure TForm29.DBGrid1DblClick(Sender: TObject);
begin
StringGrid1.Cells[0,x]:= DataModule1.ADOQuery1.FieldByName('商品编号').Value;
StringGrid1.Cells[1,x]:= DataModule1.ADOQuery1.FieldByName('商品名称').Value;
DataSource1.DataSet := nil;
DBGrid1.Visible := False;
StringGrid1.SetFocus;
StringGrid1.Col := 2;
end;
procedure TForm29.DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = VK_ReTurn then
DBGrid1.OnDblClick(Sender);
CloseForm(Key);
end;
procedure TForm29.SelectSPXX;
begin
with DataModule1.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 商品基础信息表 where (商品名称 = :b and 供应商编号 = :a)');
Parameters.ParamByName('b').Value := Trim(StringGrid1.Cells[1,x]);
Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[5,x]);
Open;
end;
end;
function TForm29.IsNull: Boolean;
var
a: Integer;
begin
IsNull := False;
For a:= 0 to StringGrid1.ColCount -1 do
begin
if Trim(Stringgrid1.Cells[a,x])='' then
begin
IsNull := True;
Break;
end;
end;
end;
procedure TForm29.ClearString;
var
i: Integer;
begin
For i := 0 to 3 do
StringGrid1.Cells[i,x]:= '';
end;
procedure TForm29.ClearStringEnd;
var
mm: Integer;
begin
For mm:= 0 to 3 do
StringGrid1.Cells[mm,StringGrid1.RowCount-1]:= '';
end;
function TForm29.SumPrice: Real;
var
nn: Integer;
sum: Real;
begin
sum := 0.0;
For nn := 1 to StringGrid1.RowCount-1 do
sum := Sum + StrToFloat(StringGrid1.Cells[3,nn]);
ReSult := Sum;
end;
function TForm29.EndIsNull: Boolean;
var
Cc: Integer;
begin
Result := False;
For Cc := 0 to StringGrid1.ColCount-1 do
if Trim(StringGrid1.Cells[Cc,StringGrid1.RowCount-1])='' then
begin
Result := True;
Break;
end;
end;
function TForm29.SumSL: Integer;
var
nn: Integer;
sum: Integer;
begin
sum := 0;
For nn := 1 to StringGrid1.RowCount-1 do
sum := Sum + StrToInt(StringGrid1.Cells[2,nn]);
ReSult := Sum;
end;
function TForm29.Kinds: Integer;
var
i,m,mm: Integer;
Iscf: Boolean; //判断当前记录是否与之前的记录重复
begin
mm:= 0;
Iscf := False;
Result := StringGrid1.RowCount-1;
For m := 1 to StringGrid1.RowCount-1 do
For i := m+1 to StringGrid1.RowCount-1 do
begin
Iscf := False;
if m >1 then
For mm := 1 to m-1 do
if Trim(StringGrid1.Cells[0,m])= Trim(StringGrid1.Cells[0,mm])then
begin
Iscf := True;
Break;
end;
if Iscf = True then
Continue;
if Trim(StringGrid1.Cells[0,m])=Trim(StringGrid1.Cells[0,i])then
ReSult := Result -1;
end;
end;
procedure TForm29.ComboBox2KeyPress(Sender: TObject; var Key: Char);
begin
Key := #0;
end;
procedure TForm29.Edit4KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if FirstIsNull = False then
Exit;
if Key = VK_Next then
begin
ListBox1.Visible:= True;
ListBox1.SetFocus;
ListBox1.ItemIndex := 0;
end;
if Key = Vk_ReTurn then
begin
ListBox1.Visible := False;
if (Trim(Label8.Caption)='')or(Trim(Label3.Caption)='') then
begin
Application.MessageBox('请添加配送票号和配送时间。','提示',0+64);
BitBtn3.SetFocus;
Exit;
end;
if Trim(Edit4.Text)<>'' then
begin
with DataModule1.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 客户基础信息表 where 客户全称 = :a');
Parameters.ParamByName('a').Value := Trim(Edit4.Text);
Open;
end;
if DataModule1.ADOQuery2.RecordCount>1 then
begin
Application.CreateForm(TForm50,Form50);
Form50.DataSource1.DataSet := DataModule1.ADOQuery2;
Form50.ShowModal;
Form50.Free;
end
else if DataModule1.ADOQuery2.RecordCount= 1 then
begin
StringGrid1.Cells[5,StringGrid1.RowCount-1]:= DataModule1.ADOQuery2.FieldByName('客户编号').AsString;
StringGrid1.Cells[6,StringGrid1.RowCount-1]:= DataModule1.ADOQuery2.FieldByName('客户全称').AsString;
end
else
begin
Application.MessageBox('对不起,该客户不存在。','提示',64);
Edit4.Clear;
Edit4.SetFocus;
Exit;
end;
StringGrid1.SetFocus;
StringGrid1.Col := 1;
StringGrid1.Cells[4,StringGrid1.RowCount-1]:= '1.0';
StringGrid1.Cells[7,StringGrid1.RowCount-1]:= Label8.Caption;
StringGrid1.Cells[8,StringGrid1.RowCount-1]:= Label3.Caption;
end;
end;
CloseForm(Key);
end;
procedure TForm29.ListBox1DblClick(Sender: TObject);
begin
Edit4.Text:= ListBox1.Items[ListBox1.ItemIndex];
Edit4.SetFocus;
ListBox1.Visible := False;
end;
procedure TForm29.ListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = Vk_ReTurn then
ListBox1.OnDblClick(Sender);
CloseForm(Key);
end;
function TForm29.CurrentIsCF: Boolean;
var
i: Integer;
begin
ReSult := False;
if x > 1 then
begin
For i := 1 to x-1 do
begin
if Trim(StringGrid1.Cells[0,x])= Trim(StringGrid1.Cells[0,i]) then
begin
ReSult := True;
Break;
Exit;
end;
end;
For i := x+1 to StringGrid1.RowCount-1 do
begin
if Trim(StringGrid1.Cells[0,x])= Trim(StringGrid1.Cells[0,i]) then
begin
ReSult := True;
Break;
Exit;
end;
end;
end
else if x = 1 then
begin
For i := 2 to StringGrid1.RowCount-1 do
if Trim(StringGrid1.Cells[0,x])= Trim(StringGrid1.Cells[0,i]) then
begin
ReSult := True;
Break;
Exit;
end;
end;
end;
function TForm29.FirstIsNull: Boolean;
var
Cc: Integer;
begin
Result := False;
For Cc := 0 to StringGrid1.ColCount-1 do
if Trim(StringGrid1.Cells[Cc,1])='' then
begin
Result := True;
Break;
end;
end;
procedure TForm29.CloseForm( Key: Word);
begin
if activeControl is TWinControl then
if Key = VK_ESCAPE then
Close;
end;
procedure TForm29.BitBtn3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
CloseForm(Key);
end;
function TForm29.AfterIsNull: Boolean;
var
a: Integer;
begin
Result := False;
For a := 4 to StringGrid1.ColCount -1 do
if Trim(StringGrid1.Cells[a,x])='' then
begin
Result := True;
Break;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -