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

📄 dspxs.pas

📁 用delphi编写的销售管理系统
💻 PAS
字号:
unit dspxs;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, RpDefine, RpBase, RpSystem, DB, Grids, DBGrids,
  Buttons, ExtCtrls, jpeg, ComCtrls;

type
  TForm63 = class(TForm)
    Panel1: TPanel;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    aa: TRvSystem;
    Panel3: TPanel;
    Panel2: TPanel;
    BitBtn8: TBitBtn;
    BitBtn1: TBitBtn;
    ComboBox1: TComboBox;
    Label8: TLabel;
    SpeedButton1: TSpeedButton;
    Label5: TLabel;
    Label2: TLabel;
    Shape3: TShape;
    Label6: TLabel;
    Label3: TLabel;
    Shape1: TShape;
    Panel4: TPanel;
    Label1: TLabel;
    Label9: TLabel;
    CheckBox2: TCheckBox;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    procedure FormShow(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure aaPrint(Sender: TObject);
    procedure BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form63: TForm63;

implementation
  uses DataModal,spxsgl;
{$R *.dfm}

procedure TForm63.FormShow(Sender: TObject);
begin
  ComboBox1.Clear;
    with Data.ADOQuery1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select Distinct 商品名称 from 销售表');
      Open;
    end;
    while Not Data.ADOQuery1.Eof do
    begin
      ComboBox1.Items.Add(Data.ADOQuery1.FieldByName('商品名称').Value);
      Data.ADOQuery1.Next;
    end;
  DataSource1.DataSet := Nil;
  Label5.Caption := '';
  Label6.Caption := '';
end;

procedure TForm63.SpeedButton1Click(Sender: TObject);
begin
  if Trim(ComboBox1.Text)<>'' then
  begin
    Label5.Caption := '';
    Label6.Caption := '';
    with Data.ADOQuery1 do
    begin
      Close;
      SQL.Clear;
      if CheckBox2.Checked = False then
        SQL.Add('select * from 销售表 where 商品名称 =:a')
      else
      begin
        SQL.Add('select * from 销售表 where 商品名称 =:a ');
        SQL.Add(' and 销售票号 in ( select 销售票号 from 销售票号表 where 销售时间 >=:b and 销售时间<=:c)');
        Parameters.ParamByName('b').Value := Trunc(DateTimePicker1.Date)-2;
        Parameters.ParamByName('c').Value := Trunc(DateTimePicker2.Date)-2+0.9998;
      end;
      Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
      Open;
    end;
    if Data.ADOQuery1.RecordCount>0 then
    begin
      DataSource1.DataSet := Data.ADOQuery1;
      with Data.ADOQuery2 do
      begin
        Close;
        SQL.Clear;
        if CheckBox2.Checked  = False then
          SQL.Add('select Sum(数量)as sl,sum(金额)as je from 销售表 where 商品名称 =:a')
        else
        begin
          SQL.Add('select Sum(数量)as sl,sum(金额)as je from 销售表 where 商品名称 =:a');
          SQL.Add(' and 销售票号 in (Select 销售票号 From 销售票号表 where 销售时间>=:b and 销售时间<=:c)');
          Parameters.ParamByName('b').Value := Trunc(DateTimePicker1.Date)-2;
          Parameters.ParamByName('c').Value := Trunc(DateTimePicker2.Date)-2+ 0.9998;
        end;
        Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
        Open;
      end;
      label5.Caption := IntToStr(Data.ADOQuery2.FieldByName('sl').Value);
      label6.Caption := FloatToStr(Data.ADOQuery2.FieldByName('je').Value);
    end;
  end;
end;

procedure TForm63.BitBtn1Click(Sender: TObject);
begin
  if Data.ADOQuery1.RecordCount>0 then
    aa.Execute;
end;

procedure TForm63.aaPrint(Sender: TObject);
begin
  with Sender as TBaseRePort do
  begin
    setfont('宋体',18);
    TBaseRePort(sender).Canvas.Font.Color := clRed;
    Bold := True;
    underline := True;
    ypos := 1.0;
    PrintCenter('单商品销售报表',pagewidth / 2);
    setFont('宋体',10);
    Ypos := 1.45;
    TBaseRePort(sender).Canvas.Font.Color := clBlue;
    PrintLeft('操作员:',0.9);
    printleft(czy,1.5);
    printleft('时间:',pageWidth-2.2);
    PrintLeft(FormatDateTime('yyyy-mm-dd',Now),pageWidth-1.7);
    ypos := 1.7;
    Cleartabs;
    setFont('宋体',12);
    TBaseRePort(sender).Canvas.Font.Color := clBlue;
    setpen(clblack,pssolid,1,pmcopy);
    settab(0.9,pjcenter,1.0,0,boxlineall,0);
    settab(na,pjcenter,1.0,0,boxlineall,0);
    settab(na,pjcenter,1.0,0,boxlineall,0);
    settab(na,pjcenter,1.0,0,boxlineall,0);
    settab(na,pjcenter,0.6,0,boxlineall,0);
    settab(na,pjcenter,0.6,0,boxlineall,0);
    settab(na,pjcenter,1.2,0,boxlineall,0);
    bold := True;
    tab(-2,na,-2,-2,10);
    Print('商品编号');
    tab(na,na,-2,-2,10);
    Print('商品名称');
    Tab(na,na,-2,-2,10);
    Print('客户编号');
    Tab(na,na,-2,-2,10);
    Print('客户全称');
    Tab(na,na,-2,-2,10);
    Print('数量');
    Tab(na,na,-2,-2,10);
    Print('金额');
    Tab(na,-2,-2,-2,10);
    Print('销售票号');
    Bold := False;
    ypos := 1.9;
    ClearTabs;
    setFont('宋体',10);
    TBaseRePort(sender).Canvas.Font.Color := clBlue;
    settab(0.9,pjcenter,1.0,2,boxlineall,0);
    settab(na,pjcenter,1.0,2,boxlineall,0);
    settab(na,pjcenter,1.0,2,boxlineall,0);
    settab(na,pjcenter,1.0,2,boxlineall,0);
    settab(na,pjcenter,0.6,2,boxlineall,0);
    settab(na,pjcenter,0.6,2,boxlineall,0);
    settab(na,pjcenter,1.2,2,boxlineall,0);
    Data.ADOQuery1.First;
    ypos := 1.85;
    while Not Data.ADOQuery1.Eof do
    begin
      Tab(-2,na,na,na,0);
      print(Data.ADOQuery1.Fields[0].Value);
      tab(na,na,na,na,0);
      print(Data.ADOQuery1.Fields[1].Value);
      tab(na,na,na,na,0);
      print(Data.ADOQuery1.Fields[2].Value);
      tab(na,na,na,na,0);
      print(Data.ADOQuery1.Fields[3].Value);
      tab(na,na,na,na,0);
      print(FloatToStr(Data.ADOQuery1.Fields[4].Value));
      tab(na,na,na,na,0);
      print(FloatToStr(Data.ADOQuery1.Fields[5].Value));
      tab(na,-2,na,na,0);
      print(Data.ADOQuery1.Fields[7].Value);
      Println('');
      Data.ADOQuery1.Next;
     end;
     setFont('宋体',5);
     Println('');
     setFont('宋体',10);
     TBaseRePort(Sender).Canvas.Font.Color := clBlue;
     PrintLeft('销售总数量:',0.9);
     PrintLeft(Trim(label5.Caption),1.7);
     PrintLeft('销售总金额:',2.6);
     PrintLeft(Trim(label6.Caption),3.4);
  end;
end;

procedure TForm63.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TBitBtn(Sender).Font.Color := clRed;
end;

procedure TForm63.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TBitBtn(Sender).Font.Color := clBlue;
end;

end.

⌨️ 快捷键说明

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