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

📄 goods_out_unit.~pas

📁 一个很不错的仓库管理系统,能容进各种软件中去,
💻 ~PAS
字号:
unit goods_out_unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TEMPLETFORM, DB, ADODB, StdCtrls, TradeImage, LabelButton,
  MoveImageButton, Grids, DBGrids, NewDBGrid, Menus, ComCtrls, ToolWin,
  ExtCtrls, QRCtrls, QuickRpt;

type
  Tgoods_out = class(TTEMPLETF)
    grid: TNewDBGrid;
    Label8: TLabel;
    Panel1: TPanel;
    MIBtnOK: TMoveImgBtn;
    lbBtnOK: TLabelBtn;
    LabelBtn1: TLabelBtn;
    TradeImg1: TTradeImg;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label7: TLabel;
    Label9: TLabel;
    ComboBox1: TComboBox;
    Edit2: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Button1: TButton;
    DataSource2: TDataSource;
    qry: TADOQuery;
    qryordinal: TStringField;
    qrygoods_id: TStringField;
    qryprice: TBCDField;
    qrygoodsname: TStringField;
    qrytotal: TFloatField;
    DataSource3: TDataSource;
    qry_quit: TADOQuery;
    QuickRep1: TQuickRep;
    DetailBand1: TQRBand;
    SummaryBand1: TQRBand;
    TitleBand1: TQRBand;
    QRLabel1: TQRLabel;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRLabel4: TQRLabel;
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRDBText1: TQRDBText;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    QRDBText4: TQRDBText;
    QRDBText5: TQRDBText;
    QRShape1: TQRShape;
    QRLabel7: TQRLabel;
    QRLabel8: TQRLabel;
    QRLabel9: TQRLabel;
    QRExpr1: TQRExpr;
    QRLabel10: TQRLabel;
    QRSysData1: TQRSysData;
    lbBtnExit: TLabelBtn;
    MIBtnExit: TMoveImgBtn;
    PageFooterBand1: TQRBand;
    QRLabel11: TQRLabel;
    QRSysData2: TQRSysData;
    QRLabel12: TQRLabel;
    QRLabel13: TQRLabel;
    qryamount: TFloatField;
    procedure MIBtnOKClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure qryBeforePost(DataSet: TDataSet);
    procedure gridKeyPress(Sender: TObject; var Key: Char);
    procedure Button1Click(Sender: TObject);
    procedure gridExit(Sender: TObject);
    procedure ComboBox1Enter(Sender: TObject);
    procedure qryCalcFields(DataSet: TDataSet);
    procedure MIBtnExitClick(Sender: TObject);
    procedure TradeImg1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  goods_out: Tgoods_out;

implementation

uses data_unit, main_unit;

{$R *.dfm}

procedure Tgoods_out.MIBtnOKClick(Sender: TObject);
var i:integer;
    producer_id:string;
begin
  inherited;

if combobox1.text='' then
begin
application.MessageBox('供应商不能为空!','系统提示',mb_ok+mb_iconinformation);
exit;
end;

TradeImg1Click(nil);
{
i:=0;             //标识是否在库存中找到该商品
with qry_quit do  //总仓库加
begin
close;
sql.Clear ;
sql.Add('select * from storage');
open;
qry.First;
while not qry.Eof do
begin
i:=0;
qry_quit.First;
while not qry_quit.Eof do
begin
if qry_quit.Fields[0].value=qry.Fields[1].Value then
begin
qry_quit.edit;

qry_quit.Fields[1].value:=(qry_quit.Fields[1].value)+(qry.Fields[2].Value); //总仓库加
post;
i:=1;  //  找到该商品
break;

end;
qry_quit.Next ;
end;
if i=0 then
begin
qry_quit.Append;
qry_quit.Fields[0].value:=qry.Fields[1].Value;
qry_quit.Fields[1].value:=(qry.Fields[2].Value);
post;
i:=0;
end;
qry.Next ;
end;
end;

}

with qry_quit do  //总仓库减
begin
close;
sql.Clear ;
sql.Add('select * from storage');
open;
qry.First;
while not qry.Eof do
begin
qry_quit.First;
while not qry_quit.Eof do
begin
if qry_quit.Fields[0].value=qry.Fields[1].Value then
begin
qry_quit.edit;
qry_quit.Fields[1].value:=(qry_quit.Fields[1].value)-(qry.Fields[2].Value); //总仓库减
post;
break;
end;
qry_quit.Next ;
end;
qry.Next ;
end;
end;

with qry_quit do
begin
close;
sql.Clear ;
sql.Add('select * from manufacturer where producer_name=:name');
parameters.ParamByName('name').Value:=combobox1.Text ;
open;
producer_id:=fields[0].Value ;
end;



with qry_quit do
begin
close;
sql.Clear ;
sql.Add('select * from goods_in');
open;
append;
{
fields[0].Value:=edit5.Text ;
//fields[1].Value:=edit1.Text ;
fields[1].Value:=producer_id  ;
fields[2].Value:=date()+time();
fields[3].Value:=edit2.Text ;
fields[4].Value:=label5.Caption ;
fields[5].Value:=edit4.Text ;
}
fields[0].Value:=edit5.Text ;
fields[1].Value:=producer_id;
fields[2].Value:=date();
fields[3].Value:=edit2.Text ;
fields[4].Value:=label5.Caption ;
fields[5].Value:='否' ;
fields[6].Value:=edit4.Text ;
fields[9].Value:=time();
post;
end;

application.MessageBox('操作完成!','系统提示',mb_ok+mb_iconinformation);
goods_out.Close;

end;

procedure Tgoods_out.FormShow(Sender: TObject);
begin
  inherited;

edit2.text:=main_form.edit2.text;

with data.proc do   //生成一个新的单号
begin
parameters.ParamByName('@name').Value:='goodsout';
execproc;
edit5.text:='o'+parameters.ParamByName('@value').Value
end;
//----------------------------------------------

with qry do
begin
close;
sql.Clear ;
sql.add('select * from goods_info where ordinal=:id');
parameters.ParamByName('id').value:=edit5.Text ;
open; 
end;

grid.SetFocus;
grid.SelectedIndex:=0;
end;

procedure Tgoods_out.qryBeforePost(DataSet: TDataSet);
begin
  inherited;
qry.fieldbyname('ordinal').AsString:=edit5.text;
end;

procedure Tgoods_out.gridKeyPress(Sender: TObject; var Key: Char);
begin
  inherited;
  if (grid.SelectedIndex=1) and  (grid.SelectedField.Text='') then      //判断货物是否存在
  begin
  grid.SelectedIndex:=0;
  grid.SelectedField.Text:=''
  end;

    if (grid.SelectedField.Text<>'')  then
  begin
   if (Key =#13) then          //用enter代替tab键  (grid.SelectedIndex=1) and
    keybd_event(VK_TAB,0,0,0);
  end;
end;

procedure Tgoods_out.Button1Click(Sender: TObject);
begin
  inherited;
combobox1.SetFocus ;
if qry.RecordCount<>0 then
begin
qry.Edit;
qry.Post;
end;
end;

procedure Tgoods_out.gridExit(Sender: TObject);
var value:real;
    id:integer;
begin
  inherited;
combobox1.SetFocus ;
if qry.RecordCount<>0 then
begin
qry.Edit;
qry.Post;
end;

value:=0;
with qry do
begin
first;
id:=qry.RecordCount;     // 计算总价格
while id>0 do
begin
value:=value+(qry.fields[5].value);
qry.next;
id:=id-1;
end;
label5.Caption:=floattostr(value);
end;

end;

procedure Tgoods_out.ComboBox1Enter(Sender: TObject);
var a:integer;
begin
  inherited;
 combobox1.Items.clear;
 with qry_quit do
 begin
   close;
   sql.Clear ;
   sql.Add('select * from manufacturer where exist=:id');
   parameters.ParamByName('id').value:=1;
   open;
   first;
 end;
 a:=qry_quit.RecordCount;
 {if qry_quit.RecordCount>0 then
   combobox1.text:=qry_quit.fields[1].asstring;
 repeat
   combobox1.Items.Add(qry_quit.fields[1].asstring);
 until qry_quit.findnext=false;
  }
 while a>0 do
 begin
  combobox1.Items.Add(trim(qry_quit.fields[1].asstring));
  qry_quit.Next ;
  a:=a-1;
 end;

end;

procedure Tgoods_out.qryCalcFields(DataSet: TDataSet);
begin
  inherited;
if (not qry.FieldByName('amount').IsNull) and (not qry.FieldByName('price').IsNull) then
qrytotal.value:=(qryprice.value)*(qryamount.value);
end;

procedure Tgoods_out.MIBtnExitClick(Sender: TObject);
var oldvalue:string;
begin
  inherited;
//操作未完成 单号减1--------------------------------------
with qry_quit do
begin
close;
sql.Clear ;
sql.Add('select value from usrordinal where name=:name');
parameters.ParamByName('name').Value:='goodsout';
open;
if recordcount<>0 then
begin
//edit;
//fieldByName('value').Value:='0'+inttostr(strtoint(fieldByName('value').Value)-1) ;
//post;
      oldvalue:=fields[0].AsString;
      Close;
      SQL.Clear;
      SQL.Add('update usrordinal set value=:value where name=''goodsout''');
      Parameters.ParamByName('value').Value:='0'+inttostr(strtoint(oldvalue)-1);
      ExecSQL;
end;
end;
//删除已经输入的内容-------------------------------
with qry_quit do
begin
close;
sql.Clear ;

sql.Add('delete from goods_info where ordinal=:id');
parameters.ParamByName('id').Value:=edit5.Text ;
execsql;
end;
//-------------------------------------------------
qry.Close;
edit2.Clear ;
edit4.Clear ;
label5.Caption:='';
combobox1.Clear ;
close;
end;

procedure Tgoods_out.TradeImg1Click(Sender: TObject);
begin
  inherited;
qrlabel8.caption:=combobox1.text;
qrlabel13.caption:=edit5.text;
quickrep1.preview;
end;

end.

⌨️ 快捷键说明

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