📄 ufenlei.pas
字号:
unit UFenLei;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BusinessSkinForm, StdCtrls, bsSkinCtrls, ComCtrls, Mask,
bsSkinBoxCtrls;
type
TfrmFenlei = class(TForm)
bsBusinessSkinForm1: TbsBusinessSkinForm;
bsSkinPanel1: TbsSkinPanel;
bsSkinPanel3: TbsSkinPanel;
bsSkinListView1: TbsSkinListView;
bsSkinScrollBar1: TbsSkinScrollBar;
bsSkinScrollBar2: TbsSkinScrollBar;
bsSkinStdLabel1: TbsSkinStdLabel;
bsSkinDateEdit1: TbsSkinDateEdit;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure bsSkinButton2Click(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmFenlei: TfrmFenlei;
implementation
uses upublic,comobj,umain,DateUtils;
{$R *.dfm}
procedure TfrmFenlei.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
frmFenlei:=nil;
end;
procedure TfrmFenlei.bsSkinButton2Click(Sender: TObject);
begin
close;
end;
procedure TfrmFenlei.bsSkinButton1Click(Sender: TObject);
var
MaxDay:word;
y,m:word;
oldDate,newDate:string;
i:integer;
splx:string;
tmpqn:integer;
bfb:double;
begin
bsSkinListView1.Items.Clear;
Maxday:=daysinmonth(strtodate(bsSkinDateEdit1.Text));
y:=yearof(strtodate(bsSkinDateEdit1.Text));
m:=monthof(strtodate(bsSkinDateEdit1.Text));
olddate:='#'+inttostr(y)+'-'+inttostr(m)+'-1#';
newdate:='#'+inttostr(y)+'-'+inttostr(m)+'-'+inttostr(maxday)+'#';
strsql:='select spclass,sum(xssl) as xszl from txiaoshou where rq between '+olddate+' and '+newdate+ 'group by spclass';
rs:=CreateOleObject('ADODB.Recordset');
bsSkinListView1.Items.BeginUpdate;
try
rs.open(strsql,conn,1,1);
while not rs.eof do
begin
with bsSkinListView1.Items.Add do
begin
caption:=rs.fields.Item['spclass'].value;
subitems.add(rs.fields.Item['xszl'].value);
subitems.add('0');
subitems.add('0');
subitems.add('0');
end;
application.ProcessMessages;
rs.movenext;
end;
finally
rs.close;
rs:=unassigned;
strSql:='';
end;
rs:=CreateOleObject('ADODB.Recordset');
try
for i:=0 to bsSkinListView1.Items.count-1 do
begin
splx:=bsSkinListView1.Items[i].caption;
//全年累计销售量
olddate:='#'+inttostr(y)+'-1-1#';
newdate:='#'+inttostr(y)+'-12-31#';
strsql:='select sum(xssl) as xszl from txiaoshou where rq between '+olddate+' and '+newdate+ ' and spclass='+yinhao+splx+yinhao;
rs.open(strsql,conn,1,1);
if not rs.eof then
bsSkinListView1.Items[i].SubItems[1]:=rs.fields.Item['xszl'].value;
rs.close;
//去年同期
olddate:='#'+inttostr(y-1)+'-'+inttostr(m)+'-1#';
newdate:='#'+inttostr(y-1)+'-'+inttostr(m)+'-'+inttostr(maxday)+'#';
strsql:='select sum(xssl) as xszl from txiaoshou where rq between '+olddate+' and '+newdate+ ' and spclass='+yinhao+splx+yinhao;
rs.open(strsql,conn,1,1);
if not rs.eof then
begin
if rs.fields.Item['xszl'].value=null then
tmpqn:=0
else
tmpqn:=(rs.fields.Item['xszl'].value);//去年同期销售量
end
else
tmpqn:=0;
if tmpqn<>0 then
bfb:=((strtoint(bsSkinListView1.Items[i].SubItems[0])-tmpqn) / tmpqn) * 100
else
bfb:=strtoint(bsSkinListView1.Items[i].SubItems[0])*100;
bsSkinListView1.Items[i].SubItems[2]:=inttostr(tmpqn);
bsSkinListView1.Items[i].SubItems[3]:=FormatFloat('0.00',bfb);
rs.close;
application.ProcessMessages;
end;
finally
if rs.state=1 then rs.close;
rs:=unassigned;
strSql:='';
bsSkinListView1.Items.EndUpdate;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -