📄 stockorder.frm
字号:
ErrHandle:
End Sub
Private Sub Form_Unload(Cancel As Integer)
i = 0
currentrow = 0
End Sub
Private Sub MSHFlexGrid1_Click()
m_row = MSHFlexGrid1.MouseRow
m_col = MSHFlexGrid1.MouseCol
If m_row < MSHFlexGrid1.FixedRows Then m_row = MSHFlexGrid1.FixedRows
If m_col < MSHFlexGrid1.FixedCols Then m_col = MSHFlexGrid1.FixedCols
MSHFlexGrid1.row = m_row: MSHFlexGrid1.col = m_col
If m_col = 1 Then
Command1.Visible = False
Command1.Move MSHFlexGrid1.Left + MSHFlexGrid1.CellLeft + MSHFlexGrid1.CellWidth - 300, _
MSHFlexGrid1.Top + MSHFlexGrid1.CellTop, _
300, _
MSHFlexGrid1.CellHeight - 20
Command1.Visible = True
Else
Command1.Visible = False
End If
If m_col <> 6 And m_col <> 5 And m_col <> 2 And m_col <> 8 And m_col <> 0 Then
Text2.Visible = False
Text2.Move MSHFlexGrid1.Left + MSHFlexGrid1.CellLeft, MSHFlexGrid1.Top + MSHFlexGrid1.CellTop, MSHFlexGrid1.CellWidth + 20, MSHFlexGrid1.CellHeight - 50
Text2.text = Trim(MSHFlexGrid1.text)
Text2.Visible = True
Text2.SetFocus
Else
Text2.Visible = False
End If
End Sub
Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then '如果是鼠标右键按下时
PopupMenu mnufile, 0, X, 3500 '弹出右键菜单
End If
End Sub
Private Sub Text2_Change()
If Len(Trim(Text2.text)) = 0 Then
Exit Sub
End If
If MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 1) = "" Then
MainForm.g_msgText = "请先选择一个商品名称!!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
Text2.text = ""
Exit Sub
Else
MSHFlexGrid1.TextMatrix(m_row, m_col) = Text2.text
If Not IsNumeric(MSHFlexGrid1.TextMatrix(m_row, 3)) And Trim(MSHFlexGrid1.TextMatrix(m_row, 3)) <> "" Then
MainForm.g_msgText = "你输入的格式有误,请输入一个数字 !!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
' Text2.SetFocus
Exit Sub
End If
If Not IsNumeric(MSHFlexGrid1.TextMatrix(m_row, 4)) And Trim(MSHFlexGrid1.TextMatrix(m_row, 4)) <> "" Then
MainForm.g_msgText = "你输入的格式有误,请输入一个数字 !!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
' Text2.SetFocus
Exit Sub
End If
If Trim(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 3)) <> "" Then
MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 5) = "¥" & CDbl(Trim(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 3)) * CDbl(Replace(Trim(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 4)), "¥", "")))
End If
If Trim(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 4)) <> "" And Trim(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 3)) <> "" Then
MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 5) = "¥" & CDbl(Trim(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 3)) * CDbl(Replace(Trim(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row, 4)), "¥", "")))
End If
End If
End Sub
Private Sub Text2_LostFocus()
Text2.Visible = False
End Sub
Private Sub Tlb_Action_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "xz" ' 新 增
Call clear
notenum.text = GetBillNo(2)
Case "bc" ' 保存采购订单记录
If Not Check Then ' 判断输入文本的内容
Exit Sub
End If
If Not judge_position1 Then
Exit Sub
End If
If stockorderlistsupplier.type_g = 0 Then ' 判断该页是否是从stockorderlistsupplier传过来的 0--表示是,1--表示否
Call savestockorderdetail0
Call clear
Text2.Visible = False
ElseIf stockorderlistsupplier.type_g = 1 Then
Call savestockorderdetail
Call clear
Text2.Visible = False
End If
Unload Me ' 退出窗体
Case "dy"
If stockorderlistsupplier.type_g = 0 Then ' 判断该页是否是从stockorderlistsupplier传过来的 0--表示是,1--表示否
If Not Check Then ' 判断输入文本的内容
Exit Sub
End If
Call savestockorderdetail0
PrintData (Trim(stockorderid.caption))
ElseIf stockorderlistsupplier.type_g = 1 Then
If Not Check Then ' 判断输入文本的内容
Exit Sub
End If
Call savestockorderdetail
Call clear
PrintData (Trim(stockorderid_d))
End If
Case "shsh"
If stockorderlistsupplier.type_g = 0 Then
Call shhe1
form_enabled
End If
Unload Me
Case "shqs"
If stockorderlistsupplier.type_g = 0 Then
Call qsh
form_enabled1
End If
Case "tc" ' 退 出
Unload Me
End Select
End Sub
Private Sub clear() ' 初始化窗体
notenum.text = GetBillNo(2)
notenum.Tag = GetBillNo(2)
suppliername.text = ""
inputdate.text = CDate(Trim(Date + Time()))
deliverydate.text = Format(Date, "yyyy-mm-dd")
superinrtendent.text = ""
phone.text = ""
memo.text = ""
counterman.text = Trim(MainForm.g_application.m_userName)
inputman.text = Trim(MainForm.g_application.m_userName)
shhe.text = ""
Text1.text = ""
Text1.Tag = ""
MSHFlexGrid1.clear
MSHFlexGrid1.Rows = 2
Call showform
Text2.text = ""
Command1.Visible = False
End Sub
Private Sub savestockorderdetail() '保存采购订单
Dim ret As Boolean
MainForm.g_application.m_databaseCon.m_adoConnection.BeginTrans
On Error GoTo EXITSUB
stockorderid_d = m_stockorderDAO.addstockorder(m_recordset, Trim(notenum.text), Trim(suppliername.text), _
CDate(inputdate.text), CDate(deliverydate.text), Trim(superinrtendent.text), Trim(phone.text), _
Trim(memo.text), Trim(counterman.text), Trim(inputman.text), 1)
For currentrow = 1 To MSHFlexGrid1.Rows - 1
If Trim(MSHFlexGrid1.TextMatrix(currentrow, 8)) <> "" Then
ret = m_stockorderDAO.addstockorderdetail(m_recordset, _
stockorderid_d, _
Trim(MSHFlexGrid1.TextMatrix(currentrow, 8)), _
Trim(MSHFlexGrid1.TextMatrix(currentrow, 2)), _
CDbl(Trim(MSHFlexGrid1.TextMatrix(currentrow, 3))), _
CDbl(Replace(Trim(MSHFlexGrid1.TextMatrix(currentrow, 4)), "¥", "")), _
CDbl(Replace(Trim(MSHFlexGrid1.TextMatrix(currentrow, 5)), "¥", "")), _
CDbl(Trim(MSHFlexGrid1.TextMatrix(currentrow, 6))), _
Trim(MSHFlexGrid1.TextMatrix(currentrow, 7)))
Else
End If
' k_ret = m_BomSupplierRelationDAO.SetMaterialSupplierPrice(Trim(MSHFlexGrid1.TextMatrix(currentrow, 8)), Trim(suppliername.text), _
CDbl(Trim(MSHFlexGrid1.TextMatrix(currentrow, 4))))
Next currentrow
MainForm.g_application.m_databaseCon.m_adoConnection.CommitTrans
Exit Sub
EXITSUB:
MainForm.g_application.m_databaseCon.m_adoConnection.RollbackTrans
Exit Sub
End Sub
Private Function Check() As Boolean '判断文本框内容的有效性
Check = True
If Len(Trim(deliverydate.text)) = 0 Then
MainForm.g_msgText = "交货日期不能为空!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
deliverydate.SetFocus
Check = False
Exit Function
End If
If Not IsDate(Trim(deliverydate.text)) Then
MainForm.g_msgText = "交货日期格式有错!"
HMsgBox MainForm.g_msgText, 0, 1
deliverydate.SetFocus
Check = False
Exit Function
End If
If Not IsDate(Trim(deliverydate.text)) Then
MainForm.g_msgText = "你输入的日期格式有错误?"
Call HMsgBox(MainForm.g_msgText, 0, 1)
Check = False
deliverydate.SetFocus
Exit Function
End If
If Len(Trim(suppliername.text)) = 0 Then
MainForm.g_msgText = "供应商名称不能为空!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
'suppliername.SetFocus
Check = False
Exit Function
End If
If stockorderlistsupplier.type_g = 0 Then
If CDate(deliverydate.text) < CDate(deliverydate.Tag) Then
MainForm.g_msgText = "交货日期比记录时间小!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
'deliverydate.SetFocus
Check = False
Exit Function
End If
ElseIf stockorderlistsupplier.type_g = 1 Then
If CDate(deliverydate.text) < Date Then
MainForm.g_msgText = "交货日期比当前时间小!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
deliverydate.SetFocus
Check = False
Exit Function
End If
End If
If Len(Trim(inputman.text)) = 0 Then
MainForm.g_msgText = "制单人不能为空!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
Check = False
Exit Function
End If
Dim o As Integer
For o = 1 To MSHFlexGrid1.Rows - 1
If Trim(MSHFlexGrid1.TextMatrix(o, 0)) <> "" Then
If Trim(MSHFlexGrid1.TextMatrix(o, 3)) = "" Then
MainForm.g_msgText = "数量不能为空!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
Check = False
Exit Function
End If
If CDbl(Trim(MSHFlexGrid1.TextMatrix(o, 3))) = 0 Then
MainForm.g_msgText = "数量不能为零!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
Check = False
Exit Function
End If
If Trim(MSHFlexGrid1.TextMatrix(o, 4)) = "" Then
MainForm.g_msgText = "单价不能为空!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
Check = False
Exit Function
End If
If CDbl(Trim(MSHFlexGrid1.TextMatrix(o, 4))) = 0 Then
MainForm.g_msgText = "单价不能为零!"
Call HMsgBox(MainForm.g_msgText, 0, 1)
Check = False
Exit Function
End If
Else
' MainForm.g_msgText = "您所填的信息不完整,请重新检查!"
' Call HMsgBox(MainForm.g_msgText, 0, 1)
' Check = False
' Exit Function
End If
Next o
If Trim(MSHFlexGrid1.TextMatrix(1, 8)) = "" Then
MsgBox "请输入一条记录,", vbOKOnly, "友好提示"
Check = False
Exit Function
End If
End Function
Private Sub goodsshow() '显示采购订单-商品记录
s_stockorderid = Trim(stockorderlistsupplier.stockorderid)
Dim ret As Boolean
ret = m_stockorderDAO.stockorderdetail_show(m_recordset, s_stockorderid)
jls = CDbl(m_recordset.RecordCount)
ReDim finishNum(jls) As Double
MSHFlexGrid1.clear
MSHFlexGrid1.Rows = 2
Call showform
With m_recordset
i = 1
Do While Not .EOF
If i > MSHFlexGrid1.Rows - 1 Then
MSHFlexGrid1.AddItem ""
End If
'[>>自定义填充内容
MSHFlexGrid1.TextMatrix(i, 0) = Trim(.Fields("stockorderdetailid")) '取一个采购订单明细的编号
MSHFlexGrid1.TextMatrix(i, 8) = Trim(.Fields("goodsid"))
MSHFlexGrid1.TextMatrix(i, 2) = Trim(.Fields("unit"))
MSHFlexGrid1.TextMatrix(i, 3) = Trim(.Fields("num"))
MSHFlexGrid1.TextMatrix(i, 4) = "¥" & Trim(.Fields("price"))
MSHFlexGrid1.TextMatrix(i, 5) = "¥" & Trim(.Fields("money"))
MSHFlexGrid1.TextMatrix(i, 6) = Trim(.Fields("finishnum"))
finishNum(i) = Trim(.Fields("finishnum"))
MSHFlexGrid1.TextMatrix(i, 7) = Trim(.Fields("memo"))
Dim ret1 As Boolean
ret1 = m_goodsDAO.name_goods(g_recordset, Trim(.Fields("goodsid")))
MSHFlexGrid1.TextMatrix(i, 1) = Trim(g_recordset.Fields("name"))
g_recordset.Close
'<<]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -