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

📄 frmencouragementedit.frm

📁 随着学校的规模不断扩大
💻 FRM
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Begin VB.Form frmEncouragementEdit 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "奖惩信息编辑"
   ClientHeight    =   3255
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5085
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.5
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3255
   ScaleWidth      =   5085
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command2 
      Caption         =   "返回(&R)"
      Height          =   405
      Left            =   3870
      TabIndex        =   4
      Top             =   2640
      Width           =   1125
   End
   Begin VB.CommandButton Command1 
      Caption         =   "保存(&S)"
      Height          =   405
      Left            =   2670
      TabIndex        =   3
      Top             =   2640
      Width           =   1125
   End
   Begin VB.Frame Frame1 
      Height          =   2505
      Left            =   60
      TabIndex        =   5
      Top             =   0
      Width           =   4935
      Begin VB.TextBox Text3 
         Height          =   345
         Left            =   840
         TabIndex        =   2
         Top             =   2040
         Width           =   3945
      End
      Begin MSComCtl2.DTPicker DTPicker1 
         Height          =   345
         Left            =   840
         TabIndex        =   1
         Top             =   1584
         Width           =   1905
         _ExtentX        =   3360
         _ExtentY        =   609
         _Version        =   393216
         Format          =   19791873
         CurrentDate     =   38086
      End
      Begin VB.ComboBox Combo1 
         Height          =   330
         ItemData        =   "frmEncouragementEdit.frx":0000
         Left            =   840
         List            =   "frmEncouragementEdit.frx":000A
         Style           =   2  'Dropdown List
         TabIndex        =   0
         Top             =   1146
         Width           =   1905
      End
      Begin VB.TextBox Text2 
         Height          =   345
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   9
         TabStop         =   0   'False
         Top             =   693
         Width           =   1905
      End
      Begin VB.TextBox Text1 
         Height          =   345
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   7
         TabStop         =   0   'False
         Top             =   240
         Width           =   1905
      End
      Begin VB.Label Label5 
         Caption         =   "内容:"
         Height          =   210
         Left            =   120
         TabIndex        =   12
         Top             =   2100
         Width           =   525
      End
      Begin VB.Label Label4 
         Caption         =   "日期:"
         Height          =   345
         Left            =   120
         TabIndex        =   11
         Top             =   1650
         Width           =   555
      End
      Begin VB.Label Label3 
         Caption         =   "类别:"
         Height          =   210
         Left            =   120
         TabIndex        =   10
         Top             =   1200
         Width           =   525
      End
      Begin VB.Label Label2 
         Caption         =   "姓名:"
         Height          =   210
         Left            =   120
         TabIndex        =   8
         Top             =   750
         Width           =   525
      End
      Begin VB.Label Label1 
         Caption         =   "学籍号:"
         Height          =   210
         Left            =   120
         TabIndex        =   6
         Top             =   300
         Width           =   735
      End
   End
End
Attribute VB_Name = "frmEncouragementEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
''============================模块说明=================================
''名称:
''功能:
''作者:
''日期:
''备注:


''版本  修改日期                   修改人               原因


''====================================================================

Option Explicit
Private mlngID As Long
Private mblnEdit As Boolean

Public Sub EditEncouragement(Optional ByVal lngID As Long = 0, Optional ByVal strStudentNumber As String, Optional ByVal strStudentName As String)
Dim rst As Recordset

    mlngID = lngID
    mblnEdit = (lngID <> 0)
    Me.Combo1.ListIndex = 0
    If mblnEdit Then
        Set rst = New Recordset
        rst.ActiveConnection = pCN
        rst.CursorLocation = adUseClient
        rst.LockType = adLockBatchOptimistic
        rst.CursorType = adOpenStatic
        rst.Source = "select * from 奖惩记录 where ID=" & lngID
        rst.Open
        Text1.Text = rst![学籍号]
        Text2.Text = rst![学生姓名]
        Combo1.ListIndex = IIf(rst![类型] = "奖励", 0, 1)
        DTPicker1.Value = rst![日期]
        Text3.Text = rst![内容] & ""
    Else
        Text2.Text = strStudentName
        Text1.Text = strStudentNumber
    End If
    Me.Show 1
End Sub

Private Sub Command1_Click()
Dim rst As Recordset
On Error GoTo Proc_Exit
    If Len(Text1) = 0 Then
        MsgBox "学籍号不能为空!", vbInformation
        GoTo Proc_Exit
    End If
    
    If Len(Text2) = 0 Then
        MsgBox "学生姓名不能为空!", vbInformation
        GoTo Proc_Exit
    End If
    
    Set rst = New Recordset
    rst.ActiveConnection = pCN
    rst.CursorLocation = adUseClient
    rst.LockType = adLockBatchOptimistic
    rst.CursorType = adOpenStatic
    
    If mblnEdit Then
        rst.Source = "select * from 奖惩记录 where ID=" & mlngID
        rst.Open
    Else
        rst.Source = "select * from 奖惩记录"
        rst.Open
        rst.AddNew
    End If
    rst![学籍号] = Text1.Text
    rst![学生姓名] = Text2.Text
    rst![类型] = Combo1.Text
    rst![日期] = DTPicker1.Value
    rst![内容] = Text3.Text
    rst.UpdateBatch
    
    mblnEdit = False
    Text3.Text = ""
    Combo1.SetFocus
Proc_Exit:
    If Err.Number <> 0 Then
        If Err.Number = -2147467259 Then
            MsgBox "学籍号不能重复!", vbInformation
        Else
            MsgBox "发生意外错误,错误号:" & Err.Number & " 错误描述:" & Err.Description, vbInformation
        End If
        Err.Clear
    End If
End Sub

Private Sub Command2_Click()
    Unload Me
End Sub

⌨️ 快捷键说明

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