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

📄 queryspsellunit.pas

📁 一个用delphi 开发的商场销售系统 涵盖很多功能
💻 PAS
字号:
unit QueryspSellUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, QueryBassUnit, DB, DBTables, StdCtrls, ComCtrls, Buttons, Grids,
  DBGrids, ExtCtrls;

type
  TQueryspSellForm = class(TQueryBassForm)
    procedure FormCreate(Sender: TObject);
    procedure SB_queryClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SB_printClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  QueryspSellForm: TQueryspSellForm;

implementation

uses FunctionUnit, MainUnit, PrintspxsUnit, PrintBassUnit;

{$R *.dfm}

procedure TQueryspSellForm.FormCreate(Sender: TObject);
var
  B_find: Boolean;
  I_temp: integer;
begin
  inherited;
  self.Caption := '商品销售统计';
  with query_data do
  begin
    close;
    sql.Clear;
    sql.text := 'select * from goods order by name';
    open;
    CB_goods.Style := csDropDownList;
    CB_goods.Items.add('所有');
    cb_goods.ItemIndex := 0;
    while not eof do
    begin
      B_find := false;
      for I_temp := 0 to CB_goods.items.Count - 1 do
      begin
        if CB_goods.Items[I_temp] = fieldbyname('name').asstring then
          B_find := true; //找到相同名称
      end;
      if not B_find then //没有找到时增加
        CB_goods.Items.add(fieldbyname('name').asstring);
      next;
    end;
    close;
  end;
end;

procedure TQueryspSellForm.SB_queryClick(Sender: TObject);
begin
  inherited;
  if not Checkrights(USERRIGHTS, '查看') then
  begin
    messagedlg(Errormsg0006 + '0007', mterror, [mbok], 0);
    exit;
  end;
  with query_data do
  begin
    close;
    sql.Clear;
    if (cb_goods.Text = '') or (cb_goods.Text = '所有') then
      sql.Text := '   SELECT YWYData.Name, (Depot.NAME) Depotname, (Goods.NAME) goodsname,'
        + ' goods.TYPE,goods.UNIT, Sellrecord.NUMBER,(Sellrecord.price) selldj,'
        + ' (Sellrecord.NUMBER*Sellrecord.PRICE) PRICE,Sellrecord.MYDATE, Sellrecord.MEMO'
        + ' FROM Sellrecord INNER JOIN YWYData'
        + ' ON  (Sellrecord.PEOPLEID = YWYData.Id) INNER JOIN Depot'
        + ' ON  (Sellrecord.DEPOTID = Depot.ID) INNER JOIN goods'
        + ' ON  (Sellrecord.GOODSID = goods.ID)'
        + ' WHERE (Sellrecord.mydate>="' + formatdatetime('yyyy-mm-dd', DTP_begin.DateTime) + '")'
        + ' AND (Sellrecord.mydate<="' + formatdatetime('yyyy-mm-dd', dtp_end.DateTime) + '")'
        + ' UNION ALL'
        + '   SELECT YWYData.Name, (Depot.NAME) Depotname, (goods.NAME) goodsname,'
        + ' goods.TYPE,goods.UNIT,(0- XSTHrecord.NUMBER) NUMBER,(XSTHrecord.price) selldj,'
        + ' ((0-XSTHrecord.NUMBER)*XSTHrecord.PRICE) PRICE,XSTHrecord.MYDATE, XSTHrecord.MEMO'
        + ' FROM XSTHrecord INNER JOIN YWYData'
        + ' ON  (XSTHrecord.PEOPLEID = YWYData.Id) INNER JOIN Depot'
        + ' ON  (XSTHrecord.DEPOTID = Depot.ID) INNER JOIN goods'
        + ' ON  (XSTHrecord.GOODSID = goods.ID)'
        + ' WHERE (XSTHrecord.mydate>="' + formatdatetime('yyyy-mm-dd', DTP_begin.DateTime) + '")'
        + ' AND (XSTHrecord.mydate<="' + formatdatetime('yyyy-mm-dd', dtp_end.DateTime) + '")'
        + '  ORDER BY goods.NAME,MYDATE'
    else
      sql.Text := ' SELECT YWYData.Name, (Depot.NAME) Depotname, (goods.NAME) goodsname,'
        + ' goods.TYPE,goods.UNIT, Sellrecord.NUMBER,(Sellrecord.price) selldj,'
        + ' (Sellrecord.NUMBER*Sellrecord.PRICE) PRICE,Sellrecord.MYDATE, Sellrecord.MEMO'
        + ' FROM Sellrecord INNER JOIN YWYData'
        + ' ON  (Sellrecord.PEOPLEID = YWYData.Id) INNER JOIN Depot'
        + ' ON  (Sellrecord.DEPOTID = Depot.ID) INNER JOIN goods'
        + ' ON  (Sellrecord.GOODSID = goods.ID)'
        + ' WHERE (Sellrecord.mydate>="' + formatdatetime('yyyy-mm-dd', DTP_begin.DateTime) + '")'
        + ' AND (Sellrecord.mydate<="' + formatdatetime('yyyy-mm-dd', dtp_end.DateTime) + '")'
        + ' and (goods.name="' + cb_goods.Text + '")'
        + ' UNION ALL'
        + '  SELECT YWYData.Name, (Depot.NAME) Depotname, (goods.NAME) goodsname,'
        + ' goods.TYPE,goods.UNIT,(0- XSTHrecord.NUMBER) NUMBER,(XSTHrecord.price) selldj,'
        + ' ((0 - XSTHrecord.NUMBER)*XSTHrecord.PRICE) PRICE,XSTHrecord.MYDATE, XSTHrecord.MEMO'
        + ' FROM XSTHrecord INNER JOIN YWYData'
        + ' ON  (XSTHrecord.PEOPLEID = YWYData.Id) INNER JOIN Depot'
        + ' ON  (XSTHrecord.DEPOTID = Depot.ID) INNER JOIN goods'
        + ' ON  (XSTHrecord.GOODSID = goods.ID)'
        + ' WHERE (XSTHrecord.mydate>="' + formatdatetime('yyyy-mm-dd', DTP_begin.DateTime) + '")'
        + ' AND (XSTHrecord.mydate<="' + formatdatetime('yyyy-mm-dd', dtp_end.DateTime) + '")'
        + ' and (goods.name="' + cb_goods.Text + '")'
        + '  ORDER BY goods.NAME,MYDATE';
    try
      open;
    except
      messagedlg(Errormsg0001 + '0008+0018+0023', mtError, [mbok], 0);
      close;
    end;
  end;

end;

procedure TQueryspSellForm.FormShow(Sender: TObject);
begin
  inherited;
  SB_query.Click;
end;

procedure TQueryspSellForm.SB_printClick(Sender: TObject);
begin
  inherited;
  try
    Application.CreateForm(TPrintspxsForm, PrintspxsForm);
    Application.CreateForm(TPrintBassForm, PrintBassForm);
  except
    messagedlg(Errormsg0011, mtError, [mbok], 0);
    exit;
  end;
  PrintspxsForm.QuickRep_spxsmx.preview;
  PrintspxsForm.Free;
  PrintBassForm.Free;
end;

end.

⌨️ 快捷键说明

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