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

📄 uprlack.~pas

📁 DELPHI编程入门篇.从基础入手,浅显易懂,一定物有所值.
💻 ~PAS
字号:
unit Uprlack;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, Grids, StdCtrls, ExtCtrls, DB, ADODB, RpCon, RpConDS,
  RpDefine, RpRave,RVProj,RVClass,RvCsRpt,RVCsStd, RpBase, RpSystem;

type
  Tfrmprlack = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    StringGrid1: TStringGrid;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    ADOQuery1: TADOQuery;
    ADOQuery2: TADOQuery;
    RvProject1: TRvProject;
    prlackConnection1: TRvDataSetConnection;
    procedure FormCreate(Sender: TObject);
    procedure ComboBox1Select(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmprlack: Tfrmprlack;
  sqlstr:string;

implementation

uses Udatamodule;

{$R *.dfm}

procedure Tfrmprlack.FormCreate(Sender: TObject);
begin
  stringgrid1.Cells[0,0]:='商品编号';
  stringgrid1.Cells[1,0]:='商品名称';
  stringgrid1.Cells[2,0]:='商品数量';
  stringgrid1.Cells[3,0]:='库存下限';
  stringgrid1.Cells[4,0]:='最优库存';
  stringgrid1.Cells[5,0]:='缺货数量';
  adoquery1.SQL.Text:='select filname from filiale';
  adoquery1.Open;
  while not adoquery1.Eof do
  begin
    combobox1.Items.Add(adoquery1.fieldbyname('filname').AsString);
    adoquery1.Next;
  end;
  adoquery1.Close;
  combobox1.ItemIndex:=-1;
end;

procedure Tfrmprlack.ComboBox1Select(Sender: TObject);
begin
  adoquery1.SQL.Text:='select filid from filiale where filname = '''+combobox1.Text+'''';
  adoquery1.Open;
  edit1.Text:=adoquery1.fieldbyname('filid').AsString;
  adoquery1.Close;
end;

procedure Tfrmprlack.SpeedButton1Click(Sender: TObject);
var
  i,arow:integer;
begin
  for i:=1 to stringgrid1.RowCount-1 do
    stringgrid1.Rows[i].Clear;
  stringgrid1.RowCount:=2;
  if edit1.Text = '' then
  begin
    showmessage('请选择分店');
    exit;
  end
  else begin
    adoquery1.SQL.Text:='select busary.prid,pluinfo.prname,busary.busanum,'
    +'busary.stocklow,busary.stockhigh from busary inner join pluinfo on '
    +'busary.prid = pluinfo.prid where busary.filid = '''+edit1.Text+''''
    +'and busary.busanum < busary.stocklow';
    adoquery1.Open;
    sqlstr:=adoquery1.SQL.Text;
    if adoquery1.RecordCount > 0 then
    begin
      arow:=1;
      while not adoquery1.eof do
      begin
        with stringgrid1 do
        begin
          Cells[0,arow]:=adoquery1.Fields[0].AsString;
          Cells[1,arow]:=adoquery1.Fields[1].AsString;
          Cells[2,arow]:=adoquery1.Fields[2].AsString;
          Cells[3,arow]:=adoquery1.Fields[3].AsString;
          Cells[4,arow]:=adoquery1.Fields[4].AsString;
          Cells[5,arow]:=currtostr(strtocurr(Cells[4,arow])-strtocurr(Cells[2,arow]))
        end;
        adoquery1.Next;
        inc(arow);
      end;
    end;
  end;
end;

procedure Tfrmprlack.FormShow(Sender: TObject);
begin
  edit1.SetFocus;
end;

procedure Tfrmprlack.SpeedButton3Click(Sender: TObject);
begin
  modalresult:=mrcancel;
end;

procedure Tfrmprlack.SpeedButton2Click(Sender: TObject);
var
  MyPage: TRavePage;
  MyText: TRaveText;
begin
  if stringgrid1.Cells[0,1] <> '' then
  begin
    rvproject1.Open;
    with rvproject1.ProjMan do
    begin
      mypage:=FindRaveComponent('report1.page1',nil) as travepage;
      mytext:=FindRaveComponent('Text3',MyPage) as travetext;
      MyText.Text := combobox1.Text;
    end;
    adoquery1.SQL.Text:=sqlstr;
    adoquery1.Open;
    rvproject1.Execute;
    rvproject1.Close;
    adoquery1.close;
  end
  else
    showmessage('清先查找要打印的数据');  
end;

end.

⌨️ 快捷键说明

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