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

📄 uday.pas

📁 商场销售信息系统只要用于小商场的销售管理
💻 PAS
字号:
unit Uday;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, bsSkinCtrls, StdCtrls, Mask, bsSkinBoxCtrls, ComCtrls,
  BusinessSkinForm;

type
  TfrmDay = class(TForm)
    bsBusinessSkinForm1: TbsBusinessSkinForm;
    bsSkinPanel1: TbsSkinPanel;
    bsSkinPanel2: TbsSkinPanel;
    bsSkinScrollBar1: TbsSkinScrollBar;
    bsSkinScrollBar2: TbsSkinScrollBar;
    bsSkinListView1: TbsSkinListView;
    bsSkinStdLabel1: TbsSkinStdLabel;
    bsSkinDateEdit1: TbsSkinDateEdit;
    bsSkinSpeedButton1: TbsSkinSpeedButton;
    bsSkinSpeedButton2: TbsSkinSpeedButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bsSkinSpeedButton2Click(Sender: TObject);
    procedure bsSkinSpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmDay: TfrmDay;

implementation
uses upublic,comobj,umain,DateUtils;
{$R *.dfm}

procedure TfrmDay.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
frmDay:=nil;
end;

procedure TfrmDay.bsSkinSpeedButton2Click(Sender: TObject);
begin
close;
end;

procedure TfrmDay.bsSkinSpeedButton1Click(Sender: TObject);
var
  MaxDay:word;
  y,m,d:word;
  oldDate,newDate:string;
  i:integer;
  splx:string;
  qnxsl,qnje,qnmlr:integer;
  bfb:double;
begin
bsSkinListView1.Items.Clear;
Maxday:=daysinmonth(strtodate(bsSkinDateEdit1.Text));
y:=yearof(strtodate(bsSkinDateEdit1.Text));
m:=monthof(strtodate(bsSkinDateEdit1.Text));
d:=dayof(strtodate(bsSkinDateEdit1.Text));
olddate:='#'+bsSkinDateEdit1.Text+'#';
strsql:='select spmc,sptm,sum(xssl) as xszl,sum(spje) as jezl,sum(mlr) as mlrzl from txiaoshou where rq = '+olddate +' group by sptm,spmc';
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['spmc'].value; //商品名称
      subitems.add(rs.fields.Item['sptm'].value);  //商品条码
      subitems.add(rs.fields.Item['xszl'].value); //销售数量
      subitems.add('0'); //2   累计销售量
      subitems.add('0'); //3   同比增长率
      subitems.add(rs.fields.Item['jezl'].value); //4 销售金额
      subitems.add('0'); //5 累计金额
      subitems.add('0'); //6  同比增长
      subitems.add(rs.fields.Item['mlrzl'].value); //7  毛利润
      subitems.add('0'); //8   累计毛利润
      subitems.add('0'); //9   同比增长
    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,sum(spje) as xsze,sum(mlr) as mlrzl from txiaoshou where rq between '+olddate+' and '+newdate+ ' and spmc='+yinhao+splx+yinhao;
    rs.open(strsql,conn,1,1);
    if not rs.eof then
    begin
      bsSkinListView1.Items[i].SubItems[2]:=rs.fields.Item['xszl'].value;
      bsSkinListView1.Items[i].SubItems[5]:=rs.fields.Item['xsze'].value;
      bsSkinListView1.Items[i].SubItems[8]:=rs.fields.Item['mlrzl'].value;
    end;
    rs.close;

    //去年同期销售量,金额.毛利润
    olddate:='#'+inttostr(y-1)+'-'+inttostr(m)+'-'+inttostr(d)+'#';

    strsql:='select xssl,spje,mlr from txiaoshou where rq = '+olddate+ ' and spmc='+yinhao+splx+yinhao;
    rs.open(strsql,conn,1,1);
    if not rs.eof then
    begin
      if rs.fields.Item['xssl'].value=null then
        qnxsl:=0
      else
        qnxsl:=(rs.fields.Item['xssl'].value);//去年同期销售量

      if rs.fields.Item['spje'].value=null then
        qnje:=0
      else
        qnje:=(rs.fields.Item['spje'].value);//去年同期售量金额

      if rs.fields.Item['mlr'].value=null then
        qnmlr:=0
      else
        qnmlr:=(rs.fields.Item['mlr'].value);//去年同期毛利润

    end
    else
    begin
      qnxsl:=0;
      qnmlr:=0;
      qnje:=0;
    end;
   //销售量同比增长
    if qnxsl<>0 then
      bfb:=((strtoint(bsSkinListView1.Items[i].SubItems[1])-qnxsl) / qnxsl) * 100
    else
      bfb:=strtoint(bsSkinListView1.Items[i].SubItems[1])*100;
    bsSkinListView1.Items[i].SubItems[3]:=FormatFloat('0.00',bfb);
    //销售金额同比增长
    if qnje<>0 then
      bfb:=((strtofloat(bsSkinListView1.Items[i].SubItems[4])-qnje) / qnje) * 100
    else
      bfb:=strtofloat(bsSkinListView1.Items[i].SubItems[4])*100;
    bsSkinListView1.Items[i].SubItems[6]:=FormatFloat('0.00',bfb);
    //毛利润同比增长
    if qnmlr<>0 then
      bfb:=((strtofloat(bsSkinListView1.Items[i].SubItems[7])-qnmlr) / qnmlr) * 100
    else
      bfb:=strtofloat(bsSkinListView1.Items[i].SubItems[7])*100;
    bsSkinListView1.Items[i].SubItems[9]:=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 + -