📄 xsthxt.~pas
字号:
procedure TForm27.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 TForm27.Edit8KeyPress(Sender: TObject; var Key: Char);
var
a: Boolean;
begin
a := (Key <#8)or(Key >#8)and(Key<#46)or(Key>#46)and(Key<#48)or(Key>#57);
if a then
Key := #0;
end;
procedure TForm27.BitBtn3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clRed;
end;
procedure TForm27.BitBtn3MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clBlue;
end;
procedure TForm27.Edit8KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = VK_return then
begin
if Edit8.Text = '' then
begin
Application.MessageBox('折扣不能为空。','提示',0+64);
Edit8.SetFocus;
Edit8.Clear;
Exit;
end;
if (StrToFloat(Edit8.Text)>1)or(StrToFloat(Edit8.Text)<0)then
begin
Application.MessageBox('折扣不能大于1或小于0。','提示',0+64);
Edit8.Clear;
Edit8.SetFocus;
Exit;
end;
try
StrToFloat(Edit8.Text);
except
Application.MessageBox('请输入合法字符。','提示',0+64);
Edit8.Clear;
Edit8.SetFocus;
Exit;
end;
if (Trim(Edit8.Text)<>'')and(Trim(StringGrid1.Cells[2,StringGrid1.Rowcount-1])='')then
StringGrid1.Cells[4,StringGrid1.RowCount-1]:= Edit8.Text;
StringGrid1.SetFocus;
end;
end;
procedure TForm27.Edit4KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Trim(Edit4.Text)<>'') and(Key = VK_ReTurn)then
Edit1.SetFocus;
end;
Select * from 商家信息表 where 商家名称 = '明日科技'or 商家名称 = '科海实业'
Union all
procedure TForm27.Edit1KeyDown(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(Label3.Caption)='')or(Trim(Label9.Caption)='') then
begin
Application.MessageBox('请添加销售票号和销售时间。','提示',64);
BitBtn3.SetFocus;
Exit;
end;
if Trim(Edit1.Text)<>'' then
begin
with Data.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 客户基础信息表 where 客户全称 = :a');
Parameters.ParamByName('a').Value := Trim(Edit1.Text);
Open;
end;
if Data.ADOQuery2.RecordCount>1 then
begin
Application.CreateForm(TForm73,Form73);
Form73.DataSource1.DataSet := Data.ADOQuery2;
Form73.ShowModal;
Edit1.ReadOnly:= True;
end
else if Data.ADOQuery2.RecordCount= 1 then
begin
StringGrid1.Cells[5,StringGrid1.RowCount-1]:= Data.ADOQuery2.FieldByName('客户编号').AsString;
StringGrid1.Cells[6,StringGrid1.RowCount-1]:= Data.ADOQuery2.FieldByName('客户全称').AsString;
Edit1.ReadOnly:= True;
end
else
begin
Application.MessageBox('对不起,该客户不存在。','提示',64);
Edit1.Clear;
Edit1.SetFocus;
Exit;
end;
StringGrid1.SetFocus;
StringGrid1.Col := 1;
StringGrid1.Cells[4,StringGrid1.RowCount-1]:= '1.0';
StringGrid1.Cells[7,StringGrid1.RowCount-1]:= Label3.Caption;
StringGrid1.Cells[8,StringGrid1.RowCount-1]:= Label9.Caption;
end;
end;
end;
function TForm27.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 TForm27.ListBox1DblClick(Sender: TObject);
begin
Edit1.Text:= ListBox1.Items[ListBox1.ItemIndex];
Edit1.SetFocus;
ListBox1.Visible := False;
end;
procedure TForm27.ListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = Vk_ReTurn then
ListBox1.OnDblClick(Sender);
end;
procedure TForm27.DBGrid1DblClick(Sender: TObject);
begin
StringGrid1.Cells[0,x]:= Data.ADOQuery1.FieldByName('商品编号').Value;
StringGrid1.Cells[1,x]:= Data.ADOQuery1.FieldByName('商品名称').Value;
DataSource1.DataSet := nil;
DBGrid1.Visible := False;
StringGrid1.SetFocus;
StringGrid1.Col := 2;
end;
procedure TForm27.DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = VK_ReTurn then
DBGrid1.OnDblClick(Sender);
end;
function TForm27.IsNull: BooLean;
var
b: integer;
begin
isNull := False;
For b := 0 to StringGrid1.ColCount-1 do
begin
if StringGrid1.Cells[b,x]='' then
begin
Isnull := True;
break;
end;
end;
end;
function TForm27.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;
procedure TForm27.ClearString;
var
i: Integer;
begin
For i := 0 to 3 do
StringGrid1.Cells[i,x]:= '';
end;
procedure TForm27.ClearStringEnd;
var
mm: Integer;
begin
For mm:= 0 to 3 do
StringGrid1.Cells[mm,StringGrid1.RowCount-1]:= '';
end;
procedure TForm27.SelectSPxx;
begin
with Data.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 商品基础信息表 where 商品名称 = :b ');
Parameters.ParamByName('b').Value := Trim(StringGrid1.Cells[1,x]);
Open;
end;
end;
procedure TForm27.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])<>'')and(s2 = False) then
begin
with Data.ADOQuery4 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 商品基础信息表 where 商品编号 =:a');
Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[0,x]);
Open;
end;
Jg:= Data.ADOQuery4.FieldByName('批发价').Value;
StringGrid1.Cells[3,x]:= FloatToStr(StrToInt(StringGrid1.Cells[2,x])* Jg*(StrToFloat(StringGrid1.Cells[4,x])));
if jcxmlb = True then
begin
Label19.Caption := FloatToStr(SumPrice);
Label18.Caption := IntToStr(SumSL);
Label17.Caption := IntToStr(Kinds);
end;
Exit;
end
else
begin
StringGrid1.Cells[3,x]:='';
Exit;
end;
if (ss = False)and(s1 = False)and(AfterIsNull = False) then
begin
if ACol = 1 then
begin
with Data.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 Data.ADOQuery1.RecordCount>0 then
begin
DataSource1.DataSet := Data.ADOQuery1;
DBGrid1.Visible := True;
end
else
begin
DataSource1.DataSet := nil;
DBGrid1.Visible := False;
S1 := True;
Application.MessageBox('库中没有此商品。','提示',64 );
For a1 := 0 to 3 do
StringGrid1.Cells[a1,x]:= '';
StringGrid1.SetFocus;
StringGrid1.Col := 1;
end;
end;
end ;
end;
function TForm27.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 TForm27.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 TForm27.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 TForm27.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_ReTurn)and (Trim(Edit2.Text)<>'') then
BitBtn4.SetFocus;
end;
procedure TForm27.Edit2Exit(Sender: TObject);
begin
if Edit2.Text = '' then
begin
Application.MessageBox('实付金额不能为空。','提示',0+64);
Edit2.SetFocus;
Exit;
end;
if StrToFloat(Edit2.Text)<0then
begin
Application.MessageBox('实付金额不能小于0。','提示',0+64);
Edit2.Clear;
Edit2.SetFocus;
end;
try
StrToFloat(Edit2.Text);
except
Application.MessageBox('请输入合法字符。','提示',0+64);
Edit2.Clear;
Edit2.SetFocus;
end;
end;
function TForm27.GroupSL(SPbh: String): Integer;
var
i: Integer;
begin
ReSult := 0;
For i := 1 to StringGrid1.RowCount -1 do
begin
if Trim(Spbh)= Trim(StringGrid1.Cells[0,i]) then
Result := ReSult + StrToInt(StringGrid1.Cells[2,i]);
end;
end;
procedure TForm27.ComboBox2KeyPress(Sender: TObject; var Key: Char);
begin
Key := #0;
end;
function TForm27.AfterIsNull: Boolean;
var
m: Integer;
begin
Result := False;
For m := 4 to StringGrid1.ColCount-1 do
if Trim(StringGrid1.Cells[m,x])=''then
begin
Result := True;
Break;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -