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

📄 frmdata.frm

📁 一个水情自动测报系统的接收例程
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmdata 
   ClientHeight    =   4596
   ClientLeft      =   1104
   ClientTop       =   1236
   ClientWidth     =   7896
   Icon            =   "frmdata.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   ScaleHeight     =   4596
   ScaleWidth      =   7896
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   3720
      Top             =   2160
      _ExtentX        =   677
      _ExtentY        =   677
      _Version        =   393216
   End
   Begin VB.PictureBox picButtons 
      Align           =   2  'Align Bottom
      Appearance      =   0  'Flat
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   300
      Left            =   0
      ScaleHeight     =   300
      ScaleWidth      =   7896
      TabIndex        =   7
      Top             =   3996
      Width           =   7896
      Begin VB.CommandButton cmdCancel 
         Caption         =   "取消(&C)"
         Height          =   300
         Left            =   1213
         TabIndex        =   14
         Top             =   0
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.CommandButton cmdUpdate 
         Caption         =   "更新(&U)"
         Height          =   300
         Left            =   59
         TabIndex        =   13
         Top             =   0
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.CommandButton cmdClose 
         Caption         =   "关闭(&C)"
         Height          =   300
         Left            =   4675
         TabIndex        =   12
         Top             =   0
         Width           =   1095
      End
      Begin VB.CommandButton cmdRefresh 
         Caption         =   "刷新(&R)"
         Height          =   300
         Left            =   3521
         TabIndex        =   11
         Top             =   0
         Width           =   1095
      End
      Begin VB.CommandButton cmdDelete 
         Caption         =   "删除(&D)"
         Height          =   300
         Left            =   2367
         TabIndex        =   10
         Top             =   0
         Width           =   1095
      End
      Begin VB.CommandButton cmdEdit 
         Caption         =   "编辑(&E)"
         Height          =   300
         Left            =   1213
         TabIndex        =   9
         Top             =   0
         Width           =   1095
      End
      Begin VB.CommandButton cmdAdd 
         Caption         =   "添加(&A)"
         Height          =   300
         Left            =   59
         TabIndex        =   8
         Top             =   0
         Width           =   1095
      End
   End
   Begin VB.PictureBox picStatBox 
      Align           =   2  'Align Bottom
      Appearance      =   0  'Flat
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   300
      Left            =   0
      ScaleHeight     =   300
      ScaleWidth      =   7896
      TabIndex        =   1
      Top             =   4296
      Width           =   7896
      Begin VB.CommandButton cmdLast 
         Height          =   300
         Left            =   4545
         Picture         =   "frmdata.frx":0442
         Style           =   1  'Graphical
         TabIndex        =   5
         Top             =   0
         UseMaskColor    =   -1  'True
         Width           =   345
      End
      Begin VB.CommandButton cmdNext 
         Height          =   300
         Left            =   4200
         Picture         =   "frmdata.frx":0784
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   0
         UseMaskColor    =   -1  'True
         Width           =   345
      End
      Begin VB.CommandButton cmdPrevious 
         Height          =   300
         Left            =   345
         Picture         =   "frmdata.frx":0AC6
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   0
         UseMaskColor    =   -1  'True
         Width           =   345
      End
      Begin VB.CommandButton cmdFirst 
         Height          =   300
         Left            =   0
         Picture         =   "frmdata.frx":0E08
         Style           =   1  'Graphical
         TabIndex        =   2
         Top             =   0
         UseMaskColor    =   -1  'True
         Width           =   345
      End
      Begin VB.Label lblStatus 
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   1  'Fixed Single
         Height          =   285
         Left            =   690
         TabIndex        =   6
         Top             =   0
         Width           =   3360
      End
   End
   Begin MSDataGridLib.DataGrid grdDataGrid 
      Align           =   1  'Align Top
      Height          =   3504
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   7896
      _ExtentX        =   13928
      _ExtentY        =   6181
      _Version        =   393216
      AllowUpdate     =   -1  'True
      HeadLines       =   1
      RowHeight       =   15
      AllowAddNew     =   -1  'True
      AllowDelete     =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Menu DFFD 
      Caption         =   "操作"
      Begin VB.Menu SADASD 
         Caption         =   "刷新表格"
      End
      Begin VB.Menu PRIN 
         Caption         =   "打印表格"
      End
      Begin VB.Menu szfdzf 
         Caption         =   "改变背景色"
      End
      Begin VB.Menu sdsdad 
         Caption         =   "改变表格字体"
      End
      Begin VB.Menu sfdsfsdf 
         Caption         =   "改变首行字体"
      End
      Begin VB.Menu WAEWR 
         Caption         =   "过滤数据"
      End
      Begin VB.Menu SDSAD 
         Caption         =   "对表格排序"
      End
   End
End
Attribute VB_Name = "frmdata"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const hangshu = 35
Dim WithEvents adoPrimaryRS As Recordset
Attribute adoPrimaryRS.VB_VarHelpID = -1
Dim mbChangedByCode As Boolean
Dim mvBookMark As Variant
Dim mbEditFlag As Boolean
Dim mbAddNewFlag As Boolean
Dim mbDataChanged As Boolean
Dim msSortCol As String

Private Sub Form_Load()
    Dim kas
    Dim kas1 As String
    Dim aow As Boolean
    
    On Error Resume Next

    kas = GetSetting(appname:=App.title, section:="BACKGROUND", _
                       Key:="Color", Default:=-1)
    If kas = -1 Then
    SaveSetting appname:=App.title, section:="BACKGROUND", _
            Key:="Color", setting:=Me.grdDataGrid.BackColor
    Else
    Me.grdDataGrid.BackColor = kas
    End If
   
    
    aow = False
    
    kas1 = GetSetting(appname:=App.title, section:="FONT", _
                       Key:="Name")
    If kas1 = "" Then
    SaveSetting appname:=App.title, section:="FONT", _
            Key:="Name", setting:=Me.grdDataGrid.Font.Name
    Else
    aow = True
    Me.grdDataGrid.Font.Name = kas1
    End If
        
    If aow Then
    Me.grdDataGrid.Font.Size = GetSetting(appname:=App.title, section:="FONT", _
                       Key:="Size")
    Else
    SaveSetting appname:=App.title, section:="FONT", _
            Key:="Size", setting:=Me.grdDataGrid.Font.Size
    End If
    
    If aow Then
    Me.grdDataGrid.Font.Bold = GetSetting(appname:=App.title, section:="FONT", _
                       Key:="Bold")
    Else
    SaveSetting appname:=App.title, section:="FONT", _
            Key:="Bold", setting:=Me.grdDataGrid.Font.Bold
    End If
    
    
    
    If aow Then
    Me.grdDataGrid.Font.Italic = GetSetting(appname:=App.title, section:="FONT", _
                       Key:="Italic")
    Else
    SaveSetting appname:=App.title, section:="FONT", _
            Key:="Italic", setting:=Me.grdDataGrid.Font.Italic
    End If
    
    
    
    If aow Then
    Me.grdDataGrid.Font.Underline = GetSetting(appname:=App.title, section:="FONT", _
                       Key:="Underline")
    Else
    SaveSetting appname:=App.title, section:="FONT", _
            Key:="Underline", setting:=Me.grdDataGrid.Font.Underline
    End If
    
    
    
    If aow Then
    Me.grdDataGrid.ForeColor = GetSetting(appname:=App.title, section:="FONT", _
                       Key:="ForeColor")
    Else
    SaveSetting appname:=App.title, section:="FONT", _
            Key:="ForeColor", setting:=Me.grdDataGrid.ForeColor
    End If



    aow = False
    kas1 = GetSetting(appname:=App.title, section:="HeadFont", _
                       Key:="Name")
    If kas1 = "" Then
    SaveSetting appname:=App.title, section:="HeadFont", _
            Key:="Name", setting:=Me.grdDataGrid.HeadFont.Name
    Else
    aow = True
    Me.grdDataGrid.HeadFont.Name = kas1
    End If
        
    If aow Then
    Me.grdDataGrid.HeadFont.Size = GetSetting(appname:=App.title, section:="HeadFont", _
                       Key:="Size")
    Else
    SaveSetting appname:=App.title, section:="HeadFont", _
            Key:="Size", setting:=Me.grdDataGrid.HeadFont.Size
    End If
    
    If aow Then
    Me.grdDataGrid.HeadFont.Bold = GetSetting(appname:=App.title, section:="HeadFont", _
                       Key:="Bold")
    Else
    SaveSetting appname:=App.title, section:="HeadFont", _
            Key:="Bold", setting:=Me.grdDataGrid.HeadFont.Bold
    End If
    
    
    
    If aow Then
    Me.grdDataGrid.HeadFont.Italic = GetSetting(appname:=App.title, section:="HeadFont", _
                       Key:="Italic")
    Else
    SaveSetting appname:=App.title, section:="HeadFont", _
            Key:="Italic", setting:=Me.grdDataGrid.HeadFont.Italic
    End If
    
    
    
    If aow Then
    Me.grdDataGrid.HeadFont.Underline = GetSetting(appname:=App.title, section:="HeadFont", _
                       Key:="Underline")
    Else
    SaveSetting appname:=App.title, section:="HeadFont", _
            Key:="Underline", setting:=Me.grdDataGrid.HeadFont.Underline
    End If
    
  Set adoPrimaryRS = New Recordset
  adoPrimaryRS.Open sql_string, DB1, adOpenStatic, adLockOptimistic
  Me.Caption = frmdata_caption
  Set grdDataGrid.DataSource = adoPrimaryRS
  mbDataChanged = False
End Sub

Private Sub Form_Resize()
  On Error Resume Next
  '当窗体调整时会调整网格
  grdDataGrid.Height = Me.ScaleHeight - 30 - picButtons.Height - picStatBox.Height
  lblStatus.Width = Me.Width - 1500
  cmdNext.Left = lblStatus.Width + 700
  cmdLast.Left = cmdNext.Left + 340
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next

  If mbEditFlag Or mbAddNewFlag Then Exit Sub

  Select Case KeyCode
    Case vbKeyEscape
      cmdClose_Click
    Case vbKeyEnd
      cmdLast_Click
    Case vbKeyHome
      cmdFirst_Click
    Case vbKeyUp, vbKeyPageUp
      If Shift = vbCtrlMask Then
        cmdFirst_Click
      Else
        cmdPrevious_Click
      End If
    Case vbKeyDown, vbKeyPageDown
      If Shift = vbCtrlMask Then
        cmdLast_Click
      Else
        cmdNext_Click
      End If
  End Select
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next

  Screen.MousePointer = vbDefault
End Sub

Private Sub adoPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error Resume Next
  '为这个 recordset 显示当前记录位置
  lblStatus.Caption = "Record: " & CStr(adoPrimaryRS.AbsolutePosition)
End Sub

Private Sub adoPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  '验证代码置于此处
  '下列动作发生时该事件被调用
  Dim bCancel As Boolean
On Error Resume Next

  Select Case adReason
  Case adRsnAddNew
  Case adRsnClose
  Case adRsnDelete
  Case adRsnFirstChange
  Case adRsnMove
  Case adRsnRequery
  Case adRsnResynch
  Case adRsnUndoAddNew
  Case adRsnUndoDelete
  Case adRsnUndoUpdate
  Case adRsnUpdate
  End Select

  If bCancel Then adStatus = adStatusCancel
End Sub

Private Sub cmdAdd_Click()
  On Error GoTo AddErr

⌨️ 快捷键说明

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