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

📄 frmjobstatuscard.frm

📁 金算盘软件代码
💻 FRM
字号:
VERSION 5.00
Object = "{F42BDC2B-FC9B-11D1-9ABD-444553540000}#4.0#0"; "ATLEDIT.OCX"
Begin VB.Form frmJobStatusCard 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "新增工程状态"
   ClientHeight    =   1740
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4710
   HelpContextID   =   23001
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1740
   ScaleWidth      =   4710
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin AtlEdit.TEdit txtJobStatus 
      Height          =   285
      Left            =   390
      TabIndex        =   1
      Top             =   780
      Width           =   2385
      _ExtentX        =   4207
      _ExtentY        =   503
      maxchar         =   12
      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 
      Cancel          =   -1  'True
      Height          =   350
      Index           =   1
      Left            =   3240
      Style           =   1  'Graphical
      TabIndex        =   3
      Tag             =   "1002"
      Top             =   600
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdOK 
      Height          =   350
      Index           =   0
      Left            =   3240
      Style           =   1  'Graphical
      TabIndex        =   2
      Tag             =   "1001"
      Top             =   210
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdOK 
      Height          =   350
      Index           =   2
      Left            =   3240
      Style           =   1  'Graphical
      TabIndex        =   4
      Tag             =   "1009"
      Top             =   990
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.Label lblTitle 
      Caption         =   "工程状态(&S)"
      Height          =   285
      Left            =   390
      TabIndex        =   0
      Top             =   510
      Width           =   1305
   End
End
Attribute VB_Name = "frmJobStatusCard"
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 mblnIsList As Boolean
Private mlngJobStatusID As Long
Private mlngDJobStatusID As Long                                   '合并目的ID
Private mblnIsNew As Boolean
Private mstrJobStatus As String
Private mblnIsChanged As Boolean

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

Public Function DelCard(lngID As Long, Optional lnghWnd As Long = 0) As Boolean
    Dim recTemp As rdoResultset
    Dim strSql As String, strJobStatus As String
    
    DelCard = False
    strSql = "SELECT * FROM JobStatus WHERE lngJobStatusID= " & lngID
    Set recTemp = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
    If recTemp.EOF = True Then
        DelCard = True
        recTemp.Close
        Exit Function
    Else
        strJobStatus = recTemp!strJobStatusName
    End If
    recTemp.Close
    
    If CodeIsUsed(lngID) Then
        ShowMsg lnghWnd, "“" & strJobStatus & "”工程状态已经有业务发生,不能删除!", vbExclamation + MB_TASKMODAL, "删除工程状态"
        Exit Function
    End If
  
    If ShowMsg(lnghWnd, "你确实要删除“" & strJobStatus & "”工程状态吗?", vbQuestion + vbYesNo + MB_TASKMODAL + vbDefaultButton2, _
        "删除工程状态") = vbNo Then Exit Function
    strSql = "DELETE FROM JobStatus WHERE lngJobStatusID=" & lngID
    DelCard = gclsBase.ExecSQL(strSql)
    gclsSys.SendMessage hwnd, Message.msgJobStatus
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
            mlngJobStatusID = 0
            mblnIsNew = True
            mblnIsChanged = True
            InitCard
            txtJobStatus.SetFocus
            Exit Sub
        End If
    End If
    Unload Me
End Sub

Private Sub Form_Activate()
    SetHelpID Me.HelpContextID
  mstrJobStatus = txtJobStatus.Text
'  txtJobStatus.SetFocus
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If mblnIsList Then
        mblnIsList = False
        Exit Sub
    End If
    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, 23001
    Utility.LoadFormResPicture Me
'    SendKeys "%{S}"
    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, _
    Optional ByVal IsList As Boolean = False) As Long
    mlngJobStatusID = 0
    mblnIsNew = True
    mblnIsChanged = True
    mblnIsList = IsList
    InitCard strName
    Show intModal
    AddCard = mlngJobStatusID
End Function

Public Sub EditCard(ByVal lngID As Long, Optional intModal As Integer = 0, _
    Optional strJobStatus As String)
    Dim strMess As String
    
    If Not CheckIDUsed("JobStatus", "lngJobStatusID", lngID) Then
        If Trim(strJobStatus) <> "" Then
            strMess = "“" & strJobStatus & "”"
        Else
            strMess = "该"
        End If
        ShowMsg 0, strMess & "工程状态不存在,不能进行修改!", vbExclamation + MB_TASKMODAL, "修改工程状态"
        Unload Me
    Else
        mlngJobStatusID = lngID
        mblnIsNew = False
        InitCard
        Caption = "修改工程状态"
        cmdOk(2).Visible = False
        Show intModal
    End If
End Sub

Private Sub InitCard(Optional strName As String = "")
   Dim recJobStatus As rdoResultset, strSql As String
   
   mblnIsInit = True
   mlngDJobStatusID = 0
   If Not mblnIsNew Then
        strSql = "SELECT * FROM JobStatus WHERE lngJobStatusID=" & mlngJobStatusID
        Set recJobStatus = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
        mstrJobStatus = recJobStatus!strJobStatusName
        txtJobStatus.Text = mstrJobStatus
        recJobStatus.Close
    Else
        txtJobStatus.Text = Trim(strName)
    End If
    mblnIsInit = False
End Sub

Private Sub Form_Paint()
    FrameBox Me.hwnd, 210, 180, 3045, 1485
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(txtJobStatus.Text) = "" Then Exit Sub
    If mblnIsChanged Then
        If mblnIsNew Then
            strMess = "您要保存新增的工程状态“" & txtJobStatus.Text & "”吗?"
        Else
            strMess = "“" & txtJobStatus.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 txtJobStatus_Change()
    If ContainErrorChar(txtJobStatus.Text, "'`~*@#$|") Then BKKEY txtJobStatus.hwnd
    If Not mblnIsInit Then mblnIsChanged = True
End Sub

Private Function CodeCheck() As Boolean
    Dim recJobStatus As rdoResultset, strSql As String
    
    strSql = "SELECT * FROM JobStatus WHERE strJobStatusName= '" & txtJobStatus.Text _
        & "' AND lngJobStatusID<>" & IIf(mblnIsNew, 0, mlngJobStatusID)
    Set recJobStatus = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
    If recJobStatus.EOF Then
        CodeCheck = True
    Else
        CodeCheck = False
        mlngDJobStatusID = recJobStatus!lngJobStatusID
    End If
    recJobStatus.Close
End Function

Private Function MergeCode() As Boolean
    
    MergeCode = False
    If Not DisplaceActivity("Job", "lngJobStatusID", mlngDJobStatusID, mlngJobStatusID) Then Exit Function
    MergeCode = True
End Function

Private Function SaveCard() As Boolean
    Dim recJobStatus 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 txtJobStatus.Text = "" Then
        ShowMsg hwnd, "工程状态不能为空!", vbExclamation, Caption
        GoTo ErrHandle
    End If
     
    If CodeCheck Then
        If mblnIsNew Then
            mlngJobStatusID = GetNewID("JobStatus")
            strSql = "INSERT INTO JobStatus(lngJobStatusID,strJobStatusName) VALUES(" _
                & mlngJobStatusID & ",'" & Trim(txtJobStatus.Text) & "')"
            If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
            strSql = "SELECT * FROM JobStatus WHERE strJobStatusName='" _
                & Trim(txtJobStatus.Text) & "'"
'            Set recJobStatus = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
'            mlngJobStatusID = recJobStatus!lngJobStatusID
'            recJobStatus.Close
        Else
            strSql = "UPDATE JobStatus SET strJobStatusName='" & Trim(txtJobStatus.Text) _
                & "' WHERE lngJobStatusID=" & mlngJobStatusID
            If Not gclsBase.ExecSQL(strSql) Then GoTo ErrHandle
        End If
    Else
        If mblnIsNew Then
            ShowMsg hwnd, "工程状态“" & txtJobStatus.Text & "”已经存在,请重新录入!", _
                vbExclamation, Caption
            GoTo ErrHandle
        Else
            If ShowMsg(hwnd, "是否将工程状态“" & mstrJobStatus & "”与“" & txtJobStatus.Text _
                & "”进行合并?", vbQuestion + vbYesNo, Caption) = vbNo Then
                GoTo ErrHandle
            Else
                If Not MergeCode Then GoTo ErrHandle
                strSql = "DELETE FROM JobStatus WHERE lngJobStatusID=" & mlngJobStatusID
                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 hwnd, Message.msgJobStatus
ErrHandle:
    gclsBase.BaseWorkSpace.RollBacktrans
End Function

Private Function CodeIsUsed(ByVal lngID As Long) As Boolean
    CodeIsUsed = CheckIDUsed("Job", "lngJobStatusID", lngID)
End Function



⌨️ 快捷键说明

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