需求:单据保存启动多级审核后,后面的审批人能够修改单价和备注,金额=数量*单价自动计算
演示效果:
点击按钮【修改单价】
跳出弹框,可以输入要修改的【单价】和【备注】,由于表体可能多条,所以当前选中哪行,就修改哪行
点击【确认】,数值便更新到对应的表体,金额自动计算
再次点【修改单价】按钮,表体原本的值会显示在弹框中
附源码:
类模块:Industry_PlugIns.cls
'定义插件对象接口. 必须具有的声明, 以此来获得事件 Private WithEvents m_BillTransfer As k3BillTransfer.Bill Public Sub Show(ByVal oBillTransfer As Object) '接口实现 '注意: 此方法必须存在, 请勿修改 Set m_BillTransfer = oBillTransfer End Sub Private Sub Class_Terminate() '释放接口对象 '注意: 此方法必须存在, 请勿修改 Set m_BillTransfer = Nothing End Sub Private Sub m_BillTransfer_BillInitialize() 'TODO: 请在此处添加代码响应事件 BillInitialize '*************** 开始设置菜单 *************** m_BillTransfer.AddUserMenuItem "修改单价", "自定义菜单" m_BillTransfer.AddUserMenuItem "刷新", "自定义菜单" '*************** 结束设置菜单 *************** End Sub Private Sub m_BillTransfer_BillTerminate() 'TODO: 请在此处添加代码响应事件 BillTerminate End Sub Private Sub m_BillTransfer_LeveCell(ByVal Col As Long, ByVal Row As Long, ByVal NewCol As Long, ByVal NewRow As Long, Cancel As Boolean) 'TODO: 请在此处添加代码响应事件 LeveCell If (NewRow > 0) Then currow = NewRow End If End Sub Private Sub m_BillTransfer_UserMenuClick(ByVal Index As Long, ByVal Caption As String) Dim THeadCtl As Variant Dim i As Long Dim str As String Dim state As String Dim rs As New ADODB.Recordset stateCur = "False" 'TODO: 请在此处添加代码响应事件 UserMenuClick Set rs = New ADODB.Recordset Select Case Caption Case "修改单价" '此处添加处理 修改单价 菜单对象的 Click 事件 connString = m_BillTransfer.Cnnstring THeadCtl = m_BillTransfer.HeadCtl For i = 1 To UBound(THeadCtl) If (UCase(THeadCtl(i).FieldName) = "FBILLNO") Then curBillNo = m_BillTransfer.Head(i).Text End If Next If Len(curBillNo) > 0 Then '判断审核人 sql = "select FMULTICHECKSTATUS from PORequest where FBillNo='" + curBillNo + "'" rs.Open sql, connString, 0, 1 state = rs.Fields(0).Value End If If state <> 2 Then PriceForm.Show 1 ' 刷新 If (stateCur = "True") Then m_BillTransfer.BillFunc.refillbill End If Else MsgBox "操作失败,必须审核后才能操作!" End If Case "刷新" '此处添加处理 刷新 菜单对象的 Click 事件 m_BillTransfer.BillFunc.refillbill Case Else End Select End Sub
窗体:PriceForm.frm
Private Sub Command1_Click() Dim rs As New ADODB.Recordset Dim sql As String Set rs = New ADODB.Recordset ' 测试,确认后修改备注 sql = "update PORequestentry set FEntrySelfP0133=" + Trim(Val(Text1.Text)) + ", FEntrySelfP0132='" + Text2.Text + "',FEntrySelfP0134=" + Trim(Trim(Val(Text1.Text)) * Trim(Val(Text3.Text))) + " from PORequestentry t_1 left join PORequest t_2 on t_1.FInterID=t_2.FInterID where FBillNo='" + curBillNo + "' and FEntryID=" + Trim(currow) rs.Open sql, connString, 0, 1 stateCur = "True" '确认 Unload PriceForm End Sub Private Sub Command2_Click() stateCur = "False" '取消 Unload PriceForm End Sub Private Sub Form_Load() Dim rs As New ADODB.Recordset Dim sql As String Set rs = New ADODB.Recordset sql = "select isnull(FEntrySelfP0133,0.000),isnull(FEntrySelfP0132,0),isnull(FQty,0) from PORequestentry t_1 left join PORequest t_2 on t_1.FInterID=t_2.FInterID where FBillNo='" + curBillNo + "' and FEntryID=" + Trim(currow) rs.Open sql, connString, 0, 1 If Not rs.EOF Then Text1.Text = rs.Fields(0).Value Text2.Text = rs.Fields(1).Value Text3.Text = rs.Fields(2).Value End If rs.Close Label1.Caption = "单据编码:" + curBillNo + ",当前选中行是:" + Trim(currow) End Sub '判断是否为数字 Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < Asc(".") And KeyAscii <> Asc(".") Or KeyAscii > Asc("9") And KeyAscii <> Asc(".") Or KeyAscii = Asc("/") Then KeyAscii = 0 '取消字符。 End If End Sub Private Sub Text1_Click() Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) End Sub Private Sub Text2_Click() Text2.SelStart = 0 Text2.SelLength = Len(Text2.Text) End Sub Private Sub Text3_Click() Text3.SelStart = 0 Text3.SelLength = Len(Text3.Text) End Sub
模块:Common.bas
Public currow As Long Public curBillNo As String Public connString As String Public stateCur As String