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

📄 udepartment.pas

📁 PosEasy收银系统源码,Pos机前后台管理代码
💻 PAS
字号:
unit UDepartment;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, Grids, DBGrids, Db, DBTables;

type
  TDepartment = class(TForm)
    DataSource1: TDataSource;
    DepQuery: TQuery;
    TmpQuery: TQuery;
    DBGrid1: TDBGrid;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Query1: TQuery;
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
    ocf:boolean;
  public
    { Public declarations }
  end;

var
  Department: TDepartment;

implementation

uses main, UParticular;
procedure AlignGrid(dbgrid:Tdbgrid);stdcall;external 'AlignGriddll.dll';

{$R *.DFM}

procedure TDepartment.FormCreate(Sender: TObject);
var
  tmpsql,tmpflag:string;
begin
  ocf:=False;
  TmpQuery.Close;
  TmpQuery.SQL.Clear;
  TmpQuery.SQL.Add('create table #tmp (销售部门 char(15),库存结算金额 money,进货结算金额 money,销售结算金额 money)');
  TmpQuery.ExecSQL;
  TmpQuery.Close;
  TmpQuery.SQL.Clear;
  TmpQuery.SQL.Add('select 部门名称 from deptnamebase');
  TmpQuery.Open;
  while not TmpQuery.Eof do
    begin
      tmpflag:=TmpQuery.Fields[0].AsString;
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add('insert into #tmp(销售部门) values('''+tmpflag+''')');
      Query1.ExecSQL;
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add('select 销售部门,(进价*进货数量)as total into #aa from goodsbase where 销售部门='''+tmpflag+'''');
      Query1.ExecSQL;
      tmpsql:='update #tmp set 库存结算金额=(select sum(库存结算金额) from goodsbase where ';
      tmpsql:=tmpsql+'销售部门='''+tmpflag+'''),进货结算金额=(select sum(total) from #aa where ';
      tmpsql:=tmpsql+'销售部门='''+tmpflag+'''),销售结算金额=(select sum(销售结算金额) from ';
      tmpsql:=tmpsql+'goodsbase where 销售部门='''+tmpflag+''') where 销售部门='''+tmpflag+'''';
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add(tmpsql);
      Query1.ExecSQL;
      DepQuery.Close;
      DepQuery.SQL.Clear;
      DepQuery.SQL.Add('select * from #tmp');
      DepQuery.Open;
      TmpQuery.Next;
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add('drop table #aa');
      Query1.ExecSQL;
    end;
  AlignGrid(dbgrid1);
  Dbgrid1.Columns[0].Width:=159;
  Dbgrid1.Columns[1].Width:=158;
  Dbgrid1.Columns[2].Width:=158;
  Dbgrid1.Columns[3].Width:=158;
end;

procedure TDepartment.SpeedButton3Click(Sender: TObject);
begin
  sflag:=1;
  ocf:=True;
  Query1.Close;
  Query1.SQL.Clear;
  Query1.SQL.Add('drop table #tmp');
  Query1.ExecSQL;
  DepQuery.Close;
  TmpQuery.Close;
  Query1.Close;
  Department.Release;
  Department.Close;
end;

procedure TDepartment.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if ocf=False then
    begin
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add('drop table #tmp');
      Query1.ExecSQL;
      DepQuery.Close;
      TmpQuery.Close;
      Query1.Close;
      Department.Release;
      Department.Close;
    end;
end;

procedure TDepartment.SpeedButton1Click(Sender: TObject);
begin
  Application.CreateForm(TParticular,Particular);
  Particular.ShowModal;
end;

procedure TDepartment.FormActivate(Sender: TObject);
begin
  sflag:=2;
end;

end.

⌨️ 快捷键说明

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