📄 frmjiben.frm
字号:
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 350
Left = 120
TabIndex = 3
Top = 240
Width = 2895
End
End
Begin MSFlexGridLib.MSFlexGrid MSF1
Height = 3975
Left = 120
TabIndex = 0
Top = 240
Width = 3165
_ExtentX = 5583
_ExtentY = 7011
_Version = 393216
BackColor = -2147483624
BackColorFixed = 12632256
ForeColorFixed = 0
BackColorSel = 16777215
ForeColorSel = 255
BackColorBkg = -2147483624
AllowBigSelection= -1 'True
SelectionMode = 1
AllowUserResizing= 3
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
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) = 1000
.ColWidth(2) = 2000
.FixedRows = 1
.FillStyle = flexFillSingle
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.Row = 1
End With
End Sub
Private Sub Command1_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 allkecheng 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 allkecheng 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 Command4_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 allkecheng 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 allkecheng 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 MSF1_Click()
If Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) = "" Then
Text1.Text = ""
Text2.Text = ""
Else
Adodc1.RecordSource = "select * from allkecheng 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -