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

📄 xsglxt.pas

📁 用delphi编写的销售管理系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      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(TForm40,Form40);
        Form40.DataSource1.DataSet := Data.ADOQuery2;
        Form40.ShowModal;
        Form40.Free;
        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]:= Label16.Caption;
   end;
  end;

end;

function TForm24.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 TForm24.ListBox1DblClick(Sender: TObject);
begin
  Edit1.Text:= ListBox1.Items[ListBox1.ItemIndex];
  Edit1.SetFocus;
  ListBox1.Visible := False;

end;

procedure TForm24.ListBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = Vk_ReTurn then
    ListBox1.OnDblClick(Sender);
end;

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

end;

function TForm24.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 TForm24.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 TForm24.ClearString;
var
  i: Integer;
begin
  For i := 0 to 3 do
    StringGrid1.Cells[i,x]:= '';
end;

procedure TForm24.ClearStringEnd;
var
  mm: Integer;
begin
  For mm:= 0 to 3 do
    StringGrid1.Cells[mm,StringGrid1.RowCount-1]:= '';
end;

procedure TForm24.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 TForm24.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 TForm24.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 TForm24.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 TForm24.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 TForm24.ComboBox3KeyPress(Sender: TObject; var Key: Char);
begin
  Key := #0;
end;

procedure TForm24.ClearForDd;
var
  a,b: Integer;
begin
  Edit1.Clear;
  Label17.Caption := '';
  Label18.Caption := '';
  Label19.Caption := '';
  For a := 1 to StringGrid1.RowCount- 1 do
    For b := 0 to StringGrid1.ColCount-1 do
      StringGrid1.Cells[b,a]:= '';
      StringGrid1.RowCount := 2;
end;

procedure TForm24.Edit2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (Key = VK_ReTurn)and (Trim(Edit2.Text)<>'') then
    BitBtn4.SetFocus;
end;

procedure TForm24.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 TForm24.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 TForm24.ComboBox2KeyPress(Sender: TObject; var Key: Char);
begin
  Key := #0;
end;

function TForm24.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 + -