Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cz_012273
WZGL
提交
4826f18c
W
WZGL
项目概览
cz_012273
/
WZGL
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
WZGL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4826f18c
编写于
4月 08, 2022
作者:
cz_012273
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
上传新文件
上级
7f35998c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
218 addition
and
0 deletion
+218
-0
ChuKu.pas
ChuKu.pas
+218
-0
未找到文件。
ChuKu.pas
0 → 100644
浏览文件 @
4826f18c
unit
ChuKu
;
interface
uses
Winapi
.
Windows
,
Winapi
.
Messages
,
System
.
SysUtils
,
System
.
Variants
,
System
.
Classes
,
Vcl
.
Graphics
,
Vcl
.
Controls
,
Vcl
.
Forms
,
Vcl
.
Dialogs
,
Vcl
.
StdCtrls
,
FireDAC
.
Stan
.
Intf
,
FireDAC
.
Stan
.
Option
,
FireDAC
.
Stan
.
Param
,
FireDAC
.
Stan
.
Error
,
FireDAC
.
DatS
,
FireDAC
.
Phys
.
Intf
,
FireDAC
.
DApt
.
Intf
,
FireDAC
.
Stan
.
Async
,
FireDAC
.
DApt
,
FireDAC
.
UI
.
Intf
,
FireDAC
.
Stan
.
Def
,
FireDAC
.
Stan
.
Pool
,
FireDAC
.
Phys
,
FireDAC
.
Phys
.
SQLite
,
FireDAC
.
Phys
.
SQLiteDef
,
FireDAC
.
Stan
.
ExprFuncs
,
FireDAC
.
Phys
.
SQLiteWrapper
.
Stat
,
FireDAC
.
VCLUI
.
Wait
,
Vcl
.
Mask
,
Vcl
.
DBCtrls
,
Data
.
DB
,
FireDAC
.
Comp
.
Client
,
FireDAC
.
Comp
.
DataSet
,
Vcl
.
ExtCtrls
,
Vcl
.
Grids
,
Vcl
.
DBGrids
;
type
TForm3
=
class
(
TForm
)
Label1
:
TLabel
;
FDQuery1
:
TFDQuery
;
FDConnection1
:
TFDConnection
;
DataSource1
:
TDataSource
;
Label2
:
TLabel
;
Label3
:
TLabel
;
DBEdit3
:
TDBEdit
;
Label4
:
TLabel
;
DBEdit4
:
TDBEdit
;
Label5
:
TLabel
;
Label6
:
TLabel
;
Label7
:
TLabel
;
Button1
:
TButton
;
Button2
:
TButton
;
DBGrid1
:
TDBGrid
;
FDQuery2
:
TFDQuery
;
DBText1
:
TDBText
;
DataSource2
:
TDataSource
;
DBLookupComboBox1
:
TDBLookupComboBox
;
Label8
:
TLabel
;
Label9
:
TLabel
;
DBEdit1
:
TDBEdit
;
DBEdit2
:
TDBEdit
;
DBEdit5
:
TDBEdit
;
DBLookupComboBox2
:
TDBLookupComboBox
;
DBLookupComboBox3
:
TDBLookupComboBox
;
FDQuery3
:
TFDQuery
;
DataSource3
:
TDataSource
;
FDQuery4
:
TFDQuery
;
DataSource4
:
TDataSource
;
procedure
Button1Click
(
Sender
:
TObject
);
procedure
Button2Click
(
Sender
:
TObject
);
procedure
FormShow
(
Sender
:
TObject
);
procedure
DBLookupComboBox1CloseUp
(
Sender
:
TObject
);
procedure
DBLookupComboBox2CloseUp
(
Sender
:
TObject
);
procedure
DBLookupComboBox3CloseUp
(
Sender
:
TObject
);
private
{ Private declarations }
public
{ Public declarations }
end
;
var
Form3
:
TForm3
;
implementation
uses
pubunit
;
{$R *.dfm}
procedure
TForm3
.
Button1Click
(
Sender
:
TObject
);
var
i
:
integer
;
begin
i
:=
0
;
if
DBlookupcombobox1
.
text
=
''
then
begin
application
.
MessageBox
(
'品名不能为空!'
,
'系统提示'
,
mb_ok
+
mb_iconinformation
);
exit
;
end
;
if
DBedit3
.
text
=
''
then
begin
application
.
MessageBox
(
'数量不能为空!'
,
'系统提示'
,
mb_ok
+
mb_iconinformation
);
exit
;
end
;
if
DBlookupcombobox3
.
text
=
''
then
begin
application
.
MessageBox
(
'部门(班组)不能为空!'
,
'系统提示'
,
mb_ok
+
mb_iconinformation
);
exit
;
end
;
if
DBlookupcombobox2
.
text
=
''
then
begin
application
.
MessageBox
(
'领取人不能为空!'
,
'系统提示'
,
mb_ok
+
mb_iconinformation
);
exit
;
end
;
FDQuery1
.
post
;
FDQuery1
.
Open
(
'SELECT * FROM 出库表 order by 序号 desc limit 1'
);
//每次仅更新最大序号出库记录
with
FDQuery2
do
//操作库存表
begin
close
;
sql
.
Clear
;
sql
.
Add
(
'select * from 库存表'
);
open
;
FDQuery1
.
First
;
//出库表定位于首记录
while
not
FDQuery1
.
Eof
do
//当出库表非空时,循环开始
begin
FDQuery2
.
first
;
//库存表定位于首记录
while
not
FDQuery2
.
Eof
do
//当库存表非空时,循环开始
begin
if
(
FDQuery2
.
Fields
[
1
].
value
=
FDQuery1
.
Fields
[
1
].
Value
)
and
(
FDQuery2
.
Fields
[
2
].
value
>=
FDQuery1
.
Fields
[
2
].
Value
)
then
//当库存表品名等于出库表品名时
begin
FDQuery2
.
edit
;
//编辑库存表
FDQuery2
.
Fields
[
2
].
value
:=(
FDQuery2
.
Fields
[
2
].
value
)-(
FDQuery1
.
Fields
[
2
].
Value
);
//库存数量减少
//FDQuery2.Fields[4].value:= FDQuery1.Fields[4].Value; //更新出库日期
post
;
i
:=
1
;
// 找到该商品
break
;
//跳出内循环
end
;
FDQuery2
.
Next
;
//到库存表下一记录
end
;
if
i
=
0
then
//如果标记为0,即未找到同名商品
begin
application
.
MessageBox
(
'库存中无此商品或数量不够,请重新选择输入!'
,
'系统提示'
,
mb_ok
+
mb_iconinformation
);
i
:=
0
;
//标记为0
end
;
FDQuery1
.
Next
;
//到出库表下一记录
end
;
end
;
if
i
=
0
then
begin
FDConnection1
.
rollback
;
end
else
begin
FDConnection1
.
commit
;
end
;
//FDConnection1.Connected := false;
close
;
end
;
procedure
TForm3
.
Button2Click
(
Sender
:
TObject
);
begin
FDConnection1
.
rollback
;
//FDConnection1.Connected := false;
close
;
end
;
procedure
TForm3
.
DBLookupComboBox1CloseUp
(
Sender
:
TObject
);
begin
FDQuery1
.
FieldByName
(
'品名'
).
value
:=
DBlookupcombobox1
.
text
;
FDQuery1
.
FieldByName
(
'规格'
).
value
:=
FDQuery2
.
FieldByName
(
'规格'
).
Value
;
FDQuery1
.
FieldByName
(
'使用周期(天)'
).
value
:=
FDQuery2
.
FieldByName
(
'使用周期(天)'
).
Value
;
end
;
procedure
TForm3
.
DBLookupComboBox2CloseUp
(
Sender
:
TObject
);
begin
FDQuery1
.
FieldByName
(
'领取人'
).
value
:=
DBlookupcombobox2
.
text
;
end
;
procedure
TForm3
.
DBLookupComboBox3CloseUp
(
Sender
:
TObject
);
var
keycode
:
string
;
begin
FDQuery1
.
FieldByName
(
'所在部门(班组)'
).
value
:=
DBlookupcombobox3
.
text
;
if
DBlookupcombobox3
.
Text
=
EmptyStr
then
keycode
:=
EmptyStr
else
keycode
:=
DBlookupcombobox3
.
Text
;
//使用filter过滤
FDQuery3
.
Filtered
:=
False
;
FDQuery3
.
Filter
:=
'所在部门(班组)='
+
QuotedStr
(
keycode
);
FDQuery3
.
Filtered
:=
True
;
//清除城市下拉框已选的值
DBlookupcombobox2
.
KeyValue
:=
''
;
end
;
procedure
TForm3
.
FormShow
(
Sender
:
TObject
);
begin
FDConnection1
.
Params
.
Add
(
'Database='
+
dbName
);
FDConnection1
.
Connected
:=
True
;
FDQuery1
.
Close
;
FDQuery1
.
Open
(
'SELECT * FROM 出库表'
);
FDQuery2
.
Close
;
FDQuery2
.
Open
(
'SELECT * FROM 品名表'
);
FDQuery3
.
Close
;
FDQuery3
.
Open
(
'SELECT * FROM 人员表'
);
FDQuery4
.
Close
;
FDQuery4
.
Open
(
'SELECT * FROM 人员表 GROUP BY 所在部门(班组) ORDER BY 序号'
);
FDConnection1
.
starttransaction
;
try
with
FDQuery1
do
begin
refresh
;
//数据表刷新,否则第二次打开本窗体会提示下标越界
Append
;
FieldByName
(
'序号'
).
value
:=
FDQuery1
.
RecordCount
+
1
;
FieldByName
(
'出库日期'
).
value
:=
date
();
Fields
[
0
].
DisplayWidth
:=
4
;
//这个宽度指字符数
Fields
[
1
].
DisplayWidth
:=
20
;
Fields
[
2
].
DisplayWidth
:=
6
;
Fields
[
3
].
DisplayWidth
:=
6
;
Fields
[
4
].
DisplayWidth
:=
10
;
Fields
[
5
].
DisplayWidth
:=
6
;
Fields
[
6
].
DisplayWidth
:=
16
;
end
;
//DBLookupComboBox1.KeyValue:= DBLookupComboBox1.ListSource.DataSet[DBLookupComboBox1.KeyField];
except
FDConnection1
.
rollback
;
end
;
end
;
end
.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录