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

📄 frmmdf.frm

📁 一个vb的mis系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
      Width           =   6300
   End
End
Attribute VB_Name = "frmmdf"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim oldx As Integer      '为解决全图形窗口没有标题栏而无法拖动的问题而定义的鼠标新旧两个XY变量
Dim oldy As Integer
Dim newx As Integer
Dim newy As Integer

Public hasselect As Boolean    '为解决选择姓名后没有更新而直接删除造成一个层叠事件而定义一个检测是否更新的变量

'选择按钮功能实现
Private Sub cmdselect_Click()
    '根据当前显示的信息判断应该给相应的数据控件传递T-SQL语句,并赋值hasselect为真。
    If stuinfo.Visible = True Then
        Adodc1.RecordSource = "select * from stuinfo where stu_name='" & dbstuname1.Text & "'"
        Adodc1.Refresh
        hasselect = True
        Exit Sub
    End If
    If makinfo1.Visible = True Then
        Adodc2.RecordSource = "select * from stumak1 where 学生姓名='" & dbstuname2.Text & "'"
        Adodc2.Refresh
        hasselect = True
        Exit Sub
    End If
    If makinfo2.Visible = True Then
        Adodc3.RecordSource = "select * from stumak2 where 学生姓名='" & dbstuname3.Text & "'"
        Adodc3.Refresh
        hasselect = True
        Exit Sub
    End If
    If makinfo3.Visible = True Then
        Adodc4.RecordSource = "select * from stumak3 where 学生姓名='" & dbstuname4.Text & "'"
        Adodc4.Refresh
        hasselect = True
        Exit Sub
    End If
End Sub



'>>>>>>>>>以下程序段设定一旦动过名字选项则hasselect布尔值为否<<<<<<<<<
Private Sub dbstuname1_Click(Area As Integer)
    '改动后自动赋hasselect为非
    hasselect = False
End Sub
Private Sub dbstuname2_Click(Area As Integer)
    '改动后自动赋hasselect为非
    hasselect = False
End Sub
Private Sub dbstuname3_Click(Area As Integer)
    '改动后自动赋hasselect为非
    hasselect = False
End Sub
Private Sub dbstuname4_Click(Area As Integer)
    '改动后自动赋hasselect为非
    hasselect = False
End Sub
'>>>>>>>>>以上设定hasselect布尔值为否<<<<<<<<<



Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    Call pic_updata_Click
End If
End Sub

'>>>>>>>>>>>>>>>>>>>>>>>>以下程序段解决全图形窗口的移动问题<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'移植须知:将该功能移植到一个全图片窗口以解决不能移动的问题时,需注意:1 赋值计时器和伪装标题栏到新的全图片窗体中;2 赋值定义的新旧XY值(4个)和本程序段到新的全图片窗体中;3 修改计时器的过程“mousemovetimer_Timer”中的四个窗体名字。4 修改伪装标题栏的图片
'当指定图片(伪装标题栏)被鼠标点击时启动计时器,并记录下当时的初始鼠标坐标
Private Sub mousermovepic_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    mousemovetimer.Enabled = True
    oldx = X
    oldy = Y
End Sub
'当指定图片(伪装标题栏)上鼠标移动时,赋给新的鼠标XY值,注意系统每隔很短的时间会赋值一次。
Private Sub mousermovepic_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    newx = X
    newy = Y
End Sub
'当指定图片(伪装标题栏)被鼠标释放时关闭计时器。
Private Sub mousermovepic_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    mousemovetimer.Enabled = False
End Sub
'计时器将定时得到四个值,分别是固定的初始XY值,和不断变化的新的XY值。利用新旧XY的差,可以以此来移动窗体。适当调小计时器间隔时间将有助于移动窗体的流畅性。
Private Sub mousemovetimer_Timer()
    frmmdf.Left = frmmdf.Left - (oldx - newx)
    If frmmdf.Top - (oldy - newy) < 1050 Then
        frmmdf.Top = 1050
    Else
        frmmdf.Top = frmmdf.Top - (oldy - newy)
    End If
End Sub
'>>>>>>>>>>>>>>>>>>>>>>>>以上程序段解决全图形窗口的移动问题<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<




Private Sub Adodc1_Reposition()
  Screen.MousePointer = vbDefault
  On Error Resume Next
  '这将显示当前记录位置
  '为动态集和快照
  Adodc1.Caption = "记录:" & (Adodc1.Recordset.AbsolutePosition + 1)
  '对于 Table 对象,当记录集创建后并使用下面的行时,
  '必须设置 Index 属性
  'Adodc1.Caption = "记录:" & (Adodc1.Recordset.RecordCount * (Adodc1.Recordset.PercentPosition * 0.01)) + 1
End Sub

Private Sub Adodc1_Validate(Action As Integer, Save As Integer)
  '这是放置验证代码的地方
  '当下面的动作发生时,调用这个事件
  Select Case Action
    Case vbAdodcActionMoveFirst
    Case vbAdodcActionMovePrevious
    Case vbAdodcActionMoveNext
    Case vbAdodcActionMoveLast
    Case vbAdodcActionAddNew
    Case vbAdodcActionUpdate
    Case vbAdodcActionDelete
    Case vbAdodcActionFind
    Case vbAdodcActionBookmark
    Case vbAdodcActionClose
  End Select
  Screen.MousePointer = vbHourglass
End Sub

'初始化窗体
Private Sub Form_Load()
    Me.Height = 6840
    Me.Width = 6690
    Me.Top = 1050
    
    '对于众多信息窗口,只显示学生信息,其余屏蔽
    stuinfo.Visible = True
    makinfo1.Visible = False
    makinfo2.Visible = False
    makinfo3.Visible = False
    
    '初始化四个学生姓名选择下拉菜单的可视效果
    dbstuname1.Visible = True
    dbstuname2.Visible = False
    dbstuname3.Visible = False
    dbstuname4.Visible = False
    
    hasselect = False
    
    '初始化CHKECK框“delyes”
    nodel.Value = 0
End Sub
'删除功能实现
Private Sub pic_del_Click()
    '防止误删除(点击选择后才能继续)
    If hasselect = False Then
        If frmmain.check_have.Value = 0 Then
        Set publicmbox.Picture = publicmbox.pic10.Picture: publicmbox.Show vbModal
        End If
        Exit Sub
    End If
    '防止误删除空的项目(往往是最后一项)
    If txtFields(13) = "" Then
        Exit Sub
    End If
    
    '在学员信息页面中删除
    If stuinfo.Visible = True Then
        '获得许可
        publicmbox.pic_exit2.Visible = True            '提示信息出现取消框
        Set publicmbox.Picture = publicmbox.picdel.Picture: publicmbox.Show vbModal  '提示删除学员信息将导致同时删除该学员的成绩信息。
        '如果取消则退出该过程
        If nodel.Value = 1 Then
            nodel.Value = 0
            Exit Sub
        End If
        '根据ID同时删除相应的成绩信息
        If txtFields(11).Text = "第一学期" Then
            runtsql ("DELETE stumak1 where 学生ID='" & txtFields(13) & "'")
        End If
        If txtFields(11).Text = "第二学期" Then
            runtsql ("DELETE stumak2 where 学生ID='" & txtFields(13) & "'")
        End If
        If txtFields(11).Text = "第三学期" Then
            runtsql ("DELETE stumak3 where 学生ID='" & txtFields(13) & "'")
        End If
        Adodc1.Recordset.Delete
        Adodc1.Recordset.MoveFirst
        Adodc1.Refresh
        dbstuname1.Refresh
        Exit Sub
    End If
    '在学员成绩信息1页面中删除
    If makinfo1.Visible = True Then
        Adodc2.Recordset.Delete
        Adodc2.Recordset.MoveFirst
        Adodc2.Refresh
        dbstuname2.Refresh
        Exit Sub
    End If
    '在学员成绩信息2页面中删除
    If makinfo2.Visible = True Then
        Adodc3.Recordset.Delete
        Adodc3.Recordset.MoveFirst
        Adodc3.Refresh
        dbstuname3.Refresh
        Exit Sub
    End If
    '在学员成绩信息3页面中删除
    If makinfo3.Visible = True Then
        Adodc4.Recordset.Delete
        Adodc4.Recordset.MoveFirst
        Adodc4.Refresh
        dbstuname4.Refresh
        Exit Sub
    End If
End Sub



'更新功能实现
Private Sub pic_updata_Click()
    If stuinfo.Visible = True Then
        Adodc1.Recordset.Update
        If frmmain.check_have.Value = 0 Then
        Set publicmbox.Picture = publicmbox.pic11.Picture: publicmbox.Show vbModal
        End If
    End If
    If makinfo1.Visible = True Then
        Adodc2.Recordset.Update
        If frmmain.check_have.Value = 0 Then
        Set publicmbox.Picture = publicmbox.pic11.Picture: publicmbox.Show vbModal
        End If
    End If
    If makinfo2.Visible = True Then
        Adodc3.Recordset.Update
        If frmmain.check_have.Value = 0 Then
        Set publicmbox.Picture = publicmbox.pic11.Picture: publicmbox.Show vbModal
        End If
    End If
    If makinfo3.Visible = True Then
        Adodc4.Recordset.Update
        If frmmain.check_have.Value = 0 Then
        Set publicmbox.Picture = publicmbox.pic11.Picture: publicmbox.Show vbModal
        End If
    End If
End Sub

'刷新功能实现
Private Sub pic_flash_Click()
    If stuinfo.Visible = True Then
        Adodc1.Refresh
    End If
    If makinfo1.Visible = True Then
        Adodc2.Refresh
    End If
    If makinfo2.Visible = True Then
        Adodc3.Refresh
    End If
    If makinfo3.Visible = True Then
        Adodc4.Refresh
    End If
End Sub
'关闭功能实现
Private Sub pic_exit_Click()
    Unload Me
End Sub
'关闭功能实现
Private Sub pic_close_Click()
    Unload Me
End Sub



'切换按钮功能实现
Private Sub pic_stuinfo_Click()    '切换到学生信息
    '只显示学生信息,其余屏蔽
    stuinfo.Visible = True
    makinfo1.Visible = False
    makinfo2.Visible = False
    makinfo3.Visible = False
    '实现切换按钮的学生按钮无效化和成绩按钮的有效化
    pic_stuinfo.Enabled = False
    pic_makinfo.Enabled = True
    '切换背景图片到学生信息图片
    Set frmmdf.Picture = pic_temppicstu
    '初始化四个学生姓名选择下拉菜单的可视效果
    dbstuname1.Visible = True
    dbstuname2.Visible = False
    dbstuname3.Visible = False
    dbstuname4.Visible = False
    '黑现删除按钮
    Set pic_del.Picture = picdel1.Picture
End Sub

Private Sub pic_makinfo_Click()    '切换到成绩信息
    '只显示成绩信息1,其余屏蔽
    stuinfo.Visible = False
    makinfo1.Visible = True
    makinfo2.Visible = False
    makinfo3.Visible = False
    '实现切换按钮的学生按钮有效化和成绩按钮的无效化
    pic_stuinfo.Enabled = True
    pic_makinfo.Enabled = False
    '切换背景图片到成绩信息图片
    Set frmmdf.Picture = pic_temppicmak
    '初始化四个学生姓名选择下拉菜单的可视效果
    dbstuname1.Visible = False
    dbstuname2.Visible = True
    dbstuname3.Visible = False
    dbstuname4.Visible = False
    
    '灰现删除按钮
    Set pic_del.Picture = picdel2.Picture
End Sub


'通过快速选择学期来选定数据
Private Sub dbstuxq_Click()
    '改动后自动赋hasselect为非
    hasselect = False
    
    '当显示学生信息时传输相应的符合学期的所有信息
    If stuinfo.Visible = True Then
        Adodc1.RecordSource = "select * from stuinfo where stu_term='" & dbstuxq.Text & "'"
        Adodc1.Refresh
        Exit Sub
    End If
    
    '当显示成绩信息时传输相应学期的成绩信息
    If dbstuxq.Text = "第一学期" Then
        makinfo1.Visible = True
        makinfo2.Visible = False
        makinfo3.Visible = False
        
        dbstuname1.Visible = False
        dbstuname2.Visible = True
        dbstuname3.Visible = False
        dbstuname4.Visible = False
        
        Adodc2.RecordSource = "select * from stumak1"
        Adodc2.Refresh
        
        '切换背景图片到成绩信息图片1
        Set frmmdf.Picture = pic_temppicmak.Picture
        
        Exit Sub
    Else
        If dbstuxq.Text = "第二学期" Then
            makinfo1.Visible = False
            makinfo2.Visible = True
            makinfo3.Visible = False
            
            dbstuname1.Visible = False
            dbstuname2.Visible = False
            dbstuname3.Visible = True
            dbstuname4.Visible = False
            
            Adodc3.RecordSource = "select * from stumak2"
            Adodc3.Refresh
            
            '切换背景图片到成绩信息图片2
            Set frmmdf.Picture = pic_temppicmak2.Picture
            
            Exit Sub
    Else:
            makinfo1.Visible = False
            makinfo2.Visible = False
            makinfo3.Visible = True
            
            dbstuname1.Visible = False
            dbstuname2.Visible = False
            dbstuname3.Visible = False
            dbstuname4.Visible = True
            
            Adodc4.RecordSource = "select * from stumak3"
            Adodc4.Refresh
            
            '切换背景图片到成绩信息图片3
            Set frmmdf.Picture = pic_temppicmak3.Picture
            
            Exit Sub
        End If
    End If
End Sub
'通过快速选择name来选定数据
Private Sub dbstuname_Change()
    If stuinfo.Visible = True Then
        Adodc1.RecordSource = "select * from stuinfo where stu_name='" & dbstuname.Text & "'"
        Adodc1.Refresh
        Exit Sub
    End If
    If makinfo1.Visible = True Then
        Adodc2.RecordSource = "select * from stumak1 where 学生姓名='" & dbstuname.Text & "'"
        Adodc2.Refresh
        Exit Sub
    End If
    If makinfo2.Visible = True Then
        Adodc3.RecordSource = "select * from stumak2 where 学生姓名='" & dbstuname.Text & "'"
        Adodc3.Refresh
        Exit Sub
    End If
    If makinfo3.Visible = True Then
        Adodc4.RecordSource = "select * from stumak3 where 学生姓名='" & dbstuname.Text & "'"
        Adodc4.Refresh
        Exit Sub
    End If
End Sub

⌨️ 快捷键说明

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