⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ˪-i㦥

📁 VB开发的ERP系统
💻
📖 第 1 页 / 共 2 页
字号:
            End If
            TextChangeLock = False
    End Select

   
    ']以上为依据实际情况自定义部分
  
End Sub

Private Sub LrText_Change(Index As Integer)
    
    '屏蔽程序改变控制
    If TextChangeLock Then
        Exit Sub
    End If
    
    TextValiJudgeLock(Index) = False    '打开有效性判断锁
    
    '限制字段录入长度
          
    TextChangeLock = True  '加锁(防止执行Lrtext_Change)
     
    Select Case Textint(Index, 1)
        Case 8, 11      '金额型
            Call Sjgskz(LrText(Index), Xtjezws - Xtjexsws - 1, Xtjexsws)
        Case 9, 12      '数量型
            Call Sjgskz(LrText(Index), Xtslzws - Xtslxsws - 1, Xtslxsws)
        Case 10          '单价型
            Call Sjgskz(LrText(Index), Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
        Case Else        '其他小数类型控制
            If Textint(Index, 6) <> 0 Or Textint(Index, 7) <> 0 Then
                Call Sjgskz(LrText(Index), Textint(Index, 6), Textint(Index, 7))
            End If
    End Select
        
    TextChangeLock = False '解锁

End Sub

Private Sub LrText_GotFocus(Index As Integer)                                                 '文本框得到焦点,显示相应信息
    
    Call TextShow(Index)
    CurTextIndex = Index
    LrText(Index).SelStart = Len(LrText(Index))

End Sub

Private Sub LrText_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)            '字段按F2键提供帮助
    
    Select Case KeyCode
        Case vbKeyF2
            Call Text_Help(Index)
    End Select

End Sub

Private Sub LrText_KeyPress(Index As Integer, KeyAscii As Integer)                            '文本框录入事中控制
    Call InputFieldLimit(LrText(Index), Textint(Index, 1), KeyAscii)
End Sub

Private Sub LrText_LostFocus(Index As Integer)                                                '文本框失去焦点

  '显示相应信息但不能进行有效性判断
  Call Wbklrwbcl(Index)
End Sub

Private Sub Ydcommand1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)     '按钮提供帮助
    Call Text_Help(Index)
End Sub

Private Sub Text_Help(Index As Integer)                                                       '录入字段帮助
    If Not Textboolean(Index, 1) Then
        Exit Sub
    End If
     
    '调用帮助
    Call Drbmhelp(Textint(Index, 2), Textstr(Index, 4), Trim(LrText(Index).Text))
  
    '根据设置选择显示编码和名称,并进行存储
    If Len(Xtfhcs) <> 0 Then
        If Textint(Index, 3) = 1 Then
            LrText(Index).Text = Xtfhcsfz
            LrText(Index).Tag = Xtfhcs
        Else
            LrText(Index).Text = Xtfhcs
            LrText(Index).Tag = Xtfhcsfz
        End If
    End If
   
    LrText(Index).SetFocus

End Sub

Private Sub TextShow(Index As Integer)        '文本框得到焦点,显示相应信息

  '填写文本框得到焦点,进行相应信息处理程序
   
End Sub

Private Sub Wbkcsh()                          '录入文本框初始化
  
    Dim jsqte As Integer
  
    '最大录入文本框索引值
    Max_Text_Index = Textvar(1)
  
    ReDim TextValiJudgeLock(Max_Text_Index)
    For jsqte = 0 To Max_Text_Index
         
        If Len(Trim(Textstr(jsqte, 1))) <> 0 Then
            If Textboolean(jsqte, 1) Then
                If jsqte <> 0 And Not Textboolean(jsqte, 3) Then
                    Load Ydcommand1(jsqte)
                End If
                Ydcommand1(jsqte).Visible = True
                Ydcommand1(jsqte).Move LrText(jsqte).Left + LrText(jsqte).Width, LrText(jsqte).Top
            End If
            TextChangeLock = True
            LrText(jsqte).Text = ""
            LrText(jsqte).Tag = ""
            If Textint(jsqte, 5) <> 0 Then
                LrText(jsqte).MaxLength = Textint(jsqte, 5)
            End If
            TextChangeLock = False
        End If
        If Textboolean(jsqte, 5) = False Then
            LrText(jsqte).Enabled = False
        End If
        TextValiJudgeLock(jsqte) = True
    Next jsqte

End Sub

Private Function TextYxxpd(Index As Integer) As Boolean           '文本框有效性判断
    Dim Sqlstr As String
    Dim Findrec As ADODB.Recordset
  
    '文本框内容未曾改变不进行有效性判断
    If TextValiJudgeLock(Index) Then
        TextYxxpd = True
        Exit Function
    End If
  
    '文本框内容为空认为有效,并清空其Tag值
    If Trim(LrText(Index)) = "" Then
        LrText(Index).Tag = ""
        Call Wbklrwbcl(Index)
        TextValiJudgeLock(Index) = True
        TextYxxpd = True
        Exit Function
    End If
  
    '可在此加入不做有效性判断的理由
  
    Select Case Textint(Index, 4)
        Case 1      '编码型
            Sqlstr = Trim(Textstr(Index, 5))
            Sqlstr = Replace(Sqlstr, "@", "'" + Trim(LrText(Index).Text) + "'")
            Set Findrec = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
            If Findrec.EOF Then
                Call Xtxxts(Trim(Textstr(Index, 6)), 0, 1)
                LrText(Index).SetFocus
                Exit Function
            Else
                Select Case Textint(Index, 3)
                    Case 0
                        If Len(Trim(Textstr(Index, 2))) <> 0 Then
                            LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
                        End If
                        If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
                            LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
                        End If
                    Case 1
                        If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
                            LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
                        End If
                        If Len(Trim(Textstr(Index, 2))) <> 0 Then
                            LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
                        End If
                End Select
            End If
        Case 2      '日期型
            If IsDate(LrText(Index).Text) Then
                LrText(Index).Text = Format(LrText(Index).Text, "yyyy-mm-dd")
                If Val(Mid(LrText(Index), 1, 4)) < 1900 Then
                    LrText(Index).Text = "1900" + Mid(LrText(Index), 5, 6)
                End If
            Else
                Tsxx = "非法公历日期!(格式:" + Format(Date, "yyyy-mm-dd") + ")"
                Call Xtxxts(Tsxx, 0, 1)
                LrText(Index).SetFocus
                Exit Function
            End If
        Case 3      '其他类型
    End Select
    
    '如果有效则加锁,用户不改变内容则不再进行有效性判断
    TextValiJudgeLock(Index) = True

    '调用文本框事后处理程序
    Call Wbklrwbcl(Index)
  
    '有效性判断通过则返回True
    TextYxxpd = True
   
End Function
Private Sub ShowBill()
    '调入用户查询结果动态集,并定位该单据
    Sqlstr = "SELECT dbo.RP_Note.*, dbo.Gy_ForeignCurrency.ForeignCurrName AS ForeignCurrName " & _
            "FROM dbo.Gy_ForeignCurrency INNER JOIN  dbo.RP_Note ON " & _
            "dbo.Gy_ForeignCurrency.ForeignCurrCode = dbo.RP_Note.ForeignCurrCode where NoteId='" & XT_BillID & "'"
    Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
    LrText(0).Text = RecTemp.Fields("NoteCode")
    LrText(1).Text = RecTemp.Fields("YbSsJe") + Val(RecTemp.Fields("YbInterest") & "") '票面+利息
    LrText(3).Text = Xtrq
    LrText(2).Tag = RecTemp.Fields("ForeignCurrCode")
    LrText(2).Text = RecTemp.Fields("ForeignCurrName")
    Call Sub_GetAccRate(LrText(2).Tag, Bln_ConVertFlag, Dbl_AccRate)    '取外币记帐汇率,和汇兑方式
    LrText(5).Text = Dbl_AccRate
End Sub

Private Function SaveBill()                   '存储背书数据
    Dim Rec_Bill As New ADODB.Recordset
    Dim jsqte As Integer
    Dim Int_Kjyear As Integer                 '会计年度
    Dim Int_Period As Integer                 '会计期间
    Dim JE As Double                          '背书金额
    
    '保存其它应付单用变量
    Dim BillCode As String                   '其它应付单单据代码
    Dim OtherBillCode As String              '其它应付单编码
    Dim OtherBillId As Integer               '其它应付单ID
    Dim RecTemp As New ADODB.Recordset
    SaveBill = False
    '一.============先对单据内容进行有效性判断==============='
  
    '先进行字段不能为空或不能为零有效性判断(Fixed)
    For jsqte = 0 To Max_Text_Index
        If Textint(jsqte, 8) = 1 Then     '字段不能为空
            If Len(Trim(LrText(jsqte).Text)) = 0 Then
                Tsxx = Textstr(jsqte, 7) & "不能为空!"
                Call Xtxxts(Tsxx, 0, 1)
                LrText(jsqte).SetFocus
                Exit Function
            End If
        Else
            If Textint(jsqte, 8) = 2 Then   '字段不能为零
                If Val(Trim(LrText(jsqte).Text)) = 0 Then
                    Tsxx = Textstr(jsqte, 7) & "不能为零!"
                    Call Xtxxts(Tsxx, 0, 1)
                    LrText(jsqte).SetFocus
                    Exit Function
                End If
            End If
        End If
    Next jsqte
    
  
    '[>>
        '1.判断单据日期是否有效,如有效同时记录会计年度和会计期间
    If Not Fun_GetPeriod(CDate(Format(LrText(3).Text, "yyyy-mm-dd")), Int_Kjyear, Int_Period) Then
        LrText(3).SetFocus
        Exit Function
    End If
        '2.判断汇率
    If Trim(LrText(2).Tag) <> XtSCurrCode Then
       If Val(LrText(5).Text) = 0 Then
          Tsxx = "汇率不能为零!"
          Call Xtxxts(Tsxx, 0, 1)
          LrText(5).SetFocus
          Exit Function
       End If
    Else
       LrText(5).Text = 1
    End If
    
    '<<]
    Sqlstr = "SELECT * From Rp_Note where NoteId='" & XT_BillID & "'"
    Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)

    
   '2.开始存盘
    
    On Error GoTo Swcwcl
    Cw_DataEnvi.DataConnect.BeginTrans
    
    Sqlstr = "SELECT * From Rp_Note where NoteId='" & XT_BillID & "'"
    Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)

    '增加一张付款结算单
    If OptType(0).Value = True Then                                   '按冲销应付款方式背书
 
        Sqlstr = "Select * from RP_Note Where NoteId='" & XT_BillID & "'"
        Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
    
        BillCode = "0304"   '付款结算单编号
        OtherBillCode = CreatBillCode(BillCode, True) '
        OtherBillId = CreatBillID(BillCode)
    
        If Rec_Bill.State = 1 Then Rec_Bill.Close
        Rec_Bill.Open "Select * From Rp_CloseBill Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
        With Rec_Bill
            .AddNew
            .Fields("CloseBillID") = OtherBillId                                      '单据ID
            .Fields("BillCode") = OtherBillCode                                       '单据编号
            .Fields("SourceBillCode") = Trim(LrText(0).Text)                          '形成该应收单的单据号
            .Fields("BillDate") = CDate(LrText(3).Text)                               '单据日期
            .Fields("ForeignCurrCode") = Trim(LrText(2).Tag)                          '币别编码
            .Fields("YbSsJe") = Val(LrText(6).Text)                                   '背书金额
            .Fields("AccRate") = Val(LrText(5).Text)                                  '汇率
            If Bln_ConVertFlag Then
                .Fields("BbSsJe") = Val(Format(Val(LrText(6).Text) / Val(LrText(5).Text), "##." + String(Xtjexsws, "0")))
            Else
                .Fields("BbSsJe") = Val(Format(Val(LrText(6).Text) * Val(LrText(5).Text), "##." + String(Xtjexsws, "0")))
            End If
            
            .Fields("PsCode") = LrText(4).Tag                                         '背书单位编码
        
            .Fields("DeptCode") = RecTemp.Fields("DeptCode")                          '部门编码
            .Fields("PersonCode") = RecTemp.Fields("PersonCode")                      '经办人编码
            .Fields("Digest") = Trim((LrText(8).Text) & "") & "应收票据背书" & Trim(LrText(0).Text)                           '摘要"
            .Fields("Maker") = Xtczy                                                  '制单人
            
            '系统自动保存应付帐款科目
            .Fields("AccCodeArAp") = LrText(7).Tag
            '应收票据科目
            If .Fields("BillItemCode") = "01" Then
                .Fields("AccCode") = Fun_GetInputCode("AR_CommNoteAccCode")           '商业承兑汇票科目
            Else
                .Fields("AccCode") = Fun_GetInputCode("AR_BankNoteAccCode")           '银行承兑汇票科目
            End If
            
            '后台处理
            .Fields("RPFlag") = "AP"                                                  '应付标识
            .Fields("KJYear") = Int_Kjyear                                            '会计年度
            .Fields("Period") = Int_Period                                            '会计期间
            .Fields("BillItemCode") = "90"                                            '单据类型编码
            .Fields("VouchId") = 0                                                    '凭证关联标识
            .Fields("IfBuildVouch") = 1   '目的是该付款结算单在“选择应付单做凭证时不被选中”是否生成凭证
            .Fields("OverStatus") = 0
            .Update
        End With
    End If


    
    '写入变动单据表
    If Rec_Bill.State = 1 Then Rec_Bill.Close
    Rec_Bill.Open "Select * From Rp_NoteClose Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
    With Rec_Bill
        .AddNew
        .Fields("NoteId") = XT_BillID                      '单据号
        .Fields("CloseDate") = CDate(LrText(3).Text)       '背书日期
        .Fields("EndorseCusCode") = Trim(LrText(4).Tag)    '背书单位
        .Fields("ForeignCurrCode") = Trim(LrText(2).Tag)   '原币编码
        .Fields("YbCash") = Val(Trim(LrText(6).Text))      '原币背书金额
        .Fields("AccRate") = Val(Trim(LrText(5).Text))     '记帐汇率
        .Fields("PsCode") = RecTemp.Fields("PsCode")       '客户编码
        .Fields("Digest") = Trim(LrText(8).Text)           '备注
        If Bln_ConVertFlag Then                            '本币背书金额
            .Fields("BbCash") = Val(Format(Val(LrText(6).Text) / Val(LrText(5).Text), "##." + String(Xtjexsws, "0")))
        Else
            .Fields("BbCash") = Val(Format(Val(LrText(6).Text) * Val(LrText(5).Text), "##." + String(Xtjexsws, "0")))
        End If
        .Fields("DeptCode") = Trim(RecTemp.Fields("DeptCode") & "")       '部门编码
        .Fields("PersonCode") = Trim(RecTemp.Fields("PersonCode") & "")   '经办人编码
        .Fields("AccCodeNote") = Trim(RecTemp.Fields("AccCode") & "")     '应收票据科目
        .Fields("AccCode") = LrText(7).Tag                                '背书科目编码
        
        
        '系统名
        .Fields("RPFlag") = "Ar"
        
        '单据所属的会计期间
        .Fields("KjYear") = Int_Kjyear
        .Fields("Period") = Int_Period
        
        '单据类型
        .Fields("BillItemCode") = "43"
        
        
        '票据利息科目
        .Fields("AccCodeInterest") = Fun_GetInputCode("AR_NoteIntAccCode")  '承兑利息科目
        
        '票据费用科目
        .Fields("AccCodeExpense") = Fun_GetInputCode("AR_NoteFareAccCode")
        .Fields("BillIDAp") = OtherBillId
        .Update
        
        '系统读出单据ID写入Lab_BillID
    End With
    
    
            
    Cw_DataEnvi.DataConnect.CommitTrans
    Tsxx = "保存完毕!"
    SaveBill = True
    Call Xtxxts(Tsxx, 0, 4)
    Exit Function
Swcwcl:       '数据存盘时出现错误
    Cw_DataEnvi.DataConnect.RollbackTrans
    Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
    Call Xtxxts(Tsxx, 0, 1)
    Exit Function
        
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -