【delphi开源代码栏目提醒】:网学会员delphi开源代码为您提供goodsin_unit.pas参考,解决您在goodsin_unit.pas学习中工作中的难题,参考学习。
unit goodsin_unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TEMPLETFORM, Menus, ComCtrls, ToolWin, StdCtrls, ExtCtrls,
TradeImage, LabelButton, MoveImageButton, Grids, DBGrids, NewDBGrid, DB,
ADODB, QuickRpt, QRCtrls;
type
Tgoods_in = class(TTEMPLETF)
grid: TNewDBGrid;
Panel1: TPanel;
MIBtnOK: TMoveImgBtn;
lbBtnOK: TLabelBtn;
LabelBtn1: TLabelBtn;
TradeImg1: TTradeImg;
GroupBox1: TGroupBox;
Label2: TLabel;
ComboBox1: TComboBox;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit4: TEdit;
qry: TADOQuery;
DataSource2: TDataSource;
Edit5: TEdit;
qrygoods_id: TStringField;
qryprice: TBCDField;
qry_quit: TADOQuery;
DataSource3: TDataSource;
ComboBox2: TComboBox;
qryordinal: TStringField;
qrygoodsname: TStringField;
Label8: TLabel;
Button1: TButton;
Label9: TLabel;
qrytotal: TFloatField;
MIBtnExit: TMoveImgBtn;
lbBtnExit: TLabelBtn;
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
TitleBand1: TQRBand;
SummaryBand1: TQRBand;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRLabel4: TQRLabel;
QRLabel3: TQRLabel;
QRLabel2: TQRLabel;
QRLabel1: TQRLabel;
QRDBText5: TQRDBText;
QRDBText4: TQRDBText;
QRDBText3: TQRDBText;
QRDBText2: TQRDBText;
QRDBText1: TQRDBText;
QRLabel7: TQRLabel;
QRLabel8: TQRLabel;
QRLabel9: TQRLabel;
QRSysData1: TQRSysData;
QRLabel13: TQRLabel;
QRLabel12: TQRLabel;
QRLabel11: TQRLabel;
QRShape1: TQRShape;
QRExpr1: TQRExpr;
PageFooterBand1: TQRBand;
QRLabel10: TQRLabel;
QRSysData2: TQRSysData;
QRLabel14: TQRLabel;
QRLabel15: TQRLabel;
qryamount: TFloatField;
procedure FormShow(Sender: TObject);
procedure qryBeforePost(DataSet: TDataSet);
procedure gridKeyPress(Sender: TObject; var Key: Char);
procedure MIBtnOKClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure gridExit(Sender: TObject);
procedure ComboBox1Enter(Sender: TObject);
procedure qryCalcFields(DataSet: TDataSet);
procedure MIBtnExitClick(Sender: TObject);
procedure TradeImg1Click(Sender: TObject);
procedure gridColEnter(Sender: TObject);
procedure gridEnter(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
goods_in: Tgoods_in;
implementation
uses data_unit, main_unit;
{$R *.dfm}
procedure Tgoods_in.FormShow(Sender: TObject);
begin
inherited;
Panel1.Visible:=false; //确定按钮不可见
edit2.Text:=main_form.edit2.Text ;
with data.proc do //生成一个新的单号
begin
parameters.ParamByName('@name').Value:='goodsin';
execproc;
edit5.text:='i'+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_in.qryBeforePost(DataSet: TDataSet);
begin
inherited;
qry.fieldbyname('ordinal').AsString:=edit5.text;
end;
procedure Tgoods_in.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_in.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 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();
fields[3].Value:=edit2.Text ;
fields[4].Value:=label5.Caption ;
fields[5].Value:=combobox2.Text ;
fields[6].Value:=edit4.Text ;
fields[9].Value:=time();
post;
end;
application.MessageBox('操作完成!','系统提示',mb_ok+mb_iconinformation);
goods_in.Close;
end;
procedure Tgoods_in.Button1Click(Sender: TObject);
begin
inherited;
grid.SelectedIndex:=0;
combobox1.SetFocus ;
if qry.RecordCount<>0 then
begin
qry.Edit;
qry.Post;
end;
end;
procedure Tgoods_in.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_in.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_in.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_in.MIBtnExitClick(Sender: TObject);
var oldvalue:string;
begin
inherited;
//操作未完成 单号减1--------------------------------------
with qry_quit do
begin
close;
sql.Clear ;
sql.Add('select value from usrordinal where
上一篇:
GoodsInfoUnit.pas
下一篇:
系统中主要发电机的电力系统稳定器