1、VB的控件名称控件名称:txtCourIDtxtCourCredittxtCourNamechkCourCorecmdAddcmdDeletecmdEditcmdSavecmdCancelcmdFirstcmdPreviouscmdNextcmdLastcmdExitCourID 课程代号CourName 课程名称CourCredit 课程学分CourCore 是否核心课程ToolTipText属性:确定:1取消:2终止:3重试:4忽略:5是:6否:7课程信息管理模块代码:Dim AddMode As BooleanSub clearcontrol() txtCourID.Text = txt
2、CourName.Text = txtCourCredit.Text = chkCourCore.Value = 0End SubSub ControltoField(rss As ADODB.Recordset) rss!CourID = Trim(txtCourID.Text) rss!CourName = Trim(txtCourName.Text) rss!CourCredit = Val(Trim(txtCourCredit.Text) + ) If chkCourCore.Value = 1 Then rss!CourCore = True Else rss!CourCore =
3、False End If End SubSub FieldtoControl(rss As ADODB.Recordset) txtCourID.Text = Trim(rss!CourID) txtCourName.Text = Trim(rss!CourName) txtCourCredit.Text = Trim(rss!CourCredit) If rss!CourCore = True Then chkCourCore.Value = 1 Else chkCourCore.Value = 0 End IfEnd SubSub cmdAdd_Click() Call SetCmdNot
4、Enable(Me) Call clearcontrol If Not rs.EOF() And Not rs.BOF() Then rs.MoveLast rs.AddNew txtCourID.SetFocus AddMode = True txtCourID.Enabled = TrueEnd SubSub cmdCancel_Click() rs.CancelUpdate Call SetCmdEnable(Me) txtCourID.Enabled = TrueEnd SubSub cmdDelete_Click()If rs.EOF Or rs.BOF Or Trim(txtCou
5、rID) = Then MsgBox 无记录可删?, 48 + vbOKCancel, 警告 Exit SubElse If MsgBox(当真要删除该课程信息码?, 48 + vbOKCancel, 警告) = 1 Then rs.Delete rs.Update Call clearcontrol Else Exit Sub End IfEnd IfIf rs.RecordCount = 0 Then MsgBox 记录已全部删除!, 48, 提示End IfEnd SubSub cmdEdit_Click()AddMode = FalseCall SetCmdNotEnable(Me)I
6、f rs.EOF Or rs.BOF Or Trim(txtCourID) = Then MsgBox 无记录可修改?, 48 + vbOKCancel, 警告 Exit SubEnd IftxtCourID.Enabled = FalseEnd SubPrivate Sub cmdExit_Click()Unload MeEnd SubSub cmdFirst_Click() If rs.RecordCount 0 Then rs.MoveFirst Call Me.FieldtoControl(rs) End IfEnd SubSub cmdLast_Click() If rs.Recor
7、dCount 0 Then rs.MoveLast Call Me.FieldtoControl(rs) End IfEnd SubSub cmdNext_Click() If rs.RecordCount 0 Then rs.MoveNext If rs.EOF Then rs.MoveLast Call Me.FieldtoControl(rs) End IfEnd SubSub cmdPrevious_Click() If rs.RecordCount 0 Then rs.MovePrevious If rs.BOF Then rs.MoveFirst Call Me.FieldtoCo
8、ntrol(rs) End IfEnd SubPrivate Sub cmdSave_Click()If Trim(txtCourID.Text) = Then MsgBox 课程编号不能为空, vbCritical, 不能保存 Exit SubEnd IfOn Error Resume NextCall SetCmdEnable(Me)If AddMode = True Then strSql = select * from CourInfo where Trim(CourID) = & Trim(Me.txtCourID.Text) & Set rstmp = New ADODB.Reco
9、rdset rstmp.Open strSql, cn, adOpenKeyset, adLockPessimistic If rstmp.RecordCount 0 Then MsgBox 您添加的课程编号已存在,不能有相同的编号!请为新课程选择不重复的编号, 48, 提示 Me.txtCourID.SetFocus: Me.txtCourID.SelStart = 0: Me.txtCourID.SelLength = Len(Me.txtCourID.Text) Call SetCmdNotEnable(Me): Exit Sub Else Call Me.ControltoField(
10、rs) rs.Update: txtCourID.Enabled = True End IfElse Call Me.ControltoField(rs) rs.Update: txtCourID.Enabled = TrueEnd IfEnd SubPrivate Sub Form_Activate()strSql = select * from CourInfoSet rs = New ADODB.Recordsetrs.ActiveConnection = cnrs.Open strSql, cn, adOpenKeyset, adLockPessimisticIf rs.RecordCount 0 Then rs.MoveFirst: Call FieldtoControl(rs)Else DoEvents MsgBox 无任何课程记录可显示!, 48, 提示 Call clearControlEnd IfcmdFirst_ClickEnd Sub学生成绩管理:txtStuIDtxtCourIDtxtStuScore
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1