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

📄 frmdepman.frm

📁 主要是基本的办公用品管理操作界面, 包含基本信息管理、办公用品管理
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form FrmDepMan 
   Caption         =   "部门管理"
   ClientHeight    =   4065
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4635
   LinkTopic       =   "Form1"
   ScaleHeight     =   4065
   ScaleWidth      =   4635
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox txtName 
      Height          =   375
      Left            =   2640
      TabIndex        =   5
      Top             =   360
      Width           =   1695
   End
   Begin VB.CommandButton Cmd_Back 
      Caption         =   "返 回"
      Height          =   495
      Left            =   2880
      TabIndex        =   4
      Top             =   3360
      Width           =   1215
   End
   Begin VB.CommandButton Cmd_Del 
      Caption         =   "删 除"
      Height          =   495
      Left            =   2880
      TabIndex        =   3
      Top             =   2565
      Width           =   1215
   End
   Begin VB.CommandButton Cmd_Modi 
      Caption         =   "修 改"
      Height          =   495
      Left            =   2880
      TabIndex        =   2
      Top             =   1755
      Width           =   1215
   End
   Begin VB.CommandButton Cmd_Add 
      Caption         =   "添 加"
      Height          =   495
      Left            =   2880
      TabIndex        =   1
      Top             =   960
      Width           =   1215
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   2760
      Top             =   0
      Visible         =   0   'False
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSDataListLib.DataList DataList1 
      Height          =   3570
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   2175
      _ExtentX        =   3836
      _ExtentY        =   6297
      _Version        =   393216
   End
End
Attribute VB_Name = "FrmDepMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public OriDepId As Long
Public OriOldName As String

Private Sub Cmd_Add_Click()
  '添加部门名称,先判断域是否为空
  If Len(Trim(txtName)) = 0 Then
    MsgBox ("请输入部门名称")
    txtName.SetFocus
    Exit Sub
  End If
  '判断数据库中是否已经存在此部门名称
  If MyDep.In_DB(Trim(txtName)) = True Then
    MsgBox ("已经存在此部门名称")
    txtName.SetFocus
    Exit Sub
  End If
  '插入新记录
  With MyDep
    .DepName = Trim(txtName)
    .Insert
    MsgBox ("添加成功")
  End With
  DataRefresh
End Sub

Private Sub Cmd_Back_Click()
  Unload Me
End Sub

Private Sub Cmd_Del_Click()
  If Len(Trim(DataList1.BoundText)) = 0 Then
    MsgBox ("请选择记录")
    Exit Sub
  End If
  ' 确定删除
  If MsgBox("是否确定要删除 ", vbYesNo, "请确认") = vbNo Then
    Exit Sub
  End If
  '判断其他表中是否存在此部门信息
  
  ' 删除部门
  MyDep.Delete (Val(DataList1.BoundText))
  MsgBox ("删除成功")
  DataRefresh   '刷新DataList1
End Sub

Private Sub Cmd_Modi_Click()
  '修改部门名称
  If Len(Trim(DataList1.BoundText)) = 0 Then
    MsgBox ("请选择记录")
    Exit Sub
  End If
  '判断新的名称是否和原来的相同
  If Trim(txtName) = OriOldName Then
    Exit Sub
  End If
  '判断新的名称是否已经存在
  If MyDep.In_DB(Trim(txtName)) = True Then
    MsgBox ("已经存在此部门名称")
    txtName.SetFocus
    Exit Sub
  End If
  '更新部门名称
  MyDep.DepName = Trim(txtName)
  MyDep.Update (OriDepId)
  MsgBox ("修改成功")
  DataRefresh  '刷新部门列表
End Sub

Private Sub DataList1_Click()
  If Len(Trim(DataList1.Text)) = 0 Then
    Exit Sub
  End If
  OriDepId = DataList1.BoundText
  txtName = Trim(DataList1.Text)
  OriOldName = Trim(DataList1.Text)
End Sub

Private Sub Form_Load()
  '装入部门信息
  DataRefresh
End Sub

Private Sub DataRefresh()
  '设置连接字符串
  Adodc1.ConnectionString = Conn
  Adodc1.RecordSource = "Select * From Department Order By DepId"
  Adodc1.Refresh
  Set DataList1.RowSource = Adodc1
  DataList1.ListField = "DepName"
  DataList1.BoundColumn = "DepId"
  DataList1.Refresh
End Sub

⌨️ 快捷键说明

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