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

📄 frmdeletedept.frm

📁 数据库课程设计
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmUpdateDept 
   Caption         =   "删改部门信息"
   ClientHeight    =   3510
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4095
   LinkTopic       =   "Form1"
   ScaleHeight     =   3510
   ScaleWidth      =   4095
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdCancel 
      Caption         =   "返回(&C)"
      Height          =   375
      Left            =   2280
      TabIndex        =   13
      Top             =   3000
      Width           =   735
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "删除(&D)"
      Height          =   375
      Left            =   1080
      TabIndex        =   12
      Top             =   3000
      Width           =   735
   End
   Begin VB.Frame Frame2 
      Caption         =   "部门基本信息"
      Height          =   1695
      Left            =   120
      TabIndex        =   3
      Top             =   120
      Width           =   3855
      Begin VB.TextBox txtNo 
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   285
         Left            =   1080
         TabIndex        =   11
         Text            =   "Text1"
         Top             =   240
         Width           =   2535
      End
      Begin VB.TextBox txtOffice 
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   285
         Left            =   1080
         TabIndex        =   9
         Text            =   "Text3"
         Top             =   1320
         Width           =   2535
      End
      Begin VB.TextBox txtTel 
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   285
         Left            =   1080
         TabIndex        =   7
         Text            =   "Text2"
         Top             =   960
         Width           =   2535
      End
      Begin VB.TextBox txtName 
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   285
         Left            =   1080
         TabIndex        =   5
         Text            =   "Text1"
         Top             =   600
         Width           =   2535
      End
      Begin VB.Label Label4 
         Caption         =   "部门编号:"
         Height          =   255
         Left            =   240
         TabIndex        =   10
         Top             =   240
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "办  公  室:"
         Height          =   255
         Left            =   240
         TabIndex        =   8
         Top             =   1320
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "部门电话:"
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   960
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "部门名称:"
         Height          =   255
         Index           =   1
         Left            =   240
         TabIndex        =   4
         Top             =   600
         Width           =   975
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "选择"
      Height          =   855
      Left            =   120
      TabIndex        =   0
      Top             =   1920
      Width           =   3855
      Begin VB.ComboBox cboDept 
         Height          =   315
         Left            =   1080
         TabIndex        =   1
         Text            =   "Combo1"
         Top             =   360
         Width           =   2535
      End
      Begin VB.Label Label1 
         Caption         =   "选择部门:"
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   2
         Top             =   360
         Width           =   1815
      End
   End
End
Attribute VB_Name = "frmUpdateDept"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public sqlStr As String
Public msgText As String


Private Sub cboDept_Click()
    Dim rstDepartment As ADODB.Recordset
    
    sqlStr = "select * from department where departName='" & cboDept.Text & "'"
    Set rstDepartment = ExecuteSQL(sqlStr, msgText)
    
    If Not rstDepartment.EOF Then
        
               txtNo.Text = Trim(rstDepartment.Fields("no"))
               txtName.Text = Trim(rstDepartment.Fields("departName"))
               txtTel.Text = Trim(rstDepartment.Fields("telno"))
               txtOffice.Text = Trim(rstDepartment.Fields("roomNo"))
        
    Else
        MsgBox "没有找到相关数据!", vbOKOnly + vbExclamation, "警告"
        
        Exit Sub
    End If
    rstDepartment.Close

End Sub

Private Sub cmdCancel_Click()
Unload Me

End Sub

Private Sub cmdDelete_Click()
    Dim rstDepartment As ADODB.Recordset
    
    cboDept.Clear
    
    '初始化部门列表
    sqlStr = "delete from department where no=" & txtNo.Text
    Set rstDepartment = ExecuteSQL(sqlStr, msgText)
    

End Sub

Private Sub Form_Load()

initForm
End Sub

Sub initDept()
    Dim rstDepartment As ADODB.Recordset
    
    cboDept.Clear
    
    '初始化部门列表
    sqlStr = "select departName from department"
    Set rstDepartment = ExecuteSQL(sqlStr, msgText)
    
    If Not rstDepartment.EOF Then
        
            Do While Not rstDepartment.EOF
                cboDept.AddItem Trim(rstDepartment.Fields(0))
                rstDepartment.MoveNext
            Loop
            cboDept.ListIndex = 0
        
    Else
        MsgBox "请添加客房类型!", vbOKOnly + vbExclamation, "警告"
        
        Exit Sub
    End If
    rstDepartment.Close

End Sub

Sub initForm()
   txtNo = ""
   txtName = ""
   txtTel = ""
   txtOffice = ""
   initDept
   
End Sub

⌨️ 快捷键说明

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