frmjiben.frm

来自「源码+论文 vB+access的毕业设计,请大家参考」· FRM 代码 · 共 381 行

FRM
381
字号
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmjiben 
   Caption         =   "基本课程设置"
   ClientHeight    =   6315
   ClientLeft      =   4935
   ClientTop       =   2070
   ClientWidth     =   4740
   LinkTopic       =   "Form1"
   ScaleHeight     =   6315
   ScaleWidth      =   4740
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   3000
      Top             =   6360
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.CommandButton Command4 
      Caption         =   "退出"
      Height          =   375
      Left            =   3480
      TabIndex        =   10
      Top             =   5760
      Width           =   1095
   End
   Begin VB.CommandButton Command3 
      Caption         =   "删除"
      Height          =   375
      Left            =   3480
      TabIndex        =   9
      Top             =   5280
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "增加"
      Height          =   375
      Left            =   3480
      TabIndex        =   8
      Top             =   4800
      Width           =   1095
   End
   Begin VB.Frame Frame1 
      Caption         =   "基本课程设置"
      Height          =   6255
      Left            =   120
      TabIndex        =   0
      Top             =   0
      Width           =   4575
      Begin VB.CommandButton Command1 
         Caption         =   "修改"
         Height          =   375
         Left            =   3360
         TabIndex        =   7
         Top             =   4320
         Width           =   1095
      End
      Begin VB.Frame Frame4 
         Caption         =   "提示"
         Height          =   3855
         Left            =   3360
         TabIndex        =   6
         Top             =   240
         Width           =   1095
         Begin VB.Label Label2 
            Caption         =   "   在新增资料对话框中输入新的课和条目,按回车即可完成添加资料。"
            Height          =   1575
            Left            =   120
            TabIndex        =   12
            Top             =   2160
            Width           =   855
         End
         Begin VB.Label Label1 
            Caption         =   "   在新增资料对话框中输入新的课和条目,按回车即可完成添加资料。"
            Height          =   1695
            Left            =   120
            TabIndex        =   11
            Top             =   240
            Width           =   855
         End
      End
      Begin VB.Frame Frame3 
         Caption         =   "教材"
         Height          =   735
         Left            =   120
         TabIndex        =   4
         Top             =   5400
         Width           =   3015
         Begin VB.TextBox Text2 
            BackColor       =   &H00C0FFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   5
            Top             =   240
            Width           =   2775
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "课程名称"
         Height          =   855
         Left            =   120
         TabIndex        =   2
         Top             =   4560
         Width           =   3015
         Begin VB.TextBox Text1 
            BackColor       =   &H00C0FFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   3
            Top             =   240
            Width           =   2775
         End
      End
      Begin MSFlexGridLib.MSFlexGrid MSF1 
         Height          =   4215
         Left            =   120
         TabIndex        =   1
         Top             =   240
         Width           =   3015
         _ExtentX        =   5318
         _ExtentY        =   7435
         _Version        =   393216
         BackColor       =   12648447
         ForeColor       =   4210752
         ForeColorFixed  =   4210752
         ForeColorSel    =   0
         BackColorBkg    =   12648447
         GridColor       =   0
      End
   End
End
Attribute VB_Name = "frmjiben"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub kechengshowtitle()
 MSF1.Clear
  Dim i As Integer
  With MSF1
    .Cols = 3
    .TextMatrix(0, 1) = "课程名称"
    .TextMatrix(0, 2) = "教材"
    
    .ColWidth(0) = 0
    .ColWidth(1) = 600
    .ColWidth(2) = 1000
   
    .FixedRows = 1
    
    .FillStyle = flexFillSingle
    .Col = 0
    .Row = 0
    .RowSel = 1
    .ColSel = .Cols - 1
    .CellAlignment = 4
    .Row = 1
    End With
End Sub

Private Sub Command4_Click()
Unload Me
End Sub

Private Sub Command2_Click()
qxstr = Executeqx(4)
  If qxstr = "readonly" Then
  ss = MsgBox("对不起,你是只读用户不能添加记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告")
  Exit Sub
   End If
If Command2.Caption = "确定" Then
  If Text1.Text = "" Then
     sssss = MsgBox("课程名称不能为空!", vbOKOnly + vbExclamation, "警告")
     Text1.SetFocus
     Exit Sub
  End If
    If Text2.Text = "" Then
     sssss = MsgBox("教材不能为空!", vbOKOnly + vbExclamation, "警告")
     Text2.SetFocus
     Exit Sub
  End If
   
  
  Adodc1.RecordSource = "select * from classBook where 课程名称='" & Trim(Text1.Text) & "'"
  Adodc1.Refresh
  If Adodc1.Recordset.EOF = False Then
   sssss = MsgBox("已经存在该课程名称!", vbOKOnly + vbExclamation, "警告")
    Text1.SetFocus
     Text1.SelStart = 0
     Text1.SelLength = Len(Text1.Text)
    Exit Sub
   Else
  Adodc1.Recordset.AddNew
  Adodc1.Recordset.Fields(0) = Text1.Text
  Adodc1.Recordset.Fields(1) = Text2.Text
  Adodc1.Recordset.Update
  Command2.Caption = "增加"
  Command3.Enabled = True
   Command4.Enabled = True
 Text1.Text = ""
 Text2.Text = ""
  Text1.Enabled = False
   Text2.Enabled = False
 kechengshowtitle
 kechengshowdata
 
 End If
Else
    Text1.Enabled = True
   Text2.Enabled = True
   Text1.Text = ""
    Text2.Text = ""
    Text1.SetFocus
   kechengshowtitle
   kechengshowdata
   Command2.Caption = "确定"
   Command3.Enabled = False
   Command4.Enabled = False
End If
End Sub

Private Sub Command3_Click()
qxstr = Executeqx(4)
  If qxstr = "readonly" Then
  ss = MsgBox("对不起,你是只读用户不能添加记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告")
  Exit Sub
   End If
If Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) = "" Then
   sssss = MsgBox("你还没有选择记录!", vbOKOnly + vbExclamation, "警告")
Else
  If MsgBox("确定要删除 课程名称 为 " & Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) & " 的记录吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
  Adodc1.RecordSource = "select * from classBook where 课程名称='" & Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) & "'"
  Adodc1.Refresh
  Adodc1.Recordset.Delete
  Text1.Text = ""
   Text2.Text = ""
  kechengshowtitle
  kechengshowdata
  End If
End If
End Sub

Private Sub Command1_Click()
qxstr = Executeqx(4)
  If qxstr = "readonly" Then
  ss = MsgBox("对不起,你是只读用户不能修改记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告")
  Exit Sub
   End If
If Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) = "" Then
   sssss = MsgBox("你还没有选择记录!", vbOKOnly + vbExclamation, "警告")
Else
 If Command4.Caption = "确定" Then
  If Text1.Text = "" Then
     sssss = MsgBox("课程名称不能为空!", vbOKOnly + vbExclamation, "警告")
     Text1.SetFocus
     Exit Sub
  End If
    If Text2.Text = "" Then
     sssss = MsgBox("教材不能为空!", vbOKOnly + vbExclamation, "警告")
     Text2.SetFocus
     Exit Sub
    End If
  Adodc1.RecordSource = "select * from classBook where 课程名称='" & Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) & "'"
  Adodc1.Refresh
   Adodc1.Recordset.Fields(0) = Text1.Text
    Adodc1.Recordset.Fields(1) = Text2.Text
   Adodc1.Recordset.Update
    Text1.Text = ""
   Text2.Text = ""
   kechengshowtitle
   kechengshowdata
  Command4.Caption = "修改"
   Command2.Enabled = True
   Command3.Enabled = True
   Text1.Enabled = False
   Text2.Enabled = False
Else
   Text1.Enabled = True
   Text2.Enabled = True
   Text1.SetFocus
   Command4.Caption = "确定"
   Command2.Enabled = False
   Command3.Enabled = False
End If
End If
End Sub

Private Sub Form_Load()
Adodc1.ConnectionString = connstring
kechengshowtitle
kechengshowdata
End Sub

Public Sub kechengshowdata()
Dim j As Integer
Dim i As Integer

Dim mrc As ADODB.Recordset
Adodc1.RecordSource = "select * from classBook order by 课程名称"
Adodc1.Refresh
 If Adodc1.Recordset.EOF = False Then
   Adodc1.Recordset.MoveFirst
   With MSF1
   .Rows = 15
     .Row = 2
   
    Do While Not Adodc1.Recordset.EOF
     .Rows = .Rows + 1
     For i = 1 To Adodc1.Recordset.Fields.Count
      .TextMatrix(.Row - 1, i) = Adodc1.Recordset.Fields(i - 1)
     Next i
     .Row = .Row + 1
     Adodc1.Recordset.MoveNext
    Loop
 End With
End If
End Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub MSF1_Click()
If Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) = "" Then
   Text1.Text = ""
   Text2.Text = ""
Else
  Adodc1.RecordSource = "select * from classBook where 课程名称='" & Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) & "'"
  Adodc1.Refresh
   Text1.Text = Adodc1.Recordset.Fields(0)
   Text2.Text = Adodc1.Recordset.Fields(1)
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Text2.SetFocus
End If
End Sub

⌨️ 快捷键说明

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