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

📄 form3.frm

📁 经过几个月的设计和开发
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form3 
   Appearance      =   0  'Flat
   AutoRedraw      =   -1  'True
   BackColor       =   &H80000005&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "职工信息录入"
   ClientHeight    =   4935
   ClientLeft      =   3525
   ClientTop       =   3210
   ClientWidth     =   8040
   Icon            =   "Form3.frx":0000
   LinkTopic       =   "Form3"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   329
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   536
   Begin VB.PictureBox Picture1 
      BorderStyle     =   0  'None
      Height          =   735
      Left            =   0
      Picture         =   "Form3.frx":0CCA
      ScaleHeight     =   735
      ScaleWidth      =   8775
      TabIndex        =   6
      Top             =   4560
      Width           =   8775
   End
   Begin 计算机图书管理系统2008.xp_canvas xp_canvas1 
      Height          =   4575
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   8775
      _extentx        =   15478
      _extenty        =   8070
      Begin VB.Frame Frame1 
         BackColor       =   &H00C0FFFF&
         BorderStyle     =   0  'None
         Height          =   3015
         Left            =   0
         TabIndex        =   7
         Top             =   0
         Width           =   8055
         Begin VB.TextBox Text5 
            Height          =   375
            Left            =   1320
            TabIndex        =   12
            Top             =   2040
            Width           =   5655
         End
         Begin VB.TextBox Text4 
            Height          =   375
            Left            =   4920
            TabIndex        =   11
            Top             =   1200
            Width           =   2055
         End
         Begin VB.TextBox Text3 
            Height          =   375
            Left            =   1320
            TabIndex        =   10
            Top             =   1200
            Width           =   2055
         End
         Begin VB.TextBox Text2 
            Height          =   375
            Left            =   4920
            TabIndex        =   9
            Top             =   480
            Width           =   2055
         End
         Begin VB.TextBox Text1 
            Height          =   375
            Left            =   1320
            TabIndex        =   8
            Top             =   480
            Width           =   2055
         End
         Begin VB.Label Label5 
            BackColor       =   &H00C0FFFF&
            Caption         =   "家庭住址"
            Height          =   255
            Left            =   240
            TabIndex        =   17
            Top             =   2100
            Width           =   975
         End
         Begin VB.Label Label3 
            BackColor       =   &H00C0FFFF&
            Caption         =   "性     别"
            Height          =   255
            Left            =   240
            TabIndex        =   16
            Top             =   1260
            Width           =   975
         End
         Begin VB.Label Label1 
            BackColor       =   &H00C0FFFF&
            Caption         =   "职工编号"
            Height          =   255
            Left            =   240
            TabIndex        =   15
            Top             =   540
            Width           =   975
         End
         Begin VB.Label Label4 
            BackColor       =   &H00C0FFFF&
            Caption         =   "联系电话"
            Height          =   255
            Left            =   3720
            TabIndex        =   14
            Top             =   1260
            Width           =   975
         End
         Begin VB.Label Label2 
            BackColor       =   &H00C0FFFF&
            Caption         =   " 姓   名"
            Height          =   255
            Left            =   3720
            TabIndex        =   13
            Top             =   540
            Width           =   975
         End
      End
      Begin 计算机图书管理系统2008.xpcmdbutton Command5 
         Height          =   375
         Left            =   6240
         TabIndex        =   5
         Top             =   3840
         Width           =   1215
         _extentx        =   2143
         _extenty        =   661
         caption         =   "退出"
         font            =   "Form3.frx":2BAA4
      End
      Begin 计算机图书管理系统2008.xpcmdbutton Command4 
         Height          =   375
         Left            =   4680
         TabIndex        =   4
         Top             =   3840
         Width           =   1215
         _extentx        =   2143
         _extenty        =   661
         caption         =   "下一记录"
         font            =   "Form3.frx":2BAC8
      End
      Begin 计算机图书管理系统2008.xpcmdbutton Command3 
         Height          =   375
         Left            =   3240
         TabIndex        =   3
         Top             =   3840
         Width           =   1215
         _extentx        =   2143
         _extenty        =   661
         caption         =   "上一记录"
         font            =   "Form3.frx":2BAEC
      End
      Begin 计算机图书管理系统2008.xpcmdbutton Command2 
         Height          =   375
         Left            =   1800
         TabIndex        =   2
         Top             =   3840
         Width           =   1215
         _extentx        =   2143
         _extenty        =   661
         caption         =   "删除记录"
         font            =   "Form3.frx":2BB10
      End
      Begin 计算机图书管理系统2008.xpcmdbutton Command1 
         Height          =   375
         Left            =   480
         TabIndex        =   1
         Top             =   3840
         Width           =   1215
         _extentx        =   2143
         _extenty        =   661
         caption         =   "添加记录"
         font            =   "Form3.frx":2BB34
      End
   End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()               '添加记录
Dim sql As String
Dim param As ADODB.Parameter
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Set param = New ADODB.Parameter
sql = "select * from worker where [工号]= ? "

If Command1.Caption = "添加记录" Then
   Command1.Caption = "确   定"
   Command2.Enabled = False
   Command3.Enabled = False
   Command4.Enabled = False
   rst.AddNew
Else
    If Text1.Text = "" Then
     frmMsg.Show
   frmMsg.notice.Visible = True
  frmMsg.Text1.Text = "职工编号不能为空!"
      Command2.Enabled = True
       Command3.Enabled = True
       Command4.Enabled = True
       Command1.Caption = "添加记录"
      Exit Sub
     End If
    With param
    .Direction = adParamInput
    .Type = adBSTR
    .Size = 8
    .Value = Text1.Text
    End With
   cmd.Parameters.Append param
   cmd.CommandText = sql
   cmd.CommandType = adCmdText
   Set cmd.ActiveConnection = con
   Set rst1 = cmd.Execute
  '检测职工编号是否存在防止主键冲突
  If rst1.RecordCount > 0 Then
     frmMsg.Show
     frmMsg.notice.Visible = True
     frmMsg.Text1.Text = "此职工编号已经存在!"
       rst.Cancel
       Command2.Enabled = True
       Command3.Enabled = True
       Command4.Enabled = True
       Command1.Caption = "添加记录"
      
       Exit Sub
   End If
   rst.Update
    Command2.Enabled = True
    Command3.Enabled = True
    Command4.Enabled = True
   
   Command1.Caption = "添加记录"
End If
End Sub

Private Sub Command2_Click()                '删除纪录
Dim ans As String
ans = Msgbox("确定要删除此记录吗?", vbYesNo, "提示")
If ans = vbYes Then
   rst.Delete
   rst.Requery
Else
 Exit Sub
End If
End Sub

Private Sub Command3_Click()                  '上一记录
If rst.BOF Then
   frmMsg.Show
   frmMsg.info.Visible = True
  frmMsg.Text1.Text = "已经到达记录顶端!"
   Exit Sub
 Else
  rst.MovePrevious
End If
End Sub

Private Sub Command4_Click()                  '下一记录
If rst.EOF Then
  frmMsg.Show
  frmMsg.info.Visible = True
  frmMsg.Text1.Text = "已经到达记录底端! "
   Exit Sub
 Else
   rst.MoveNext
End If
End Sub

Private Sub Command5_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim sql1 As String
Set rst = New ADODB.Recordset
sql1 = "select * from worker"
'打开数据库并对窗体控件赋值
Call connect_db
rst.Open sql1, con, adOpenDynamic, adLockOptimistic
Set Text1.DataSource = rst
Set Text2.DataSource = rst
Set Text3.DataSource = rst
Set Text4.DataSource = rst
Set Text5.DataSource = rst
Text1.DataField = "工号"
Text2.DataField = "姓名"
Text3.DataField = "性别"
Text4.DataField = "电话"
Text5.DataField = "住址"
End Sub




Private Sub xptopbuttons1_Click()
Unload Me
End Sub

Private Sub xptopbuttons2_Click()
Me.WindowState = 1
End Sub



Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)
End Sub

⌨️ 快捷键说明

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