⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 khdhxt.~pas

📁 delphi+SQL编写的销售系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
      begin
        Application.MessageBox('该商品不存在。','提示',64);
        ClearString;
        if StringGrid1.RowCount>2 then
          StringGrid1.RowCount := StringGrid1.RowCount-1;
      end;
    end;
    if (Key = VK_Shift)and(JCxmlb = True) then
      BitBtn4.SetFocus;
end;


procedure TForm22.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 TForm22.Clear;
var
  r,c: integer;
begin
  Edit2.ReadOnly := False;
  Label10.Caption := '';
  Label14.Caption := '';
  Edit2.Clear;
  Edit8.Text := '1.0';
  Label15.Caption := '0';
  Label16.Caption := '0';
  Label17.Caption := '0.0';
  Edit4.Clear;
  For r := 1 to StringGrid1.RowCount-1 do
    For c := 0 to StringGrid1.ColCount-1 do
      StringGrid1.Cells[c,r]:='';
  StringGrid1.RowCount  :=2;

end;


procedure TForm22.Edit8KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  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 TForm22.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
        Label17.Caption := FloatToStr(SumPrice);
        Label16.Caption := IntToStr(SumSL);
        Label15.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;

procedure TForm22.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 TForm22.DBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = VK_ReTurn then
    DBGrid1.OnDblClick(Sender);
end;

procedure TForm22.ClearString;
var
  i: Integer;
begin
  For i := 0 to 3 do
    StringGrid1.Cells[i,x]:= '';
end;


procedure TForm22.ClearStringEnd;
var
  mm: Integer;
begin
  For mm:= 0 to 3 do
    StringGrid1.Cells[mm,StringGrid1.RowCount-1]:= '';
end;
function TForm22.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 TForm22.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 TForm22.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 TForm22.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 TForm22.Edit2KeyDown(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(Label14.Caption)='')or(Trim(Label3.Caption)='') then
    begin
      Application.MessageBox('请添加订货票号和订货时间。','提示',64);
      BitBtn3.SetFocus;
      Exit;
    end;
    if Trim(Edit2.Text)<>'' then
    begin
      with Data.ADOQuery2 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select * from 客户基础信息表 where 客户全称 = :a');
        Parameters.ParamByName('a').Value := Trim(Edit2.Text);
        Open;
      end;
      if Data.ADOQuery2.RecordCount>1 then
      begin
        Application.CreateForm(TForm39,Form39);
        Form39.DataSource1.DataSet := Data.ADOQuery2;
        Form39.ShowModal;
        Form39.Free;
        Edit2.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;
        Edit2.ReadOnly:= True;
      end
      else
      begin
        Application.MessageBox('对不起,该客户不存在。','提示',64);
        Edit2.Clear;
        Edit2.SetFocus;
        Exit;
      end;
      StringGrid1.SetFocus;
      StringGrid1.Col := 1;
      StringGrid1.Cells[4,StringGrid1.RowCount-1]:= '1.0';
      StringGrid1.Cells[7,StringGrid1.RowCount-1]:= Label10.Caption;
      StringGrid1.Cells[8,StringGrid1.RowCount-1]:= Label14.Caption;
   end;
  end;
end;

procedure TForm22.ListBox1DblClick(Sender: TObject);
begin
  Edit2.Text:= ListBox1.Items[ListBox1.ItemIndex];
  Edit2.SetFocus;
  ListBox1.Visible := False;
end;
procedure TForm22.ListBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = Vk_ReTurn then
    ListBox1.OnDblClick(Sender);
end;

function TForm22.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;

function TForm22.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 TForm22.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 TForm22.Edit4KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_ReTurn then
    if Trim(Edit4.Text)<>'' then
      Edit2.SetFocus;
end;

function TForm22.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;

procedure TForm22.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;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -