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

📄 行业类别定义.frm

📁 软件用到的技巧:透明窗体
💻 FRM
📖 第 1 页 / 共 2 页
字号:
        Text1.SetFocus
        Exit Sub
    End If
    Dim db As Database
    Dim rs As Recordset
    Set db = OpenDatabase(MdbPath)
    Set rs = db.OpenRecordset("hangye")
    rs.AddNew
        rs!行业名称 = Text1.Text
        rs!备注信息 = Trim(Text2.Text)
    rs.Update
    LoadHangye
    rs.Close
    db.Close
    Text1.Text = ""
    Text2.Text = ""
    MsgBox "新的行业名称分类已经添加到数据库中 ...", vbInformation, "添加新的类别"
    
End Sub

Private Sub Command2_Click()
    If Len(Trim(Text3.Text)) > 700 Then
        MsgBox "备注信息文字内容过长,请保持在700字范围之内。", vbInformation, "文字内容过长"
        Text3.SetFocus
        Exit Sub
    End If

    If Val(Label6.Caption) = 0 Then Exit Sub
    Text4.Text = Trim(Text4.Text)
    If Text4.Text = "" Then
        Text4.SetFocus
        Exit Sub
    End If
    Dim db As Database
    Dim rs As Recordset
    Set db = OpenDatabase(MdbPath)
    Set rs = db.OpenRecordset("select * from hangye where id =" & Val(Trim(Label6.Caption)))
    If rs.RecordCount > 0 Then
        rs.MoveLast
        rs.MoveFirst
    End If
    If rs.RecordCount = 0 Then
        MsgBox "没有找到相应的资料,目标定位失败,原因有多方面,可能是数据库紊乱,或者数据库被手工更改过,请和程序提供者联系。", vbCritical
        rs.Close
        db.Close
        Exit Sub
    ElseIf rs.RecordCount > 1 Then
        MsgBox "定位目标资料的时候,出现了重复的资料,无法准确定位资料,这种情况多数是由于数据库资料紊乱造成的,请和软件作者联系。", vbCritical
        rs.Close
        db.Close
        Exit Sub
    ElseIf rs.RecordCount = 1 Then
        If MsgBox("你确实想更改ID编号为 " & rs!id & " 的行业名称吗?", vbInformation + vbYesNo) = vbYes Then
        rs.Edit
            rs!行业名称 = Text4.Text
            rs!备注信息 = Trim(Text3.Text)
        rs.Update
        rs.Close
        db.Close
        Text1.Text = ""
        Text2.Text = ""
        MsgBox "行业名称分类已经被更改 ...", vbInformation
        LoadHangye
        Exit Sub
        End If
    End If
    
    
    
    
    
End Sub

Private Sub Command3_Click()
    If Val(Label6.Caption) = 0 Then Exit Sub
    
    Dim db As Database
    Dim rs As Recordset
    Set db = OpenDatabase(MdbPath)
    Set rs = db.OpenRecordset("select * from hangye where id =" & Val(Trim(Label6.Caption)))
    If rs.RecordCount > 0 Then
        rs.MoveLast
        rs.MoveFirst
    End If
    If rs.RecordCount = 0 Then
        MsgBox "没有找到相应的资料,目标定位失败,原因有多方面,可能是数据库紊乱,或者数据库被手工更改过,请和程序提供者联系。", vbCritical
        rs.Close
        db.Close
        Exit Sub
    ElseIf rs.RecordCount > 1 Then
        MsgBox "定位目标资料的时候,出现了重复的资料,无法准确定位资料,这种情况多数是由于数据库资料紊乱造成的,请和软件作者联系。", vbCritical
        rs.Close
        db.Close
        Exit Sub
    ElseIf rs.RecordCount = 1 Then
        If MsgBox("你确实想删除ID编号为 " & rs!id & " 的行业名称吗,该操作将无法恢复,如果有企业属于该行业的,则这些企业将被标志为错误的行业类别,并可能会出现数据错误,所以,请确定在该行业下没有企业被定义。", vbInformation + vbYesNo) = vbYes Then
            rs.Delete
            LoadHangye
            rs.Close
            db.Close
            MsgBox "删除操作执行完毕!", vbInformation
            Exit Sub
        End If
    End If
    
            
End Sub

Private Sub Form_Load()
    Me.Icon = MDIForm1.Icon
    HookWheel Me.hwnd '用于支持鼠标滚轮
    Me.BackColor = FormBackColor
        Me.MSFlexGrid1.RowHeight(0) = 300
    Me.MSFlexGrid1.BackColorFixed = 16777178
    Me.MSFlexGrid1.BackColorBkg = MsFlexGridBackColorBkgValue
    MDIForm1.Enabled = False
    Me.Height = 4995
    Me.Width = 8040
    Me.Frame1.BackColor = Me.BackColor
    Me.Frame2.BackColor = Me.BackColor
    Label6.Caption = ""
    LoadHangye
End Sub


Private Sub Form_Resize()
On Error GoTo ddd
    Me.Height = 4995
    Me.Width = 8040
ddd:

End Sub
Private Sub Form_Unload(Cancel As Integer)
    AllBaiFangShow = False
    
    MDIForm1.Enabled = True
End Sub
Private Sub MSFlexGrid1_GotFocus()
Set CtlWheel = MSFlexGrid1 '用于设定支持鼠标滚轮
End Sub
Private Sub MSFlexGrid1_LostFocus()
Set CtlWheel = Nothing '用于设定取消鼠标滚轮的支持
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
UnHookWheel Me.hwnd '卸载鼠标滚轮的支持
End Sub


Private Sub LoadHangye()
    Me.MSFlexGrid1.Clear
    Me.MSFlexGrid1.Cols = 3
    Me.MSFlexGrid1.ColWidth(0) = 700
    Me.MSFlexGrid1.ColWidth(1) = 2000
    Me.MSFlexGrid1.RowHeightMin = 300
    Me.MSFlexGrid1.ColWidth(2) = 0
    Dim db As Database
    Dim rs As Recordset
    Set db = OpenDatabase(MdbPath)
    Set rs = db.OpenRecordset("hangye")
    If rs.RecordCount > 0 Then
        rs.MoveLast
        rs.MoveFirst
    End If
    If rs.RecordCount > 0 Then
        Me.MSFlexGrid1.Rows = rs.RecordCount + 2
        Me.MSFlexGrid1.TextMatrix(0, 0) = "ID"
        Me.MSFlexGrid1.TextMatrix(0, 1) = "行业名称"
        Me.MSFlexGrid1.TextMatrix(0, 2) = "备注信息"
        
        Dim i As Long
        For i = 1 To rs.RecordCount
            Me.MSFlexGrid1.TextMatrix(i, 0) = rs!id
            Me.MSFlexGrid1.TextMatrix(i, 1) = rs!行业名称
            Me.MSFlexGrid1.TextMatrix(i, 2) = rs!备注信息
        rs.MoveNext
        Next i
        Me.MSFlexGrid1.TextMatrix(i, 0) = "0"
        Me.MSFlexGrid1.TextMatrix(i, 1) = "无行业名称"
        
    ElseIf rs.RecordCount = 0 Then
        Me.MSFlexGrid1.TextMatrix(0, 0) = "ID"
        Me.MSFlexGrid1.TextMatrix(0, 1) = "行业名称"
        Me.MSFlexGrid1.TextMatrix(0, 2) = "备注信息"
        Me.MSFlexGrid1.TextMatrix(1, 0) = "0"
        Me.MSFlexGrid1.TextMatrix(1, 1) = "无行业名称"
    End If
    rs.Close
    db.Close
    Label6.Caption = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 0)
    Text4 = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1)
    Text3 = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 2)
End Sub

Private Sub MSFlexGrid1_Click()
    Label6.Caption = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 0)
    Text4 = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1)
    Text3 = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 2)
End Sub

Private Sub MSFlexGrid1_DblClick()
    If Val(Label6.Caption) = 0 Then Exit Sub
    
    If Text5.Text = "添加" Then
        Form1.Text6.Text = Trim(Form1.Text6.Text)
        If Form1.Text6.Text = "" Then
            Form1.Text6.Text = Trim(Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1))
        ElseIf Form1.Text6.Text <> "" Then
            Form1.Text6.Text = Form1.Text6.Text & "\" & Trim(Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1))
        End If
        'Form1.Text15.Text = Trim(Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1))
        Unload Me
    ElseIf Text5.Text = "修改" Then
        Form3.Text6.Text = Trim(Form3.Text6.Text)
        If Form3.Text6.Text <> "" Then
            If (Right(Form3.Text6.Text, 1) = "、") Or (Right(Form3.Text6.Text, 1) = "\") Then
                Form3.Text6.Text = Form3.Text6.Text & Trim(Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1))
            Else
                Form3.Text6.Text = Form3.Text6.Text & "\" & Trim(Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1))
            End If
        Else
            Form3.Text6.Text = Trim(Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1))
        End If
        Unload Me
    End If
End Sub

Private Sub MSFlexGrid1_SelChange()
    Label6.Caption = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 0)
    Text4 = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1)
    Text3 = Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 2)
End Sub

⌨️ 快捷键说明

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