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

📄 adostand.frm

📁 用C语言如何编写多元线性回归
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "使用非绑定控件操作数据"
   ClientHeight    =   3600
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4470
   LinkTopic       =   "Form1"
   ScaleHeight     =   3600
   ScaleWidth      =   4470
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame3 
      Height          =   540
      Left            =   150
      TabIndex        =   19
      Top             =   15
      Width           =   4230
      Begin VB.Label Label6 
         Caption         =   "部门信息表"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000040C0&
         Height          =   300
         Left            =   1560
         TabIndex        =   20
         Top             =   195
         Width           =   1155
      End
   End
   Begin VB.Frame Frame2 
      Height          =   2955
      Left            =   3240
      TabIndex        =   11
      Top             =   540
      Width           =   1155
      Begin VB.CommandButton cmddel 
         Caption         =   "删除记录"
         Height          =   300
         Left            =   120
         TabIndex        =   18
         TabStop         =   0   'False
         Top             =   2190
         Width           =   960
      End
      Begin VB.CommandButton cmdadd 
         Caption         =   "添加记录"
         Height          =   300
         Left            =   120
         TabIndex        =   17
         TabStop         =   0   'False
         Top             =   990
         Width           =   960
      End
      Begin VB.CommandButton cmdcnladd 
         Caption         =   "取消添加"
         Enabled         =   0   'False
         Height          =   300
         Left            =   120
         TabIndex        =   16
         TabStop         =   0   'False
         Top             =   1380
         Width           =   960
      End
      Begin VB.CommandButton cmdnext 
         Caption         =   "下一记录"
         Height          =   300
         Left            =   120
         TabIndex        =   15
         TabStop         =   0   'False
         Top             =   570
         Width           =   960
      End
      Begin VB.CommandButton cmdprev 
         Caption         =   "上一记录"
         Height          =   300
         Left            =   120
         TabIndex        =   14
         TabStop         =   0   'False
         Top             =   180
         Width           =   960
      End
      Begin VB.CommandButton cmdsave 
         Caption         =   "保存修改"
         Height          =   300
         Left            =   120
         TabIndex        =   13
         TabStop         =   0   'False
         Top             =   1770
         Width           =   960
      End
      Begin VB.CommandButton cmdclose 
         Caption         =   "退出"
         Height          =   300
         Left            =   120
         TabIndex        =   12
         TabStop         =   0   'False
         Top             =   2580
         Width           =   960
      End
   End
   Begin VB.Frame Frame1 
      Height          =   2940
      Left            =   135
      TabIndex        =   0
      Top             =   555
      Width           =   3015
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   0
         Left            =   1020
         TabIndex        =   5
         TabStop         =   0   'False
         Top             =   270
         Width           =   1812
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   1
         Left            =   1020
         TabIndex        =   4
         Top             =   810
         Width           =   1812
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   2
         Left            =   1020
         TabIndex        =   3
         Top             =   1350
         Width           =   1812
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   3
         Left            =   1020
         TabIndex        =   2
         Top             =   1890
         Width           =   1812
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   4
         Left            =   1020
         TabIndex        =   1
         Top             =   2430
         Width           =   1812
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "部门名称"
         Height          =   180
         Left            =   180
         TabIndex        =   10
         Top             =   870
         Width           =   720
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "负 责 人"
         Height          =   180
         Left            =   180
         TabIndex        =   9
         Top             =   1410
         Width           =   720
      End
      Begin VB.Label Label3 
         Caption         =   "部门电话"
         Height          =   255
         Left            =   180
         TabIndex        =   8
         Top             =   1950
         Width           =   735
      End
      Begin VB.Label Label4 
         Caption         =   "部门职能"
         Height          =   255
         Left            =   180
         TabIndex        =   7
         Top             =   2490
         Width           =   735
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "部门编号"
         Height          =   180
         Left            =   180
         TabIndex        =   6
         Top             =   345
         Width           =   720
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim myConnection As Connection
Dim myRecordset As Recordset
Dim myBookmark As Variant  '储存当前记录指针
 
Private Sub inibt()
    '设置按钮状态
    cmdadd.Enabled = True
    cmdcnladd.Enabled = False
    cmdsave.Enabled = False
    If myRecordset.RecordCount = 0 Then  '数据库为空
        cmdprev.Enabled = False
        cmdnext.Enabled = False
        cmddel.Enabled = False
        Exit Sub
    End If
    If cmdprev.Enabled = False Then
        cmdprev.Enabled = True
        cmdnext.Enabled = True
        cmdsave.Enabled = True
        cmddel.Enabled = True
    End If
End Sub

Private Sub initxt()
    Dim i As Integer
    For i = 0 To 4
        Text1(i).Text = ""
    Next i
End Sub

Private Sub showfld()
    Dim i As Integer
    On Error Resume Next
    For i = 0 To 4
        Text1(i).Text = myRecordset(i)
    Next i
End Sub

Private Sub cmdclose_Click()
    Unload Me
End Sub

Private Sub cmdcnladd_Click()
    myRecordset.CancelUpdate
    If myBookmark <> Null Then
         myRecordset.Bookmark = myBookmark
    End If
    Call inibt
    Call showfld
End Sub

Private Sub cmddel_Click()
    On Error GoTo DeleteErr
    cmdsave.Enabled = False
    With myRecordset
        .Delete
        If .RecordCount <> 0 Then
            .MoveNext
            If .EOF Then .MoveLast
        End If
    End With
    Call inibt
    Call showfld
    Exit Sub
DeleteErr:
  MsgBox Err.Description
End Sub

Private Sub cmdsave_Click()
    Dim i As Integer
    '更新数据库
    If Text1(1).Text = "" Then
        MsgBox "必须输入姓名"
        Text1(1).SetFocus
        Exit Sub
    End If
    On Error Resume Next
    For i = 0 To 4
        myRecordset(i) = Text1(i).Text
    Next i
    myRecordset.Update
    cmddel.Enabled = True
    cmdadd.Enabled = True
    cmdprev.Enabled = True
    cmdnext.Enabled = True
    cmdcnladd.Enabled = False
End Sub

Private Sub cmdadd_Click()
    On Error Resume Next
    If myRecordset.RecordCount <> 0 Then
        myBookmark = myRecordset.Bookmark
    End If
    myRecordset.AddNew
    Call initxt
    cmddel.Enabled = False
    cmdadd.Enabled = False
    cmdprev.Enabled = False
    cmdnext.Enabled = False
    cmdsave.Enabled = True
    cmdcnladd.Enabled = True
    Text1(0).SetFocus
End Sub

Private Sub cmdprev_Click()
    On Error GoTo GoPrevError
    If Not myRecordset.BOF Then
        myRecordset.MovePrevious
    End If
    If myRecordset.BOF And myRecordset.RecordCount > 0 Then
        myRecordset.MoveFirst
    Else
        If myRecordset.RecordCount > 0 Then
            Call showfld
        End If
    End If
    Exit Sub
GoPrevError:
  MsgBox Err.Description
End Sub

Private Sub cmdnext_Click()
    On Error GoTo GoNextError
    If Not myRecordset.EOF Then
        myRecordset.MoveNext
    End If
    If myRecordset.EOF And myRecordset.RecordCount > 0 Then
        myRecordset.MoveLast
    Else
        If myRecordset.RecordCount > 0 Then
            Call showfld
        End If
    End If
    Exit Sub
GoNextError:
    MsgBox Err.Description
End Sub

Private Sub Form_Load()
    Dim myPath As String
    Set myConnection = New Connection
    myConnection.CursorLocation = adUseClient
    myPath = App.Path & "\employe.mdb"
    myConnection.Open "driver={SQL Server};server=.;database=test;uid=sa;pwd=;"
    Set myRecordset = New Recordset
    myRecordset.Open "select * from 部门信息表", myConnection, adOpenStatic, adLockOptimistic
    Call inibt
    If myRecordset.BOF Then  '如果数据库为空,则开始为添加新记录状态
        cmdadd_Click
        Exit Sub
    End If
    myRecordset.MoveFirst
    Call showfld
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If myRecordset.EditMode <> 0 Then
        myRecordset.CancelUpdate  '取消数据库更新操作
    End If
    myRecordset.Close
    Set myRecordset = Nothing
End Sub


 

⌨️ 快捷键说明

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