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

📄 main_query_ywyxstj.pas

📁 pos商场、超市管理系统
💻 PAS
字号:
unit MAIN_QUERY_YWYXSTJ;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, MAIN_QUERY, DB, DBTables, ComCtrls, StdCtrls, TFlatComboBoxUnit,
  TFlatSpeedButtonUnit, Grids, DBGrids, DsFancyButton, ExtCtrls,MYSELF,Frmmain;

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

var
  Frm_main_query_ywyxstj: TFrm_main_query_ywyxstj;

implementation

uses PRINT_TEMP, PRINT_YWYXSTJ, CHART_YWYXS;

{$R *.dfm}

procedure TFrm_main_query_ywyxstj.FormCreate(Sender: TObject);
begin
  inherited;
   self.Caption :='业务员销售统计';
   with query_temp do
   begin
      close;
      sql.Clear ;
      sql.Text :='select name from people where usertype="在职"';
      open;
      cb_ywy.Items.Clear ;
      cb_ywy.Style :=csDropDownList;
      CB_ywy.Items.Add('所有'); 
      while not eof do
      begin
         CB_ywy.Items.add(fieldbyname('name').asstring);
         next;
      end;
      close;
   end;
end;

procedure TFrm_main_query_ywyxstj.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_ywy.Text ='') or (CB_ywy.Text ='所有') then
         sql.Text :='SELECT People.Name PEOPLENAME,Goodsmessage.NAME GOODSNAME,Goodsmessage.TYPE, '
               +' SUM( Sellrecord.NUMBER ) NUMBER,'
               +' SUM( Sellrecord.NUMBER * Sellrecord.PRICE  ) PRICE'
               +' FROM Sellrecord '
               +' INNER JOIN People '
               +' ON  (Sellrecord.PEOPLEID = People.Id)'
               +' INNER JOIN Goodsmessage'
               +' ON  (Sellrecord.GOODSID = Goodsmessage.ID)'
               +' WHERE (Sellrecord.mydate>="'+formatdatetime('yyyy-mm-dd',DTP_begin.DateTime)+'")'
               +' AND (Sellrecord.mydate<="'+formatdatetime('yyyy-mm-dd',dtp_end.DateTime)+'")'
               +' GROUP BY People.Name, Goodsmessage.TYPE, Goodsmessage.NAME'
               +' UNION ALL'
               +' SELECT People.Name PEOPLENAME,Goodsmessage.NAME GOODSNAME,Goodsmessage.TYPE, '
               +' SUM( 0 - Xsthrecord.NUMBER ) NUMBER,'
               +' SUM( (0 - Xsthrecord.NUMBER) * Xsthrecord.PRICE  ) PRICE'
               +' FROM Xsthrecord '
               +' INNER JOIN People '
               +' ON  (Xsthrecord.PEOPLEID = People.Id)'
               +' INNER JOIN Goodsmessage'
               +' ON  (Xsthrecord.GOODSID = Goodsmessage.ID)'
               +' WHERE (Xsthrecord.mydate>="'+formatdatetime('yyyy-mm-dd',DTP_begin.DateTime)+'")'
               +' AND (Xsthrecord.mydate<="'+formatdatetime('yyyy-mm-dd',dtp_end.DateTime)+'")'
               +' GROUP BY People.Name, Goodsmessage.TYPE, Goodsmessage.NAME'
               +' ORDER BY PEOPLE.NAME'
      else
         sql.Text :='SELECT People.Name PEOPLENAME,Goodsmessage.NAME GOODSNAME,Goodsmessage.TYPE, '
               +' SUM( Sellrecord.NUMBER ) NUMBER,'
               +' SUM( Sellrecord.NUMBER * Sellrecord.PRICE  ) PRICE'
               +' FROM Sellrecord '
               +' INNER JOIN People '
               +' ON  (Sellrecord.PEOPLEID = People.Id)'
               +' INNER JOIN Goodsmessage'
               +' ON  (Sellrecord.GOODSID = Goodsmessage.ID)'
               +' WHERE (People.name="'+cb_ywy.Text +'")'
               +' and (Sellrecord.mydate>="'+formatdatetime('yyyy-mm-dd',DTP_begin.DateTime)+'")'
               +' AND (Sellrecord.mydate<="'+formatdatetime('yyyy-mm-dd',dtp_end.DateTime)+'")'
               +' GROUP BY People.Name, Goodsmessage.TYPE, Goodsmessage.NAME'
               +' UNION ALL'
               +' SELECT People.Name PEOPLENAME,Goodsmessage.NAME GOODSNAME,Goodsmessage.TYPE, '
               +' SUM( 0 - Xsthrecord.NUMBER ) NUMBER,'
               +' SUM( (0 - Xsthrecord.NUMBER) * Xsthrecord.PRICE  ) PRICE'
               +' FROM Xsthrecord '
               +' INNER JOIN People '
               +' ON  (Xsthrecord.PEOPLEID = People.Id)'
               +' INNER JOIN Goodsmessage'
               +' ON  (Xsthrecord.GOODSID = Goodsmessage.ID)'
               +' WHERE (People.name="'+cb_ywy.Text +'")'
               +' and (Xsthrecord.mydate>="'+formatdatetime('yyyy-mm-dd',DTP_begin.DateTime)+'")'
               +' AND (Xsthrecord.mydate<="'+formatdatetime('yyyy-mm-dd',dtp_end.DateTime)+'")'
               +' GROUP BY People.Name, Goodsmessage.TYPE, Goodsmessage.NAME  ORDER BY PEOPLE.NAME';
      try
         open;
      except
         messagedlg(Errormsg0001+'0008+0018+0023',mtError,[mbok],0);
         close;
      end;

   end;
end;

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

procedure TFrm_main_query_ywyxstj.SB_printClick(Sender: TObject);
begin
  inherited;
   try
      Application.CreateForm(TFrm_print_ywyxstj, Frm_print_ywyxstj);
      Application.CreateForm(TFrm_print_temp, Frm_print_temp);
   except
      messagedlg(Errormsg0011,mtError,[mbok],0);
      exit;     
   end;
   Frm_print_ywyxstj.QuickRep_ywyxstj.preview;
   Frm_print_ywyxstj.Free ;
   Frm_print_temp.Free ;
end;

procedure TFrm_main_query_ywyxstj.SB_chartClick(Sender: TObject);
begin
  inherited;
   Application.CreateForm(TFrm_chart_ywyxs,frm_chart_ywyxs);
   frm_chart_ywyxs.DTP_begin.Date :=self.DTP_begin.Date ;
   frm_chart_ywyxs.DTP_end.Date :=self.DTP_end.Date ;
   frm_chart_ywyxs.showmodal;
   frm_chart_ywyxs.free;
end;

end.

⌨️ 快捷键说明

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