📄 positionsingleform.frm
字号:
If Not m_recordset.EOF Then
With m_recordset '将查询到的记录传到列表显示
Text5.text = Trim(.Fields("产品名称"))
Text5.Tag = Trim(.Fields("productionId"))
Text1(2).text = Trim(.Fields("产品名称")) + "库位"
End With
End If
m_recordset.Close
End If
If Combo1.text = "零件" Then
QueryFom.m_currentQuery = QUERY_PART
QueryFom.show vbModal
m_partDAO.Findpart m_recordset, Trim(MainForm.g_application.m_queryResultId)
If Not m_recordset.EOF Then
With m_recordset '将查询到的记录传到列表显示
Text5.text = Trim(.Fields("零件名称"))
Text5.Tag = Trim(.Fields("零件ID"))
Text1(2).text = Trim(.Fields("零件名称")) + "库位"
End With
End If
m_recordset.Close
End If
Else
MainForm.g_msgText = "请先选择一个存物类别!"
HMsgBox MainForm.g_msgText, 0, 1
Exit Sub
End If
End Sub
Private Sub Form_Activate()
If m_operatorType = 2 Then ' 对操作界面进行设置
Combo1.Enabled = False
Text5.Enabled = False
End If
m_exitFromButton = False
End Sub
Private Sub Form_Load()
Dim ret As Boolean
Set m_positionDAO = New positionDAO
Set m_bomDAO = New BomDAO
Set m_recordset = New ADODB.Recordset
Set m_stockorderDAO = New stockorderDAO
Set m_productionDAO = New productionDAO
Set m_partDAO = New partDAO
Me.Height = 4710
Me.Width = 7050
SetToCenter Me
If m_operatorType = 2 Then ' 物料入库时如果物料在仓库中没有时调用的处理
Me.caption = "库位资料_新增"
c_new.Visible = False
c_cancel.Visible = False
Command1.Enabled = False
clear
Text1(1).text = warehouseid
If articletype = "0" Then
Combo1.text = "原料"
End If
If articletype = "1" Then
Combo1.text = "零件"
End If
If articletype = "2" Then
Combo1.text = "产品"
End If
If articletype = "3" Then
Combo1.text = "工序"
End If
' 找到库存物料的BOM并读出其名称
ret = m_bomDAO.FindByMaterial(m_recordset, articleid, articletype)
If ret Then
Text5.text = Trim(m_recordset.Fields("name"))
Text5.Tag = articleid
End If
m_recordset.Close
Text1(2).text = Trim(Text5.text) + "库位"
Text1(2).Enabled = False
End If ' 物料入库时如果物料在仓库中没有的处理 结束
If m_operatorType = 0 Then
Me.caption = "库位资料_新增"
clear
c_new.Visible = True
c_cancel.Visible = True
End If
If m_operatorType = 1 Then
Me.caption = "库位资料_修改"
c_new.Visible = False
c_cancel.Visible = True
Combo1.Enabled = False
Text5.Enabled = False
Command1.Enabled = False
FindByIdRefresh
' 修改权限判料
If yhqxpd(MainForm.g_application.m_userId, Trim(str(POSITION_MQ))) Then ' 库位数量
T_quantity(3).Enabled = True
T_cost(4).Enabled = True
T_money(5).Enabled = True
Else
T_quantity(3).Enabled = False
T_cost(4).Enabled = False
T_money(5).Enabled = False
End If
If yhqxpd(MainForm.g_application.m_userId, Trim(str(POSITION_MP))) Then ' 库位位置改变
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
T_upperlimmit(6).Enabled = True
T_lowerlimmit(7).Enabled = True
Else
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
T_upperlimmit(6).Enabled = False
T_lowerlimmit(7).Enabled = False
End If
End If
Combo1.AddItem "原料"
Combo1.AddItem "零件"
Combo1.AddItem "产品"
End Sub
'**************************************
'* 功 能 描 述 :新增库位数据处理函数
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub Newposition()
Dim positionExist As Boolean ' 物料在仓库中是否己存在
Dim ret As Boolean
Call Check
If Combo1.text = "原料" Then
Combo1.text = "0"
End If
If Combo1.text = "零件" Then
Combo1.text = "1"
End If
If Combo1.text = "产品" Then
Combo1.text = "2"
End If
If Combo1.text = "工序" Then
Combo1.text = "3"
End If
MainForm.g_application.m_databaseCon.m_adoConnection.BeginTrans
On Error GoTo EXITSUB
'**************************判断此物料在此仓库中是否存在*****************************
positionExist = m_positionDAO.PositionJudgeExist(Trim(Text1(1).text), Trim(Text5.Tag))
'***********************************************************************************
If Not positionExist Then ' 不存在
ret = m_positionDAO.Newposition(m_recordset, Trim(Text1(1).text), _
Trim(Text1(2).text), Trim(T_quantity(3).text), Replace(Trim(T_cost(4).text), "¥", ""), _
Replace(Trim(T_money(5).text), "¥", ""), Trim(T_upperlimmit(6).text), Trim(T_lowerlimmit(7).text), _
Trim(Text5.Tag), Trim(Combo1.text), DTPicker1.value, _
Trim(Text1(9).text), Trim(Text2.text), Trim(Text3.text), Trim(Text4.text))
Else ' 存在
MainForm.g_msgText = "本仓库中已存在本物料的库位!新增失败!"
HMsgBox MainForm.g_msgText, 0, 1
GoTo EXITSUB
End If
MainForm.g_application.m_databaseCon.m_adoConnection.CommitTrans
Exit Sub
EXITSUB:
MainForm.g_application.m_databaseCon.m_adoConnection.RollbackTrans
End Sub
'**************************************
'* 功 能 描 述 :修改库位处理函数
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub Modifyposition()
'
Dim ret As Boolean
Call Check
If Combo1.text = "原料" Then
Combo1.text = "0"
End If
If Combo1.text = "零件" Then
Combo1.text = "1"
End If
If Combo1.text = "产品" Then
Combo1.text = "2"
End If
If Combo1.text = "工序" Then
Combo1.text = "3"
End If
ret = m_positionDAO.Modifyposition(m_recordset, _
Trim(Text1(2).text), Trim(T_quantity(3).text), Replace(Trim(T_cost(4).text), "¥", ""), _
Replace(Trim(T_money(5).text), "¥", ""), Trim(T_upperlimmit(6).text), Trim(T_lowerlimmit(7).text), _
Trim(Text5.Tag), Trim(Combo1.text), DTPicker1.value, _
Trim(Text1(9).text), Trim(Text2.text), Trim(Text3.text), Trim(Text4.text), m_positionId)
End Sub
'**************************************
'* 功 能 描 述 :检验数据的合法性
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub Check()
f = "1"
If Trim(Text1(2).text) = "" Then
MainForm.g_msgText = "库位名称不能为空!"
HMsgBox MainForm.g_msgText, 0, 1
Text1(2).SetFocus
f = "0"
Exit Sub
End If
If Trim(T_upperlimmit(6).text) = "" Or Not IsNumeric(Trim(T_upperlimmit(6).text)) Then
MainForm.g_msgText = "库存上限不能为空或者数据类型不正确!"
HMsgBox MainForm.g_msgText, 0, 1
T_upperlimmit(6).SetFocus
f = "0"
Exit Sub
End If
If Trim(T_lowerlimmit(7).text) = "" Or Not IsNumeric(Trim(T_lowerlimmit(7).text)) Then
MainForm.g_msgText = "库存下限不能为空或者数据类型不正确!"
HMsgBox MainForm.g_msgText, 0, 1
T_lowerlimmit(7).SetFocus
f = "0"
Exit Sub
End If
If Trim(Combo1.text) = "" Then
MainForm.g_msgText = "存物类别不能为空!"
HMsgBox MainForm.g_msgText, 0, 1
' Combo1.SetFocus
f = "0"
Exit Sub
End If
If Trim(Text5.text) = "" Then
MainForm.g_msgText = "存物名称不能为空!"
HMsgBox MainForm.g_msgText, 0, 1
' Text5.SetFocus
f = "0"
Exit Sub
End If
If Trim(Text2.text) = "" Then
MainForm.g_msgText = "架号不能为空!"
HMsgBox MainForm.g_msgText, 0, 1
Text2.SetFocus
f = "0"
Exit Sub
End If
If Trim(Text3.text) = "" Then
MainForm.g_msgText = "层号不能为空!"
HMsgBox MainForm.g_msgText, 0, 1
Text3.SetFocus
f = "0"
Exit Sub
End If
If Trim(Text4.text) = "" Then
MainForm.g_msgText = "位号不能为空!"
HMsgBox MainForm.g_msgText, 0, 1
Text4.SetFocus
f = "0"
Exit Sub
End If
If CDbl(Trim(T_lowerlimmit(7).text)) = 0 And CDbl(Trim(T_upperlimmit(6).text)) = 0 Then
Else
If CDbl(Trim(T_lowerlimmit(7).text)) >= CDbl(Trim(T_upperlimmit(6).text)) Then
MainForm.g_msgText = "库存上限数值不能小于等于库存下限!"
HMsgBox MainForm.g_msgText, 0, 1
T_upperlimmit(6).SetFocus
f = "0"
Exit Sub
End If
End If
End Sub
'**************************************
'* 功 能 描 述 :根据库位ID找到库位资料并显示在界面上
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub FindByIdRefresh()
Dim ret As Boolean
ret = m_positionDAO.FindById(m_recordset, m_positionId)
If ret Then
With m_recordset
Text1(0).text = Trim(.Fields("库位ID"))
Text1(1).text = Trim(.Fields("仓库ID"))
Text1(2).text = Trim(.Fields("库位名称"))
T_quantity(3).text = Trim(.Fields("库存的数量"))
T_cost(4).text = "¥" & Trim(.Fields("库存成本"))
T_money(5).text = "¥" & Trim(.Fields("库存金额"))
T_upperlimmit(6).text = Trim(.Fields("库存上限"))
T_lowerlimmit(7).text = Trim(.Fields("库存下限"))
Text5.Tag = Trim(.Fields("存物ID"))
If Trim(.Fields("存物类别")) = "0" Then
Combo1.text = "原料"
End If
If Trim(.Fields("存物类别")) = "1" Then
Combo1.text = "零件"
End If
If Trim(.Fields("存物类别")) = "2" Then
Combo1.text = "产品"
End If
If Trim(.Fields("存物类别")) = "3" Then
Combo1.text = "工序"
End If
DTPicker1.value = Trim(.Fields("存物有效期"))
Text1(9).text = Trim(.Fields("备注"))
Text2.text = Trim(.Fields("架号"))
Text3.text = Trim(.Fields("层号"))
Text4.text = Trim(.Fields("位号"))
m_recordset.Close
End With
Else
MainForm.g_msgText = "库位ID不正确,请重新操作!"
HMsgBox MainForm.g_msgText, 0, 1
Unload Me
End If
If Combo1.text = "工序" Then
ret = m_bomDAO.FindByMaterial(m_recordset, Trim(Text5.Tag), "3")
If ret Then
Text5.text = Trim(m_recordset.Fields("name"))
End If
m_recordset.Close
End If
If Combo1.text = "原料" Then
m_positionDAO.show_goods m_recordset '获得商品名称列表
With m_recordset
Do While Not .EOF
If Text5.Tag = Trim(.Fields(0)) Then
Text5.text = Trim(.Fields(1))
End If
.MoveNext
Loop
End With
m_recordset.Close
End If
If Combo1.text = "产品" Then
m_positionDAO.show_production m_recordset '获得产品名称列表
With m_recordset
Do While Not .EOF
If Text5.Tag = Trim(.Fields(0)) Then
Text5.text = Trim(.Fields(1))
End If
.MoveNext
Loop
End With
m_recordset.Close
End If
If Combo1.text = "零件" Then
m_positionDAO.show_part m_recordset '获得零件名称列表
With m_recordset
Do While Not .EOF
If Text5.Tag = Trim(.Fields(0)) Then
Text5.text = Trim(.Fields(1))
End If
.MoveNext
Loop
End With
m_recordset.Close
End If
End Sub
'**************************************
'* 功 能 描 述 :清除界面上文本框里的所有内容
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub clear()
Text1(0).text = ""
' Text1(1).text = ""
Text1(2).text = ""
T_quantity(3).text = "0"
T_cost(4).text = "¥" & "0"
T_money(5).text = "¥" & "0"
T_upperlimmit(6).text = "0"
T_lowerlimmit(7).text = "0"
DTPicker1.value = Date
Text1(9).text = ""
Text2.text = "1"
Text3.text = "1"
Text4.text = "1"
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not m_exitFromButton Then
If m_operatorType = 2 Then
Cancel = -1
End If
End If
End Sub
Private Sub T_cost_Change(Index As Integer)
b = CDbl(T_cost(4).text)
T_money(5).text = "¥" & Trim(CDbl(T_quantity(3).text) * CDbl(T_cost(4).text))
End Sub
Private Sub T_money_Change(Index As Integer)
If InStr(Trim(T_money(5).text), "¥") = 0 Then
T_money(5).text = "¥" & Trim(T_money(5).text)
End If
End Sub
Private Sub T_quantity_Change(Index As Integer)
Dim sum As Single
A = CDbl(T_quantity(3).text)
sum = A * b
T_money(5).text = "¥" & sum
End Sub
Private Sub T_quantity_KeyPress(Index As Integer, KeyAscii As Integer)
InputFieldLimit T_quantity(3), 4, KeyAscii
End Sub
Private Sub T_lowerlimmit_KeyPress(Index As Integer, KeyAscii As Integer)
InputFieldLimit T_lowerlimmit(7), 6, KeyAscii
End Sub
Private Sub T_upperlimmit_KeyPress(Index As Integer, KeyAscii As Integer)
InputFieldLimit T_upperlimmit(6), 6, KeyAscii
End Sub
'Private Sub T_money_KeyPress(Index As Integer, KeyAscii As Integer)
' InputFieldLimit T_money(5), 6, KeyAscii
'End Sub
Private Sub T_cost_KeyPress(Index As Integer, KeyAscii As Integer)
InputFieldLimit T_cost(4), 6, KeyAscii
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -