📄 uplusale.~pas
字号:
unit Uplusale;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, ExtCtrls, Buttons, StdCtrls, DB, ADODB, Grids,
RpCon, RpConDS, RpDefine, RpRave;
type
Tfrmplusale = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
Label1: TLabel;
DatePicker1: TDateTimePicker;
DatePicker2: TDateTimePicker;
Label2: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
Label5: TLabel;
ComboBox2: TComboBox;
Label6: TLabel;
Edit1: TEdit;
StringGrid1: TStringGrid;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
RvProject1: TRvProject;
plusaleConnection1: TRvDataSetConnection;
procedure FormCreate(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmplusale: Tfrmplusale;
sqlstr:string;
implementation
uses Udatamodule;
{$R *.dfm}
procedure Tfrmplusale.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]:='销售金额';
stringgrid1.Cells[6,0]:='上传日期';
datepicker1.Date:=date-7;
datepicker2.Date:=date;
adoquery1.SQL.Text:='select filname from filiale';
adoquery1.Open;
while not adoquery1.Eof do
begin
combobox1.Items.Add(adoquery1.Fields[0].asstring);
adoquery1.Next;
end;
adoquery1.Close;
adoquery1.SQL.Text:='select classname from classinfo';
adoquery1.Open;
while not adoquery1.Eof do
begin
combobox2.Items.Add(adoquery1.Fields[0].asstring);
adoquery1.Next;
end;
adoquery1.Close;
combobox1.ItemIndex:=0;
combobox2.ItemIndex:=0;
end;
procedure Tfrmplusale.SpeedButton3Click(Sender: TObject);
begin
modalresult:=mrcancel;
end;
procedure Tfrmplusale.SpeedButton1Click(Sender: TObject);
var
sfilid,sprkind:string;
i:integer;
begin
for i:=1 to stringgrid1.RowCount-1 do
stringgrid1.Rows[i].Clear;
stringgrid1.RowCount:=2;
adoquery1.SQL.Text:='select plusale.prid,pluinfo.prname,plusale.filid,'
+'plusale.salenum,plusale.costprice,plusale.saletotal,plusale.transdate'
+' from plusale inner join pluinfo on plusale.prid = pluinfo.prid where'
+' transdate between #'+datetostr(datepicker1.date)+'# and #'+datetostr(datepicker2.date)+'#';
if combobox1.Text <> '全部' then
begin
adoquery2.SQL.Text:='select filid from filiale where filname = '''+combobox1.Text+'''';
adoquery2.Open;
sfilid:= adoquery2.Fields[0].AsString;
adoquery2.Close;
adoquery1.SQL.Add('and plusale.filid = '''+sfilid+'''');
end;
if combobox2.Text <> '全部' then
begin
adoquery2.SQL.Text:='select classid from classinfo where classname = '''+combobox2.Text+'''';
adoquery2.Open;
sprkind:=adoquery2.Fields[0].AsString;
adoquery2.Close;
adoquery1.SQL.Add('and pluinfo.classid = '''+sprkind+'''');
end;
if edit1.Text <> '' then
adoquery1.SQL.add('and pluinfo.prname = '''+edit1.Text+'''');
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
sqlstr:=adoquery1.SQL.Text;
stringgrid1.RowCount:=adoquery1.RecordCount+1;
for i:=1 to stringgrid1.RowCount-1 do
begin
stringgrid1.Cells[0,i]:=adoquery1.FieldValues['prid'];
stringgrid1.Cells[1,i]:=adoquery1.FieldValues['prname'];
stringgrid1.Cells[2,i]:=adoquery1.FieldValues['filid'];
stringgrid1.Cells[3,i]:=adoquery1.FieldValues['salenum'];
stringgrid1.Cells[4,i]:=adoquery1.FieldValues['costprice'];
stringgrid1.Cells[5,i]:=adoquery1.FieldValues['saletotal'];
stringgrid1.Cells[6,i]:=adoquery1.FieldValues['transdate'];
adoquery1.Next;
end;
end;
adoquery1.Close;
end;
procedure Tfrmplusale.SpeedButton2Click(Sender: TObject);
begin
if stringgrid1.Cells[0,1] <> '' then
begin
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 + -