【delphi开源代码栏目提醒】:以下是网学会员为您推荐的delphi开源代码-instore.pas,希望本篇文章对您学习有所帮助。
unit instore;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB, ComCtrls,list_unit,operator_unit,
product_unit,place_unit,store_unit,DBClient;
type
Tinstorefrm = class(TForm)
GroupBox1: TGroupBox;
DBGrid1: TDBGrid;
GroupBox2: TGroupBox;
list_codelb: TLabel;
operator_idlb: TLabel;
list_datelb: TLabel;
pro_codelb: TLabel;
place_codelb: TLabel;
list_codeed: TEdit;
Instore: TButton;
Instore_Change: TButton;
Instore_Del: TButton;
cancel_btn: TButton;
DateTimePicker1: TDateTimePicker;
instore_ds1: TDataSource;
unitlb: TLabel;
all_btn: TButton;
pro_numed: TEdit;
pro_numlb: TLabel;
instore_cds1: TClientDataSet;
Label1: TLabel;
Label3: TLabel;
Label4: TLabel;
united: TComboBox;
UpDown1: TUpDown;
operator_ided: TComboBox;
pro_codeed: TComboBox;
place_codeed: TComboBox;
procedure cancel_btnClick(Sender: TObject);
procedure InstoreClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure all_btnClick(Sender: TObject);
procedure Instore_DelClick(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure Instore_ChangeClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
list:Tlist;
operator:Toperator;
product:Tproduct;
place:Tplace;
store:Tstore;
{ Private declarations }
public
{ Public declarations }
end;
var
instorefrm: Tinstorefrm;
implementation
{$R *.dfm}
procedure Tinstorefrm.cancel_btnClick(Sender: TObject);
begin
instorefrm.Close;
end;
procedure Tinstorefrm.InstoreClick(Sender: TObject);
var
tt,instr,selstr,modstr:string;
pro_num:integer;
begin
if list_codeed.Text='' then //判断入库单项是否为空
begin
showmessage('入库单编号不能为空!');
exit;
end;
if copy(list_codeed.Text,1,1)<>'I' then //判断是否是入库单
begin
showmessage('入库单编号首部为I,请更改!');
exit;
end;
if length(list_codeed.Text)<>15 then //判断入库单编号位数是否正确
begin
showmessage('对不起,入库单编号位数不对!');
exit;
end;
if length(pro_codeed.Text)<>12 then //判断物品编码位数是否正确
begin
showmessage('对不起,物品编码位数不对!');
exit;
end;
if length(place_codeed.Text)<>7 then //判断库位号位数是否正确
begin
showmessage('对不起,库位号位数不对!');
exit;
end;
try //检查物品数量值是否合法
strtoint(pro_numed.Text);
except
showmessage('入库物品数量不对,请核查!');
exit;
end;
//从出入库单信息表中检查是否已经存在该入库单编号,若有则提示并中止程序
if list.ListRec(list_codeed.Text) then
begin
showmessage('对不起,该入库单编号已经存在,请核查!');
exit;
end;
//从操作员信息表中查看是否存在该操作员,不存在的话提示并中止程序
if operator.OperatorRec(operator_ided.Text)=false then
begin
showmessage('对不起,该操作员代号不存在,请核查!');
exit;
end;
//从物品信息表中查看该物品是否存在,若不存在提示并中止程序
if product.CheckProRec(pro_codeed.Text)=false then
begin
showmessage('对不起,该物品编码不存在,请核查!');
exit;
end;
//从库位信息表中检查该库位号是否存在,若不存在提示并中止程序
if place.CheckRec(place_codeed.Text)=false then
begin
showmessage('对不起,该库位号不存在,请核查!');
exit;
end;
//将时间类型转化为字符窜类型,便于插入表中
tt:=datetostr(datetimepicker1.date);
//主要数据项检查完毕后向出入库单信息表中插入数据
instr:='insert into list_info(list_code,operator_id,list_date,pro_code,'
+'pro_num,unit,place_code)values('''+list_codeed.Text+''','''+operator_ided.Text+''','''+tt+''','
+''''+pro_codeed.Text+''','''+pro_numed.Text+''','''+united.Text+''','''+place_codeed.Text+''')';
list.ListInsert(instr);
//入库时先检查在库中某一位置是否存在该物品
selstr:='select * from store_info where '
+'pro_code='''+pro_codeed.Text+''' and place_code='''+place_codeed.Text+'''';
if store.StoreRec(selstr)=false then
begin
//如果不存在,就将本次入库物品的信息插入库存信息表中
instr:='insert into store_info(pro_code,store_pro_num,unit,place_code'
+')values('''+pro_codeed.Text+''','''+pro_numed.Text+''','''+united.Text+''','''+place_codeed.Text+''')';
store.StoreRecInsert(instr);
end
else
begin
//如果存在,就需要将原有数量与本次入库数量相加,并将库存信息表中的数量更改为相加的结果
pro_num:=strtoint(pro_numed.Text)+strtoint(store.GetStoreNum(selstr));
modstr:='update store_info set store_pro_num='''+inttostr(pro_num)+''' '
+' where pro_code='''+pro_codeed.Text+''' and place_code='''+place_codeed.Text+'''';
store.StoreRecUpdate(modstr);
end;
//将刚插入表中的记录在列表中显示出来
selstr:='select * from Instore_VIEW '
+'where list_code='''+list_codeed.Text+'''';
instore_cds1.Data:=store.StoreRecs(selstr);
showmessage('录入成功!');
end;
procedure Tinstorefrm.FormCreate(Sender: TObject);
var
selstr:string;
begin {
//实例化Tlist类
list:=Tlist.create ;
//在列表框中显示所有的入库单信息
selstr:='select list_code as 入库单编号,operator_id as 操作员代号,'
+'list_date as 入库日期,pro_code as 入库物品编码,pro_num as 入库物品数量,'
+'unit as 物品单位,place_code as 物品库位代号'
+' from list_info where list_code like ''I%'' ';
instore_cds1.Data:=list.Lists(selstr);
//释放实例
list.Free; }
end;
procedure Tinstorefrm.all_btnClick(Sender: TObject);
var
selstr:string;
begin
//实例化Tlist类
list:=Tlist.create ;
//在列表框中显示所有的入库单信息
selstr:='select list_code as 入库单编号,operator_id as 操作员代号,'
+'list_date as 入库日期,pro_code as 入库物品编码,pro_num as 入库物品数量,'
+'unit as 物品单位,place_code as 物品库位代号'
+' from list_info where list_code like ''I%'' ';
instore_cds1.Data:=list.Lists(selstr);
//释放实例
list.Free;
end;
procedure Tinstorefrm.Instore_DelClick(Sender: TObject);
var
delstr,selstr:string;
begin
if application.MessageBox('要删除吗?','警告:',mb_yesno+mb_iconquestion)=idyes then
begin
if list_codeed.Text='' then //判断入库单项是否为空
begin
showmessage('入库单编号不能为空!');
exit;
end;
if copy(list_codeed.Text,1,1)<>'I' then //判断是否是入库单
begin
showmessage('入库单编号首部为I,请更改!');
exit;
end;
if length(list_codeed.Text)<>15 then //判断入库单编号位数是否正确
begin
showmessage('对不起,入库单编号位数不对!');
exit;
end;
{从出入库单信息表中检查是否存在该入库单编号,若不存在则表示删除失败,
提示用户并中止程序}
if list.ListRec(list_codeed.Text)=false then
begin
showmessage('对不起,该入库单编号不存在,请核查!');
exit;
end;
//当出入库单信息表中确有该入库单并确认后进行删除操作
delstr:='delete from list_info where list_code='''+list_codeed.Text+'''';
list.ListDelete(delstr);
selstr:='select list_code as 入库单编号,operator_id as 操作员代号
上一篇:
InputNo.pas
下一篇:
法律专业开题报告范文