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

📄 ufmspotgoodsjc.pas

📁 港口货物管理系统
💻 PAS
字号:
unit ufmspotgoodsjc;

interface

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

type
  Tfmspotgoodsjc = class(TForm)
    Query2: TQuery;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ComboBox2: TComboBox;
    RadioGroup1: TRadioGroup;
    Label2: TLabel;
    GroupBox1: TGroupBox;
    Label3: TLabel;
    TreeView1: TTreeView;
    Query4: TQuery;
    Query1: TQuery;
    Query3: TQuery;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    Label1: TLabel;
    ComboBox1: TComboBox;
    Query5: TQuery;
    GroupBox2: TGroupBox;
    StatusBar1: TStatusBar;
    Panel1: TPanel;
    ImageList1: TImageList;
    Bevel1: TBevel;
    procedure TreeView1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure ComboBox2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure textdisplay;
  private
    { Private declarations }
  public
    node:ttreenode;{ Public declarations }
    fstr:string;
  end;

var
  fmspotgoodsjc: Tfmspotgoodsjc;

implementation

uses ulogin,udm_user, ufmspotprivew;

{$R *.dfm}


procedure tfmspotgoodsjc.textdisplay;
var tncoil,i:integer;
    tnton:single;
begin
tncoil:=0;
tnton:=0;
fmspotprivew.Query1.First;
for i:=1 to fmspotprivew.Query1.RecordCount do
begin
tncoil:=tncoil+fmspotprivew.Query1.FieldValues['ncoil'];
tnton:=tnton+fmspotprivew.Query1.FieldValues['nton'];
fmspotprivew.Query1.Next;
end;
statusbar1.Panels[1].Text:=inttostr(fmspotprivew.Query1.RecordCount)+'  个记录';
statusbar1.Panels[2].Text:='库存件数: '+inttostr(tncoil)+'  件';
statusbar1.Panels[3].Text:='库存吨位: '+formatfloat('0.000',tnton)+'  吨';
end;



procedure Tfmspotgoodsjc.TreeView1Click(Sender: TObject);
var a:string;
    b:string;
begin

if radiogroup1.ItemIndex=0 then
fstr:='atnum'
else fstr:='adime';


a:=treeview1.Selected.Text;
if (treeview1.Selected<>node) then
if treeview1.Selected.TreeView.Selected.Text<>null then
begin
b:=treeview1.Selected.Parent.Text;
fmspotprivew.Query1.Close;
fmspotprivew.Query1.sql.clear;
fmspotprivew.Query1.SQL.Add(' select * from spotgoods  where (agname='''+b+'''');
fmspotprivew.Query1.sql.Add(') and (');
fmspotprivew.Query1.sql.add(fstr+'='''+a+'''');
fmspotprivew.Query1.sql.Add(')');

if combobox2.ItemIndex<>query4.RecordCount then
fmspotprivew.Query1.SQL.add(' and (agoodd='''+combobox2.Text+'''')
else
fmspotprivew.Query1.SQL.add(' and (agoodd is not null');
fmspotprivew.Query1.SQL.add(')');
if combobox1.ItemIndex<>query5.RecordCount then
fmspotprivew.query1.SQL.add(' and (aspot='''+combobox1.text+'''')
else
fmspotprivew.Query1.SQL.add(' and (aspot is not null');
fmspotprivew.Query1.SQL.add(')');

fmspotprivew.Query1.sql.Add(' order by aspot,agoodd,atnum,agname,atnum');
end;

if  treeview1.Selected.Parent=node then
begin
b:=treeview1.Selected.Text;
fmspotprivew.Query1.Close;
fmspotprivew.Query1.sql.clear;
fmspotprivew.Query1.SQL.Add(' select * from spotgoods  where (agname='''+b+'''');
fmspotprivew.Query1.sql.Add(')');
if combobox2.ItemIndex<>query4.RecordCount then
fmspotprivew.Query1.SQL.add(' and (agoodd='''+combobox2.Text+'''')
else
fmspotprivew.Query1.SQL.add(' and (agoodd is not null');
fmspotprivew.Query1.SQL.add(')');
if combobox1.ItemIndex<>query5.RecordCount then
fmspotprivew.query1.SQL.add(' and (aspot='''+combobox1.text+'''')
else
fmspotprivew.Query1.SQL.add(' and (aspot is not null');
fmspotprivew.Query1.SQL.add(')');

fmspotprivew.Query1.sql.Add(' order by aspot,agoodd,agname,atnum');
end

else if  treeview1.Selected=node
then
 begin
 fmspotprivew.Query1.Close;
 fmspotprivew.Query1.sql.clear;
 fmspotprivew.Query1.SQL.Add(' select * from spotgoods ');
 if combobox2.ItemIndex<>query4.RecordCount then
    fmspotprivew.Query1.SQL.add(' where (agoodd='''+combobox2.Text+'''')
    else
    fmspotprivew.Query1.SQL.add(' where (agoodd is not null');
    fmspotprivew.Query1.SQL.add(')');
  if combobox1.ItemIndex<>query5.RecordCount then
  fmspotprivew.query1.SQL.add(' and (aspot='''+combobox1.text+'''')
  else
  fmspotprivew.Query1.SQL.add(' and (aspot is not null');
  fmspotprivew.Query1.SQL.add(')');
  fmspotprivew.Query1.sql.Add(' order by  aspot,agoodd,agname,atnum,adime');
 end;
fmspotprivew.Query1.Active:=true;
fmspotgoodsjc.textdisplay;
end;

procedure Tfmspotgoodsjc.BitBtn2Click(Sender: TObject);
begin
fmspotgoodsjc.Close;
end;



procedure Tfmspotgoodsjc.FormCreate(Sender: TObject);
var i:integer;

begin
application.OnMessage:=fmlogin.doenterastab;
query4.Active:=true;
query4.First;
for i:=1 to query4.RecordCount do
begin
combobox2.Items.add(query4.FieldValues['agoodd']);
query4.Next;
end;
combobox2.Items.Add('所有货代');
combobox2.ItemIndex:=0;

for i:=1 to query5.RecordCount do
begin
combobox1.Items.add(query5.FieldValues['aspot']);
query5.Next;
end;
combobox1.Items.Add('所有货场');
combobox1.ItemIndex:=0;



if radiogroup1.ItemIndex=0 then
fstr:='atnum'
else fstr:='adime';
query1.Close;
query1.SQL.clear;
query1.SQL.add('select distinct agname from spotgoods where (agoodd='''+combobox2.Text+'''');
query1.SQL.add(') and (aspot='''+combobox1.text+'''');
query1.SQL.add(') order by agname');
query1.ExecSQL;
node:=treeview1.Items.Add(nil,'钢材种类');
query1.Open;
query1.First;
for i:=1 to query1.RecordCount do
begin
treeview1.Items.AddChild(node,query1.FieldValues['agname']);
query1.next;
end;

query1.Open;
query1.First;
while not query1.Eof
do
begin
query2.Close;
query2.sql.Clear;
query2.SQL.add('select distinct ');
query2.SQL.Add(fstr+' from spotgoods where ');
query2.SQL.add(' (agname='''+query1.FieldValues['agname']+'''');
query2.sql.add(')');
query2.sql.Add(' and (agoodd='''+combobox2.Text+'''');
query2.SQL.add(') and (aspot='''+combobox1.Text+'''');
query2.SQL.add(') order by '+fstr);
query2.ExecSQL;
query2.Open;
query2.First;

while not query2.Eof do
begin
treeview1.Items.Addchild(node.Item[query1.recno-1],query2.FieldValues[fstr]);
query2.Next;
end;
query1.Next;
end;
end;

procedure Tfmspotgoodsjc.FormActivate(Sender: TObject);
begin
fmspotprivew.Query1.Close;
fmspotprivew.Query1.sql.Clear;
fmspotprivew.Query1.sql.Add('select * from spotgoods order by aspot,agoodd,agname');
fmspotprivew.Query1.Open;
fmspotgoodsjc.textdisplay;
//treeview1.OnClick(sender);
end;



procedure Tfmspotgoodsjc.ComboBox2Click(Sender: TObject);
var i:integer;
begin
if radiogroup1.ItemIndex=0 then
fstr:='atnum'
else fstr:='adime';
query1.Close;
query1.SQL.clear;
query1.SQL.add('select distinct agname from spotgoods ');
if combobox2.ItemIndex<>query4.RecordCount then
begin
query1.sql.Add(' where (agoodd='''+combobox2.Text+'''');
query1.SQL.add(')');
end
else
query1.sql.Add(' where (agoodd is not null)');
if combobox1.ItemIndex<>query5.RecordCount then
query1.SQL.add(' and (aspot='''+combobox1.text+'''')
else
query1.sql.Add(' and (aspot is not null');
query1.SQL.add(')');
query1.ExecSQL;
treeview1.Items.Clear;
node:=treeview1.Items.Add(nil,'钢材种类');
query1.Open;
query1.First;
for i:=1 to query1.RecordCount do
begin
treeview1.Items.AddChild(node,query1.FieldValues['agname']);
query1.next;
end;


query1.Open;
query1.First;
while not query1.Eof
do
begin
query2.Close;
query2.sql.Clear;
query2.SQL.add('select distinct ');
query2.SQL.add(fstr+' from spotgoods ');
if combobox2.ItemIndex<>query4.RecordCount then
begin
query2.sql.Add(' where (agoodd='''+combobox2.Text+'''');
query2.SQL.add(')');
end
else
begin
query2.sql.Add('where (agoodd is not null)');
end;
if combobox1.ItemIndex<>query5.RecordCount then
query2.SQL.add(' and (aspot='''+combobox1.text+'''')
else
query2.sql.Add(' and (aspot is not null');
query2.sql.add(') and (agname='''+query1.FieldValues['agname']+'''');
query2.SQL.add(') order by '+fstr);
query2.ExecSQL;

query2.Open;
query2.First;
while not query2.Eof do
begin
treeview1.Items.Addchild(node.Item[query1.recno-1],query2.FieldValues[fstr]);
query2.Next;
end;
query1.Next;
end;

fmspotprivew.Query1.Close;
fmspotprivew.Query1.sql.clear;
fmspotprivew.Query1.SQL.Add(' select * from spotgoods ');
if combobox2.ItemIndex<>query4.RecordCount then
begin
fmspotprivew.Query1.SQL.add(' where (agoodd='''+combobox2.Text+'''');
fmspotprivew.query1.SQL.add(')');
end
else
begin
fmspotprivew.Query1.SQL.add(' where (agoodd is not null)');
end;
if combobox1.ItemIndex<>query5.RecordCount then
fmspotprivew.query1.SQL.add(' and (aspot='''+combobox1.text+'''')
else
fmspotprivew.query1.sql.Add(' and (aspot is not null');
fmspotprivew.query1.SQL.add(')');
fmspotprivew.Query1.sql.Add(' order by aspot,agoodd,agname,atnum,adime');
fmspotprivew.Query1.Open;
fmspotgoodsjc.textdisplay;
end;



procedure Tfmspotgoodsjc.BitBtn1Click(Sender: TObject);
begin
fmspotprivew.QRLabel10.Caption:='制表人:'+fmuser.susername;
fmspotprivew.QuickRep1.Preview;
end;

procedure Tfmspotgoodsjc.RadioGroup1Click(Sender: TObject);
begin
combobox2.OnClick(sender);
end;

end.

⌨️ 快捷键说明

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