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

📄 frmaddreaderinfo.frm

📁 是一款经典的图书管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form 添加读者信息 
   Caption         =   "添加读者信息"
   ClientHeight    =   5100
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7845
   LinkTopic       =   "Form1"
   ScaleHeight     =   5100
   ScaleWidth      =   7845
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   615
      Left            =   4080
      TabIndex        =   19
      Top             =   4080
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确定"
      Height          =   615
      Left            =   1440
      TabIndex        =   18
      Top             =   4080
      Width           =   1335
   End
   Begin VB.TextBox Text2 
      BackColor       =   &H8000000A&
      ForeColor       =   &H00404080&
      Height          =   375
      Left            =   1320
      TabIndex        =   17
      Top             =   1680
      Width           =   2055
   End
   Begin VB.TextBox Text3 
      BackColor       =   &H8000000A&
      ForeColor       =   &H00404080&
      Height          =   375
      Left            =   4800
      TabIndex        =   16
      Top             =   1680
      Width           =   1935
   End
   Begin VB.TextBox Text4 
      BackColor       =   &H8000000A&
      ForeColor       =   &H00404080&
      Height          =   375
      Left            =   1320
      TabIndex        =   15
      Top             =   3120
      Width           =   5415
   End
   Begin VB.TextBox Text5 
      BackColor       =   &H8000000A&
      ForeColor       =   &H00404080&
      Height          =   375
      Left            =   4800
      TabIndex        =   14
      Top             =   2400
      Width           =   1935
   End
   Begin VB.TextBox Text6 
      BackColor       =   &H8000000A&
      ForeColor       =   &H00404080&
      Height          =   375
      Left            =   1320
      TabIndex        =   13
      Top             =   2400
      Width           =   2055
   End
   Begin VB.TextBox Text1 
      BackColor       =   &H8000000B&
      Height          =   375
      Left            =   1320
      TabIndex        =   3
      Top             =   960
      Width           =   2055
   End
   Begin VB.ComboBox Combo1 
      BackColor       =   &H8000000B&
      Height          =   300
      Left            =   1320
      TabIndex        =   2
      Top             =   360
      Width           =   2055
   End
   Begin VB.ComboBox Combo2 
      BackColor       =   &H8000000B&
      Height          =   300
      Left            =   4800
      TabIndex        =   1
      Top             =   360
      Width           =   1935
   End
   Begin VB.TextBox Text7 
      BackColor       =   &H8000000B&
      Height          =   375
      Left            =   4800
      TabIndex        =   0
      Top             =   960
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "读者类别:"
      Height          =   375
      Left            =   240
      TabIndex        =   12
      Top             =   480
      Width           =   975
   End
   Begin VB.Label Label2 
      Caption         =   "读者姓名:"
      Height          =   375
      Left            =   240
      TabIndex        =   11
      Top             =   1080
      Width           =   855
   End
   Begin VB.Label Label3 
      Caption         =   "读者编号:"
      Height          =   375
      Left            =   240
      TabIndex        =   10
      Top             =   1800
      Width           =   975
   End
   Begin VB.Label Label4 
      Caption         =   "系别/部门:"
      Height          =   375
      Left            =   3840
      TabIndex        =   9
      Top             =   1800
      Width           =   975
   End
   Begin VB.Label Label5 
      Caption         =   "家庭住址:"
      Height          =   375
      Left            =   240
      TabIndex        =   8
      Top             =   3240
      Width           =   855
   End
   Begin VB.Label Label6 
      Caption         =   "登记日期:"
      Height          =   375
      Left            =   240
      TabIndex        =   7
      Top             =   2520
      Width           =   975
   End
   Begin VB.Label Label7 
      Caption         =   "性 别:"
      Height          =   255
      Left            =   3840
      TabIndex        =   6
      Top             =   480
      Width           =   615
   End
   Begin VB.Label Label8 
      Caption         =   "电话号码:"
      Height          =   255
      Left            =   3840
      TabIndex        =   5
      Top             =   2520
      Width           =   855
   End
   Begin VB.Label Label9 
      Caption         =   "民 族:"
      Height          =   255
      Left            =   3840
      TabIndex        =   4
      Top             =   1080
      Width           =   615
   End
End
Attribute VB_Name = "添加读者信息"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim rs_addreader As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim sql As String
 
If Trim(Combo1.Text) = "" Then
  MsgBox "请选择读者类别", vbOKOnly + vbExclamation, ""
  Combo1.SetFocus
  Exit Sub
End If
If Trim(Text1.Text) = "" Then
  MsgBox "读者姓名不能为空", vbOKOnly + vbExclamation, ""
  Text1.SetFocus
  Exit Sub
End If
If Trim(Text2.Text) = "" Then
  MsgBox "读者编号不能为空", vbOKOnly + vbExclamation, ""
  Text2.SetFocus
  Exit Sub
End If

If Not IsDate(Text6.Text) Then
  MsgBox "请按照yyyy-mm-dd格式输入登记日期", vbOKOnly + vbExclamation, ""
  Text6.SetFocus
  Exit Sub
End If
If Trim(Combo2.Text) = "" Then
  MsgBox "请选读者性别", vbOKOnly + vbExclamation, ""
  Combo2.SetFocus
  Exit Sub
End If



conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
sql = "select * from 读者信息 where 读者编号='" & Text2.Text & "'"
rs_addreader.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_addreader.EOF Then
   rs_addreader.AddNew
   rs_addreader.Fields(0) = Trim(Text1.Text)
   rs_addreader.Fields(1) = Trim(Text2.Text)
   rs_addreader.Fields(2) = Trim(Combo2.Text)
   rs_addreader.Fields(3) = Trim(Combo1.Text)
   rs_addreader.Fields(4) = Trim(Text3.Text)
   rs_addreader.Fields(5) = Trim(Text4.Text)
   rs_addreader.Fields(6) = Trim(Text5.Text)
   rs_addreader.Fields(7) = Trim(Text6.Text)
   rs_addreader.Fields(8) = 0
   
   rs_addreader.Update
   MsgBox "添加读者信息成功!", vbOKOnly, ""
   rs_addreader.Close
Else
   MsgBox "读者编号重复!", vbOKOnly + vbExclamation, ""
   Text2.SetFocus
   rs_addreader.Close
   Exit Sub
End If
End Sub

Private Sub Command2_Click()
 Unload Me
End Sub

Private Sub Form_Load()
Dim rs_leibie As New ADODB.Recordset

Dim conn As New ADODB.Connection
Dim sql As String

Provider = "Microsoft.Jet.OLEDB.3.5.1 ;Persist Security Info=false;data source=D:\图书管理系统\database.mdb"
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
sql = "select * from 读者类别"
rs_leibie.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_leibie.MoveFirst
Do While Not rs_leibie.EOF
   Combo1.AddItem rs_leibie.Fields(0)
    rs_leibie.MoveNext
Loop
rs_leibie.Close

Combo2.AddItem "男"
Combo2.AddItem "女"
End Sub

⌨️ 快捷键说明

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