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

📄 fmrepair.frm

📁 <Visual Basic 数据库开发实例精粹(第二版)>一书首先介绍了Visual Basic(简称VB)开发的技巧和重点技术
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FMRepair 
   Caption         =   "维修单"
   ClientHeight    =   3585
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5010
   LinkTopic       =   "Form1"
   ScaleHeight     =   3585
   ScaleWidth      =   5010
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton ComdCancel 
      Caption         =   "取消"
      Height          =   495
      Left            =   3720
      TabIndex        =   4
      Top             =   3000
      Width           =   855
   End
   Begin VB.CommandButton ComdOK 
      Caption         =   "确定"
      Height          =   495
      Left            =   2400
      TabIndex        =   3
      Top             =   3000
      Width           =   855
   End
   Begin VB.Frame Frame1 
      Caption         =   "未维修"
      Height          =   2775
      Left            =   0
      TabIndex        =   0
      Top             =   120
      Width           =   4935
      Begin VB.TextBox TextRepairID 
         Height          =   375
         Left            =   2040
         TabIndex        =   6
         Top             =   240
         Width           =   1575
      End
      Begin VB.ComboBox Combo1 
         Height          =   300
         Left            =   2040
         TabIndex        =   5
         Top             =   720
         Width           =   1575
      End
      Begin VB.TextBox Text1 
         Height          =   1335
         Left            =   2040
         TabIndex        =   1
         Top             =   1200
         Width           =   2775
      End
      Begin VB.Label Label3 
         Caption         =   "维修单编号:"
         Height          =   255
         Left            =   600
         TabIndex        =   8
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label1 
         Caption         =   "房间编号:"
         Height          =   315
         Left            =   600
         TabIndex        =   7
         Top             =   750
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "故障现象:"
         Height          =   495
         Left            =   600
         TabIndex        =   2
         Top             =   1200
         Width           =   975
      End
   End
End
Attribute VB_Name = "FMRepair"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub ComdCancel_Click()
  Unload Me
End Sub

Private Sub ComdOK_Click()
  Dim SqlStr As String
  Dim Str As String
  Dim sRoomID As String

  If Me.Combo1.Text = "" Then
    MsgBox "请选择要维修的房间!"
    Exit Sub
  End If
    
  sRoomID = Trim(Me.Combo1.Text)
  SqlStr = "insert into RepairInfo(RepairID,RoomID,Remake)" & "values ('" & Trim(Me.TextRepairID.Text) & "'" & ",'" & Trim(Me.Combo1.Text) & "'" & ",'" & Replace(Me.Text1.Text, "'", "''") & "');"
  g_DBConn.Execute SqlStr
  Str = "update RoomInfo set RoomState='维修' where RoomID='" & sRoomID & "'"
  g_DBConn.Execute Str
  MsgBox "成功!"
    
  Me.TextRepairID.Text = ""
  Me.Combo1.Text = ""
  Me.Text1.Text = ""
    
  Unload Me
    
End Sub

Private Sub Form_Load()
  Dim DBStr As String
  Dim AddRepairID As New ADODB.Recordset
  Dim i As Integer
  Dim sRepairID As String

  Me.Top = (Screen.Height - Me.Height) / 2    '垂直方向居中
  Me.Left = (Screen.Width - Me.Height) / 2    '水平方向居中
    
  '自动生成维修单编号
  DBStr = "select RepairID from RepairInfo"
  AddRepairID.CursorType = adOpenStatic
  AddRepairID.CursorLocation = adUseClient
  AddRepairID.Open DBStr, g_DBConn, adOpenStatic, adLockOptimistic
    
  If AddRepairID.EOF Then
    sRepairID = "001"
    Me.TextRepairID.Text = sRepairID
  Else
    AddRepairID.MoveLast
    i = AddRepairID.Fields("RepairID").Value + 1

    If i < 10 Then
      Me.TextRepairID.Text = "00" & i
    ElseIf i >= 10 & i < 100 Then
      Me.TextRepairID.Text = "0" & i
    End If
        
  End If
    
  AddRepairID.Close
  Me.TextRepairID.Enabled = False
    
  '从数据库中读取数据写入房间编号下拉列表框
  Dim adoRs As New ADODB.Recordset
  DBStr = "select RoomID from RoomInfo where RoomState='空房' or RoomState='打扫' "
  adoRs.Open DBStr, g_DBConn, adOpenStatic, adLockReadOnly

  If adoRs.RecordCount > 0 Then
    adoRs.MoveFirst

    Do While Not adoRs.EOF
      Combo1.AddItem adoRs.Fields(0).Value
      adoRs.MoveNext
    Loop

  End If

  adoRs.Close
  Set adoRs = Nothing
End Sub

⌨️ 快捷键说明

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