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

📄 formain.frm

📁 输入个人联系方式
💻 FRM
📖 第 1 页 / 共 4 页
字号:
               If Adodc1.Recordset("性别") = "男" Then
                  Option1.Value = True
               Else
                  Option2.Value = True
               End If
               If Adodc1.Recordset("资料公开") = True Then
                  Option3.Value = True
               Else
                  Option4.Value = True
               End If
               TextTel.Text = Adodc1.Recordset("固定电话")
               TextMo.Text = Adodc1.Recordset("移动手机")
               TextEMail.Text = Adodc1.Recordset("电子邮箱")
               TextQQ.Text = Adodc1.Recordset("QQ号码")
               TextID.Text = Adodc1.Recordset("ID")
               Exit For                '注释:跳出For
                  
            End If
               Adodc1.Recordset.MoveNext   '注释:指向下一条记录
               DoEvents
           Next K
    Next I

    Adodc2.Refresh
    Adodc2.Recordset.MoveFirst '指向第一条记录
    For K = 1 To Adodc2.Recordset.RecordCount  '记录的数量.
        If Adodc2.Recordset("ID") = TextID.Text Then
           TextClass.Text = Adodc2.Recordset("班级名称")
           TextZY.Text = Adodc2.Recordset("专业名称")
           TextNum.Text = Adodc2.Recordset("学号")
           TextZW.Text = Adodc2.Recordset("寝室电话")
           TextTelQS.Text = Adodc2.Recordset("寝室地址")
           TextAddQS.Text = Adodc2.Recordset("职务")
           Exit For                '注释:跳出For
                
        End If
           Adodc2.Recordset.MoveNext   '注释:指向下一条记录
           DoEvents
    Next K

    Adodc3.Refresh
    Adodc3.Recordset.MoveFirst '指向第一条记录
    For K = 1 To Adodc3.Recordset.RecordCount  '记录的数量.
        If Adodc3.Recordset("ID") = TextID.Text Then
           TextFAdd.Text = Adodc3.Recordset("家庭地址")
           TextFTel.Text = Adodc3.Recordset("家庭电话")
           TextYB.Text = Adodc3.Recordset("家庭邮编")
           Exit For                '注释:跳出For
                
        End If
           Adodc3.Recordset.MoveNext   '注释:指向下一条记录
           DoEvents
    Next K

    Adodc4.Refresh
    Adodc4.Recordset.MoveFirst '指向第一条记录
    For K = 1 To Adodc4.Recordset.RecordCount  '记录的数量.
        If Adodc4.Recordset("ID") = TextID.Text Then
           TextSR.Text = Adodc4.Recordset("生日")
           TextAH.Text = Adodc4.Recordset("兴趣爱好")
           TextIntro.Text = Adodc4.Recordset("备注")
           Exit For                '注释:跳出For
                
        End If
           Adodc3.Recordset.MoveNext   '注释:指向下一条记录
           DoEvents
    Next K
  Else
    MsgBox ("你没有输入所要查找的用户!")
  End If
  
  
  Adodc1.Recordset.MoveFirst '指向第一条记录
  Adodc2.Recordset.MoveFirst '指向第一条记录
  Adodc3.Recordset.MoveFirst '指向第一条记录
  Adodc4.Recordset.MoveFirst '指向第一条记录
  
Exit Sub
errhandle:
    MsgBox Err.Description
    
End Sub

Private Sub Form_Load()       '注释:加载窗口"ForMain.frm"
Dim I As Integer              '注释:局部变量 I 为数值型.
Dim K As Integer              '注释:局部变量 K 为数值型.
Dim Temp As Integer           '注释:局部变量 Temp 为数值型.
Dim TempKey As String         '注释:局部变量 TempKey 为字符型.
Dim TempName As String        '注释:局部变量 TempName为字符型.

    With Adodc1               '注释:'连接到数据库
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Jing.mdb;Mode=ReadWrite;Persist Security Info=False"
        .CommandType = adCmdTable
        .RecordSource = "基本信息"
             '注释:连接到表"基本信息"
        .Refresh
             '注释:刷新
    End With

    With Adodc2               '注释:'连接到数据库
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Jing.mdb;Mode=ReadWrite;Persist Security Info=False"
        .CommandType = adCmdTable
        .RecordSource = "学生信息"
             '注释:连接到表"学生信息"
        .Refresh
             '注释:刷新
    End With

    With Adodc3               '注释:'连接到数据库
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Jing.mdb;Mode=ReadWrite;Persist Security Info=False"
        .CommandType = adCmdTable
        .RecordSource = "个人信息"
             '注释:连接到表"个人信息"
        .Refresh
             '注释:刷新
    End With
    
    With Adodc4               '注释:'连接到数据库
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Jing.mdb;Mode=ReadWrite;Persist Security Info=False"
        .CommandType = adCmdTable
        .RecordSource = "其他信息"
             '注释:连接到表"其他信息"
        .Refresh
             '注释:刷新
    End With
    '--------------------------------------------------------------------------
    TextMain.Text = ForLoad.TextUser.Text
    '--------------------------------------------------------------------------
    TreeView.ImageList = ImageList1
        '注释:链接图像列
    TreeView.LineStyle = tvwTreeLines
        '注释:在兄弟节点和父节点之间显示线
    Set Nodx = TreeView.Nodes.Add(, , "我的通信录", "我的通信录", 1)
        '注释:添加根节点 "我的通信录"
    Set Nodx = TreeView.Nodes.Add(, , "公共通信录", "公共通信录", 1)
        '注释:添加根节点 "公共通信录"
    '--------------------------------------------------------------------------
    '注释:初始化通信录.
    Temp = 0
    I = 0
    Adodc1.Refresh
    Adodc1.Recordset.MoveFirst '指向第一条记录
    For I = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
        Temp = 1
        TempKey = "|" & Adodc1.Recordset("ID")
        TempName = Adodc1.Recordset("姓名")
        If Adodc1.Recordset("创建者") = TextMain.Text Then '注释:分类.
           Set Nodx = TreeView.Nodes.Add("我的通信录", tvwChild, TempKey, TempName)
             '注释:TempKey 为 TreeView 中的关键字
        Else
           If Adodc1.Recordset("资料公开") Then
              Set Nodx = TreeView.Nodes.Add("公共通信录", tvwChild, TempKey, TempName)
                '注释:TempKey 为 TreeView 中的关键字
           End If
        End If                          '注释:If循环结束.
        Adodc1.Recordset.MoveNext       '注释:指向下一条记录
        DoEvents
    Next I                              '注释:For循环结束.
    If Temp = 0 Then
       MsgBox "通信录中没有记录"        '注释:提示用户  "通信录中没有记录"
    End If

    TextName.Text = ""
    TextTel.Text = ""
    TextMo.Text = ""
    TextEMail.Text = ""
    TextQQ.Text = ""
    TextID.Text = ""
    TextClass.Text = ""
    TextZY.Text = ""
    TextNum.Text = ""
    TextZW.Text = ""
    TextTelQS.Text = ""
    TextAddQS.Text = ""
    TextFAdd.Text = ""
    TextFTel.Text = ""
    TextYB.Text = ""
    TextSR.Text = ""
    TextAH.Text = ""
    TextIntro.Text = ""

    '--------------------------------------------------------------------------
        
    For I = 1 To TreeView.Nodes.Count    '注释:For循环开始.
        TreeView.Nodes(I).Expanded = True
            '注释:展开所有节点
        'TreeView.Sorted = True
            '注释:排列顺序
    Next                                 '注释:For循环结束.
    '--------------------------------------------------------------------------
    
    
End Sub





Private Sub Image15_Click()
Dim I As Integer                         '注释:局部变量 I 为数值型.
Dim K As Integer                         '注释:局部变量 k 为数值型.
Dim Temp As String                       '注释:局部变量 Temp 为字符型.
On Error GoTo errhandle:
        
  If TextName.Text <> "" Then '注释:检查用户名是否为空
    
           '注释:查找用户
           Adodc1.Refresh
           Adodc1.Recordset.MoveFirst '指向第一条记录
           For K = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
               If TextID.Text = Adodc1.Recordset("ID") Then
                  Adodc1.Recordset("姓名") = TextName.Text
                  If Option1.Value = True Then
                     Adodc1.Recordset("性别") = "男"
                  Else
                     Adodc1.Recordset("性别") = "女"
                  End If
                  If Option3.Value = True Then
                     Adodc1.Recordset("资料公开") = True
                  Else
                     Adodc1.Recordset("资料公开") = False
                  End If
                  Adodc1.Recordset("固定电话") = TextTel.Text
                  Adodc1.Recordset("移动手机") = TextMo.Text
                  Adodc1.Recordset("电子邮箱") = TextEMail.Text
                  Adodc1.Recordset("QQ号码") = TextQQ.Text
                  Adodc1.Recordset("创建者") = ForMain.TextMain.Text
                  Adodc1.Recordset.Update     '注释:保存记录
                  DoEvents
                  Exit For                 '注释:跳出For
               End If
               Adodc1.Recordset.MoveNext   '注释:指向下一条记录
               DoEvents
           Next K
 '------------------------------------------------------------------------
           Adodc2.Refresh
           Adodc2.Recordset.MoveFirst '指向第一条记录
           For K = 1 To Adodc2.Recordset.RecordCount  '记录的数量.
               If TextID.Text = Adodc2.Recordset("ID") Then
                  Adodc2.Recordset("ID") = TextID.Text
                  Adodc2.Recordset("班级名称") = TextClass.Text
                  Adodc2.Recordset("专业名称") = TextZY.Text
                  Adodc2.Recordset("学号") = TextNum.Text
                  Adodc2.Recordset("寝室电话") = TextZW.Text
                  Adodc2.Recordset("寝室地址") = TextTelQS.Text
                  Adodc2.Recordset("职务") = TextAddQS.Text
                  Adodc2.Recordset.Update        '注释:保存记录
                  DoEvents
               End If
               Adodc2.Recordset.MoveNext   '注释:指向下一条记录
               DoEvents
           Next K
 '------------------------------------------------------------------------
           Adodc3.Refresh
           Adodc3.Recordset.MoveFirst '指向第一条记录
           For K = 1 To Adodc3.Recordset.RecordCount  '记录的数量.
               If TextID.Text = Adodc3.Recordset("ID") Then
                  Adodc3.Recordset("ID") = TextID.Text
                  Adodc3.Recordset("家庭地址") = TextFAdd.Text
                  Adodc3.Recordset("家庭电话") = TextFTel.Text
                  Adodc3.Recordset("家庭邮编") = TextYB.Text
                  Adodc3.Recordset.Update        '注释:保存记录
                  DoEvents
               End If
               Adodc3.Recordset.MoveNext   '注释:指向下一条记录
               DoEvents
           Next K
 '------------------------------------------------------------------------
           Adodc4.Refresh
           Adodc4.Recordset.MoveFirst '指向第一条记录
           For K = 1 To Adodc4.Recordset.RecordCount  '记录的数量.
               If TextID.Text = Adodc4.Recordset("ID") Then
                  Adodc4.Recordset("ID") = TextID.Text
                  Adodc4.Recordset("生日") = TextSR.Text
                  Adodc4.Recordset("兴趣爱好") = TextAH.Text
                  Adodc4.Recordset("备注") = TextIntro.Text
                  Adodc4.Recordset.Update        '注释:保存记录
                  DoEvents
               End If
               Adodc4.Recordset.MoveNext   '注释:指向下一条记录
               DoEvents
           Next K
 '------------------------------------------------------------------------
  Else
    MsgBox ("用户名不能为空!")
    Exit Sub
  End If
  MsgBox ("修改成功!")
  
Exit Sub
errhandle:
    MsgBox Err.Description
End Sub

Private Sub TreeView_DblClick()
Dim I As Integer                         '注释:局部变量 I 为数值型.
Dim K As Integer                         '注释:局部变量 k 为数值型.
Dim Temp As String                       '注释:局部变量 Temp 为字符型.
On Error GoTo errhandle:
        
  If TreeView.SelectedItem.Children = 0 Then '注释:检查是否有子节点,0为无
    For I = 1 To TreeView.Nodes.Count
        If TreeView.Nodes(I).Selected Then
           'MsgBox "您选择的是:“" & TreeView.Nodes(I).FullPath & "”子节点!"  '注释:系统提示
           TextName.Text = TreeView.Nodes(I).FullPath
           TextName.Text = Right(TextName.Text, Len(TextName.Text) - InStr(TextName.Text, "\"))
           
           '注释:查找用户   Adodc1.'连接到表"Adm"
           Adodc1.Refresh
           Adodc1.Recordset.MoveFirst '指向第一条记录
           For K = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
               If TextName.Text = Adodc1.Recordset("姓名") Then
                  If Adodc1.Recordset("性别") = "男" Then
                     Option1.Value = True
                  Else
                     Option2.Value = True
                  End If
                  If Adodc1.Recordset("资料公开") = True Then
                     Option3.Value = True
                  Else
                     Option4.Value = True
                  End If
                  TextTel.Text = Adodc1.Recordset("固定电话")
                  TextMo.Text = Adodc1.Recordset("移动手机")
                  TextEMail.Text = Adodc1.Recordset("电子邮箱")
                  TextQQ.Text = Adodc1.Recordset("QQ号码")
                  TextID.Text = Adodc1.Recordset("ID")
                  TextCJZ.Text = Adodc1.Recordset("创建者")
                  Exit For                '注释:跳出For
                  
               End If
               Adodc1.Recordset.MoveNext   '注释:指向下一条记录
               DoEvents
           Next K
       
        End If
    Next I

    Adodc2.Refresh
    Adodc2.Recordset.MoveFirst '指向第一条记录
    For K = 1 To Adodc2.Recordset.RecordCount  '记录的数量.
        If Adodc2.Recordset("ID") = TextID.Text Then
           TextClass.Text = Adodc2.Recordset("班级名称")
           TextZY.Text = Adodc2.Recordset("专业名称")
           TextNum.Text = Adodc2.Recordset("学号")
           TextZW.Text = Adodc2.Recordset("寝室电话")
           TextTelQS.Text = Adodc2.Recordset("寝室地址")
           TextAddQS.Text = Adodc2.Recordset("职务")
           Exit For                '注释:跳出For
                
        End If
           Adodc2.Recordset.MoveNext   '注释:指向下一条记录
           DoEvents
    Next K

    Adodc3.Refresh
    Adodc3.Recordset.MoveFirst '指向第一条记录
    For K = 1 To Adodc3.Recordset.RecordCount  '记录的数量.
        If Adodc3.Recordset("ID") = TextID.Text Then
           TextFAdd.Text = Adodc3.Recordset("家庭地址")
           TextFTel.Text = Adodc3.Recordset("家庭电话")
           TextYB.Text = Adodc3.Recordset("家庭邮编")
           Exit For                '注释:跳出For
                
        End If
           Adodc3.Recordset.MoveNext   '注释:指向下一条记录
           DoEvents
    Next K

    Adodc4.Refresh
    Adodc4.Recordset.MoveFirst '指向第一条记录
    For K = 1 To Adodc4.Recordset.RecordCount  '记录的数量.
        If Adodc4.Recordset("ID") = TextID.Text Then
           TextSR.Text = Adodc4.Recordset("生日")
           TextAH.Text = Adodc4.Recordset("兴趣爱好")
           TextIntro.Text = Adodc4.Recordset("备注")
           Exit For                '注释:跳出For
                
        End If
           Adodc4.Recordset.MoveNext   '注释:指向下一条记录
           DoEvents
    Next K
  End If
    
  Adodc1.Recordset.MoveFirst '指向第一条记录
  Adodc2.Recordset.MoveFirst '指向第一条记录
  Adodc3.Recordset.MoveFirst '指向第一条记录
  Adodc4.Recordset.MoveFirst '指向第一条记录
  
Exit Sub
errhandle:
    MsgBox Err.Description
    
End Sub

Private Sub TreeView_Expand(ByVal Node As MSComctlLib.Node)
On Error GoTo errhandle:
   '注释:节点被展开时,选择索引为2的图像
   Node.ExpandedImage = 2

Exit Sub
errhandle:
    MsgBox Err.Description
End Sub


⌨️ 快捷键说明

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