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

📄 uinputgoods.pas

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

interface

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

type
  Tfminputgoods = class(TForm)
    Bevel1: TBevel;
    Label1: TLabel;
    Label2: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    DBGrid1: TDBGrid;
    Edit2: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    ComboBox1: TComboBox;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    DateTimePicker1: TDateTimePicker;
    Table1: TTable;
    Label3: TLabel;
    Edit1: TEdit;
    Label4: TLabel;
    DBLookupComboBox1: TDBLookupComboBox;
    Label9: TLabel;
    ComboBox2: TComboBox;
    Table2: TTable;
    DataSource1: TDataSource;
    DataSource2: TDataSource;
    Query1: TQuery;
    DataSource3: TDataSource;
    Memo1: TMemo;
    Edit3: TEdit;
    Label11: TLabel;
    ComboBox3: TComboBox;
    ComboBox4: TComboBox;
    StatusBar1: TStatusBar;
    Query2: TQuery;
    Table3: TTable;
    Query3: TQuery;
    GroupBox1: TGroupBox;
    procedure ComboBox1Click(Sender: TObject);
    procedure DBLookupComboBox1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ComboBox3Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure ComboBox4Click(Sender: TObject);
    procedure FormClick(Sender: TObject);
  
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fminputgoods: Tfminputgoods;

implementation


uses udm_user, ulogin;

{$R *.dfm}

procedure Tfminputgoods.ComboBox1Click(Sender: TObject);
begin
combobox4.Clear;
query1.Close;
query1.SQL.Clear;
query1.sql.add('select distinct atnum,agname from mplan where lend=false and agoodd='''+combobox1.Text+'''');
query1.SQL.Add(' order by agname');
query1.ExecSQL;
query1.Active:=true;
end;

procedure Tfminputgoods.DBLookupComboBox1Click(Sender: TObject);
begin
combobox4.Clear;
try
table1.DisableControls;
table1.First;
while not  table1.eof
do
begin
if (table1.FieldValues['agoodd']=combobox1.Text) and (table1.FieldValues['atnum']=dblookupcombobox1.Text) and (table1.FieldValues['lend']=false)
then
//if table1.FieldValues['adime']<>'' then
combobox4.Items.add(table1.FieldValues['adime']);

table1.next;
end;
finally
table1.EnableControls;
end;
if combobox4.Items.Count=0
then
begin
combobox4.Enabled:=false;
memo1.Clear;
with table1 do
begin
table1.Locate('agoodd;atnum',vararrayof([combobox1.text,dblookupcombobox1.text]),[]);
memo1.Lines.Add('货代:'+table1.FieldValues['agoodd']);
memo1.Lines.Add('提单号:'+table1.FieldValues['atnum']);
memo1.Lines.Add('货名:'+table1.FieldValues['adime']+' '+table1.FieldValues['agname']);
memo1.Lines.Add('计划吨位:'+inttostr(table1.FieldValues['nton'])+'吨');

end;
end;
end;

procedure Tfminputgoods.FormCreate(Sender: TObject);
var i:integer;
begin
application.OnMessage:=fmlogin.doenterastab;
datetimepicker1.Date:=date();
edit3.Text:='0';
edit5.Text:='0';
edit6.Text:='';
edit2.Text:='';
edit1.Text:='';
query2.Active:=true;
query2.First;
for i:=1 to query2.RecordCount do
begin
combobox1.Items.Add(query2.FieldValues['agoodd']);
query2.Next;
end;
combobox1.ItemIndex:=0;
combobox1.OnClick(sender);

query3.First;
for i:=1 to query3.RecordCount do
begin
combobox3.Items.Add(query3.FieldValues['aspot']);
query3.Next;
end;
combobox3.ItemIndex:=0;


end;

procedure Tfminputgoods.ComboBox3Click(Sender: TObject);
begin
edit1.SetFocus;
end;

procedure Tfminputgoods.BitBtn4Click(Sender: TObject);
begin
fminputgoods.Close;
end;

procedure Tfminputgoods.BitBtn1Click(Sender: TObject);
var tempnum:string;
begin
if table2.Locate('ddate;atnum;ncoil',vararrayof([datetostr(datetimepicker1.date),dblookupcombobox1.text,strtoint(edit3.Text)]),[])=false
then
begin
table2.Append;
table2.FieldValues['ddate']:=formatdatetime('yyyy-mm-dd',datetimepicker1.Date);
table2.FieldValues['atnum']:=dblookupcombobox1.Text;
table2.FieldValues['agname']:=table1.FieldValues['agname'];
table2.FieldValues['adime']:=table1.FieldValues['adime'];
table2.FieldValues['ncoil']:=strtoint(edit3.Text);
tempnum:=formatfloat('0.000',strtofloat(edit5.text));
table2.FieldValues['nton']:=strtofloat(tempnum);
table2.FieldValues['aqd']:=combobox2.Text;
table2.FieldValues['atname']:=trim(edit6.Text);
table2.FieldValues['aspot']:=combobox3.Text+edit1.Text;
table2.FieldValues['agoodd']:=table1.FieldValues['agoodd'];
table2.FieldValues['lout']:=false;
table2.FieldValues['auser']:=fmuser.susername;
table2.FieldValues['agroup']:=fmuser.strgroup;
table2.FieldValues['abz']:=edit2.Text;
table2.Post;
end
else
messagedlg('你已经输入此条记录!请核查!!',mtInformation,
      [mbOk], 0);

if table3.Locate('atnum;adime;agoodd;aspot',vararrayof([dblookupcombobox1.text,combobox4.text,combobox1.text,combobox3.text]),[])=false
then
begin
table3.Append;
table3.FieldValues['atnum']:=dblookupcombobox1.Text;
table3.FieldValues['agname']:=table1.FieldValues['agname'];
table3.FieldValues['adime']:=table1.FieldValues['adime'];
table3.FieldValues['ncoil']:=strtoint(edit3.Text);
tempnum:=formatfloat('0.000',strtofloat(edit5.text));
table3.FieldValues['nton']:=strtofloat(tempnum);
table3.FieldValues['aspot']:=combobox3.Text+edit1.Text;
table3.FieldValues['agoodd']:=table1.FieldValues['agoodd'];
table3.FieldValues['abz']:=edit2.Text;
table3.Post;
end
else
begin
table3.edit;
table3.FieldValues['ncoil']:=table3.FieldValues['ncoil']+strtoint(edit3.Text);
tempnum:=formatfloat('0.000',strtofloat(edit5.text));
table3.FieldValues['nton']:=table3.FieldValues['nton']+strtofloat(tempnum);
table3.Post;
end;



fminputgoods.OnClick(sender);
fminputgoods.ComboBox4.OnClick(sender);
end;

procedure Tfminputgoods.BitBtn3Click(Sender: TObject);
begin
if table2.RecordCount>0 then
begin
if table3.Locate('agoodd;atnum;adime;aspot',vararrayof([table2.FieldValues['agoodd'],table2.FieldValues['atnum'],table2.FieldValues['adime'],table2.FieldValues['aspot']]),[])=true then
if table3.FieldValues['ncoil']-table2.FieldValues['ncoil']=0 then
table3.Delete
else
begin
table3.Edit;
table3.FieldValues['ncoil']:=table3.FieldValues['ncoil']-table2.FieldValues['ncoil'];
table3.FieldValues['nton']:=table3.FieldValues['nton']-table2.FieldValues['nton'];
table3.Post;
end;
table2.Delete;
end
else
showmessage('没有可删除的记录!');
fminputgoods.OnClick(sender);
fminputgoods.ComboBox4.OnClick(sender);
end;


procedure Tfminputgoods.ComboBox4Click(Sender: TObject);

var aa:integer;
    bb:single;
begin
aa:=0;
bb:=0;
try
table3.DisableControls;
table3.First;
while not  table3.eof
do
begin
if (table3.FieldValues['agoodd']=combobox1.Text) and (table3.FieldValues['atnum']=dblookupcombobox1.Text) and  (table3.FieldValues['adime']=combobox4.Text)
then
begin
aa:=aa+table3.FieldValues['ncoil'];
bb:=bb+table3.FieldValues['nton'];
end;
table3.next;
end;
finally
table3.EnableControls;
end;

memo1.Clear;
with table1 do
begin
table1.Locate('agoodd;atnum;adime',vararrayof([combobox1.text,dblookupcombobox1.text,combobox4.text]),[]);
memo1.Lines.Add('货代:'+table1.FieldValues['agoodd']);
memo1.Lines.Add('提单号:'+table1.FieldValues['atnum']);
memo1.Lines.Add('货名:'+table1.FieldValues['adime']+' '+table1.FieldValues['agname']);
memo1.Lines.Add('库存件数:'+inttostr(aa)+' 件');
memo1.Lines.Add('库存吨位:'+formatfloat('0.000',bb)+' 吨');
memo1.Lines.Add('计划吨位:'+inttostr(table1.FieldValues['nton'])+' 吨');
end;
end;

procedure Tfminputgoods.FormClick(Sender: TObject);
var sumton:single;
    i,sumcoil:integer;
begin
sumton:=0.000;
sumcoil:=0;
table2.First;
for i:=1 to table2.RecordCount do
begin
sumton:=sumton+table2.FieldValues['nton'];
sumcoil:=sumcoil+table2.FieldValues['ncoil'];
table2.Next;
end;
statusbar1.Panels[1].Text:=inttostr(table2.RecordCount)+' 个记录';
statusbar1.Panels[2].Text:=inttostr(sumcoil)+' 件';
statusbar1.Panels[3].Text:=formatfloat('0.000',sumton)+' 吨';
end;


end.

⌨️ 快捷键说明

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