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

📄 frmpaycustomcard.frm

📁 金算盘软件代码
💻 FRM
字号:
VERSION 5.00
Object = "{F42BDC2B-FC9B-11D1-9ABD-444553540000}#4.0#0"; "ATLEDIT.OCX"
Begin VB.Form frmPayCustomCard 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "新增付款方 "
   ClientHeight    =   1515
   ClientLeft      =   2400
   ClientTop       =   2490
   ClientWidth     =   4545
   HelpContextID   =   10241
   Icon            =   "frmPayCustomCard.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form2"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1515
   ScaleWidth      =   4545
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin AtlEdit.TEdit txtWorkName 
      Height          =   285
      Left            =   330
      TabIndex        =   1
      Top             =   600
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   503
      maxchar         =   20
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Text            =   ""
   End
   Begin VB.CommandButton cmdOk 
      Height          =   350
      Index           =   2
      Left            =   3240
      Style           =   1  'Graphical
      TabIndex        =   4
      Tag             =   "1009"
      Top             =   900
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdOk 
      Cancel          =   -1  'True
      Height          =   350
      Index           =   1
      Left            =   3240
      Style           =   1  'Graphical
      TabIndex        =   3
      Tag             =   "1002"
      Top             =   510
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdOk 
      Height          =   350
      Index           =   0
      Left            =   3240
      Style           =   1  'Graphical
      TabIndex        =   2
      Tag             =   "1001"
      Top             =   120
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.Label lblWorkName 
      Caption         =   "付款方名称(&N)"
      Height          =   195
      Left            =   360
      TabIndex        =   0
      Top             =   360
      Width           =   1035
   End
End
Attribute VB_Name = "frmPayCustomCard"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'                 功能:      完成付款方的增、删、改。                              '
'                 卡片接口:             EditCard 参数: lngID 记录的ID号                        '
'                 作用:                          LNGID为零是增加记录、其它为编辑记录           '
'                                       DelCard 参数: lngID 记录的ID号                         '
'                 作用:                          删除ID号为LNGID的记录                         '
'                 作者:     苏涛                                                                            '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit

Private mblnIsInit As Boolean
Private mlngPayCustomerID As Long
Private mlngDPayCustomerID As Long                                   '合并目的ID
Private mblnIsNew As Boolean
Private mstrWorkName As String
Private mblnIsChanged As Boolean

Public Property Get getID() As Long
    getID = mlngPayCustomerID
End Property

Public Function DelCard(lngID As Long, Optional lnghWnd As Long = 0) As Boolean
    Dim recTemp As rdoResultset
    Dim strSql As String, strPayCustomer As String
    
    DelCard = False
    strSql = "SELECT  * FROM PayCustomer WHERE lngPayCustomerID= " & lngID
    Set recTemp = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
    If recTemp.EOF = True Then
        DelCard = True
        recTemp.Close
        Exit Function
    Else
        strPayCustomer = recTemp!strPayCustomerName
    End If
    recTemp.Close
    
    If CodeIsUsed(lngID) Then
        ShowMsg lnghWnd, "“" & strPayCustomer & "”付款方已经有业务发生,不能删除!", vbExclamation + MB_TASKMODAL, "删除付款方"
        Exit Function
    End If
  
    If ShowMsg(lnghWnd, "你确实要删除“" & strPayCustomer & "”付款方吗?", vbQuestion + vbYesNo + MB_TASKMODAL + vbDefaultButton2, _
        "删除付款方") = vbNo Then Exit Function
    strSql = "DELETE FROM PayCustomer WHERE lngPayCustomerID=" & lngID
    DelCard = gclsBase.ExecSQL(strSql)
    gclsSys.SendMessage CStr(Me.hwnd), Message.msgPayCustomer
End Function

Private Sub cmdOK_Click(Index As Integer)
    
    If Index = 0 Then
        If Not SaveCard Then Exit Sub
    ElseIf Index = 2 Then
        If SaveCard Then
'            mlngPayCustomerID = 0
            mblnIsNew = True
            mblnIsChanged = True
            InitCard
            txtWorkName.SetFocus
        End If
        Exit Sub
    End If
    Unload Me
End Sub

Private Sub Form_Activate()
    SetHelpID Me.HelpContextID
'  txtWorkName.SetFocus
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        BKKEY Me.ActiveControl.hwnd, vbKeyTab
    End If
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn And Shift = 2 Then
        cmdOk(0).Value = True
    End If
End Sub

Private Sub Form_Load()
    Dim edtErrReturn As ErrDealType
    
    On Error GoTo ErrHandle
'    SetHelpID hwnd, 10241
    Utility.LoadFormResPicture Me
    SendKeys "%{N}"
    Exit Sub
ErrHandle:
    edtErrReturn = Errors.ErrorsDeal
    
    If edtErrReturn = edtResume Then
         Resume
    Else
         On Error Resume Next
         Unload Me
    End If
End Sub
 
Public Function AddCard(Optional strName As String = "", Optional ByVal intModal As Integer = 0) As Long
    mlngPayCustomerID = 0
    mblnIsNew = True
    mblnIsChanged = True
    InitCard strName
    Show intModal
    AddCard = mlngPayCustomerID
End Function

Public Sub EditCard(ByVal lngID As Long, Optional intModal As Integer = 0, _
    Optional strPayCustomer As String)
    Dim strMess As String
    
    If Not CheckIDUsed("PayCustomer", "lngPayCustomerID", lngID) Then
        If Trim(strPayCustomer) <> "" Then
            strMess = "“" & strPayCustomer & "”"
        Else
            strMess = "该"
        End If
        ShowMsg 0, strMess & "付款方不存在,不能进行修改!", vbExclamation + MB_TASKMODAL, "修改付款方"
        Unload Me
    Else
        mlngPayCustomerID = lngID
        mblnIsNew = False
        InitCard
        Caption = "修改付款方"
        cmdOk(2).Visible = False
        Show intModal
    End If
End Sub

Private Sub InitCard(Optional strName As String = "")
   Dim recWorkName As rdoResultset, strSql As String
   
   mblnIsInit = True
   mlngDPayCustomerID = 0
   If Not mblnIsNew Then
        strSql = "SELECT * FROM PayCustomer WHERE lngPayCustomerID=" & mlngPayCustomerID
        Set recWorkName = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
        mstrWorkName = recWorkName!strPayCustomerName
        txtWorkName.Text = mstrWorkName
        recWorkName.Close
    Else
        txtWorkName.Text = Trim(strName)
    End If
    mblnIsInit = False
End Sub

Private Sub Form_Paint()
    FrameBox Me.hwnd, 120, 120, 3070, 1320
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Dim intMsgReturn As Integer, strMess As String
    
    If UnloadMode <> vbFormControlMenu Then Exit Sub
    If Trim(txtWorkName.Text) = "" Then Exit Sub
    If mblnIsChanged Then
        If mblnIsNew Then
            strMess = "您要保存新增的付款方“" & txtWorkName.Text & "”吗?"
        Else
            strMess = "“" & txtWorkName.Text & "”" & "付款方已被修改,是否保存?"
        End If
        intMsgReturn = ShowMsg(hwnd, strMess, vbQuestion + vbYesNoCancel, Caption)
        If intMsgReturn = vbYes Then
            Cancel = Not SaveCard
        ElseIf intMsgReturn = vbCancel Then
            Cancel = True
        End If
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    mblnIsChanged = False
    Utility.UnLoadFormResPicture Me
End Sub

Private Sub txtWorkName_Change()
    If ContainErrorChar(txtWorkName.Text) Then BKKEY txtWorkName.hwnd
    If Not mblnIsInit Then mblnIsChanged = True
End Sub

Private Function CodeCheck() As Boolean
    Dim recPayCustomer As rdoResultset, strSql As String
    
    strSql = "SELECT * FROM PayCustomer WHERE strPayCustomerName= '" & txtWorkName.Text _
        & "' AND lngPayCustomerID<>" & IIf(mblnIsNew, 0, mlngPayCustomerID)
    Set recPayCustomer = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
    If recPayCustomer.EOF Then
        CodeCheck = True
    Else
        CodeCheck = False
        mlngDPayCustomerID = recPayCustomer!lngPayCustomerID
    End If
    recPayCustomer.Close
End Function

Private Function MergeCode() As Boolean
    
    MergeCode = False
    If Not DisplaceActivity("Business", "lngPayCustomerID", mlngDPayCustomerID, mlngPayCustomerID) Then Exit Function
    If Not DisplaceActivity("BusinessAddress", "lngPayCustomerID", mlngDPayCustomerID, mlngPayCustomerID) Then Exit Function
    If Not DisplaceActivity("Customer", "lngPayCustomerID", mlngDPayCustomerID, mlngPayCustomerID) Then Exit Function
    If Not DisplaceActivity("CustomerAddress", "lngPayCustomerID", mlngDPayCustomerID, mlngPayCustomerID) Then Exit Function
    If Not DisplaceActivity("Employee", "lngPayCustomerID", mlngDPayCustomerID, mlngPayCustomerID) Then Exit Function
    MergeCode = True
End Function

Private Function SaveCard() As Boolean
    Dim recPayCustomer As rdoResultset, strSql As String
    
    SaveCard = False
    If Not mblnIsChanged Then
        SaveCard = True
        Exit Function
    End If
    On Error GoTo ErrHandle
    gclsBase.BaseWorkSpace.BeginTrans
    
    If txtWorkName.Text = "" Then
        ShowMsg hwnd, "付款方不能为空!", vbExclamation + MB_TASKMODAL, Caption
        GoTo ErrHandle
    End If
     
    If CodeCheck Then
        If mblnIsNew Then
            mlngPayCustomerID = GetNewID("PayCustomer")
            strSql = "INSERT INTO PayCustomer(lngPayCustomerID,strPayCustomerName) VALUES(" _
                & mlngPayCustomerID & ",'" & Trim(txtWorkName.Text) & "')"
            If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
'            strSql = "SELECT * FROM PayCustomer WHERE strPayCustomerName='" _
'                & Trim(txtWorkName.Text) & "'"
'            Set recPayCustomer = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
'            mlngPayCustomerID = recPayCustomer!lngPayCustomerID
'            recPayCustomer.Close
        Else
            strSql = "UPDATE PayCustomer SET strPayCustomerName='" & Trim(txtWorkName.Text) _
                & "' WHERE lngPayCustomerID=" & mlngPayCustomerID
            If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
        End If
    Else
        If mblnIsNew Then
            ShowMsg hwnd, "付款方“" & txtWorkName.Text & "”已经存在,请重新录入!", _
                vbExclamation + MB_TASKMODAL, Caption
            GoTo ErrHandle
        Else
            If ShowMsg(hwnd, "是否将付款方“" & mstrWorkName & "”与“" & txtWorkName.Text _
                & "”进行合并?", vbQuestion + vbYesNo + MB_TASKMODAL, Caption) = vbNo Then
                GoTo ErrHandle
            Else
                If Not MergeCode Then GoTo ErrHandle
                strSql = "DELETE FROM PayCustomer WHERE lngPayCustomerID=" & mlngPayCustomerID
                If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
            End If
        End If
    End If
    gclsBase.BaseWorkSpace.CommitTrans
    SaveCard = True
    mblnIsChanged = False
    Exit Function
    gclsSys.SendMessage CStr(Me.hwnd), Message.msgPayCustomer
ErrHandle:
    gclsBase.BaseWorkSpace.RollBacktrans
End Function

Private Function CodeIsUsed(ByVal lngID As Long) As Boolean
    
    CodeIsUsed = True
    If CheckIDUsed("VoucherDetail", "lngPayCustomerID", lngID) Then Exit Function
    CodeIsUsed = False
End Function

Private Sub txtWorkName_KeyPress(KeyAscii As Integer)
    If InStr("`~!@#$%^&*=+' "";:,./?|\", Chr(KeyAscii)) > 0 Then KeyAscii = 0
End Sub

⌨️ 快捷键说明

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