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

📄 fmrepairafter.frm

📁 <Visual Basic 数据库开发实例精粹(第二版)>一书首先介绍了Visual Basic(简称VB)开发的技巧和重点技术
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FMRepairAfter 
   Caption         =   "维修完毕"
   ClientHeight    =   5265
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4875
   LinkTopic       =   "Form1"
   ScaleHeight     =   5265
   ScaleWidth      =   4875
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton ComdOK 
      Caption         =   "确定"
      Height          =   495
      Left            =   2160
      TabIndex        =   4
      Top             =   4680
      Width           =   855
   End
   Begin VB.CommandButton ComdCancel 
      Caption         =   "取消"
      Height          =   495
      Left            =   3480
      TabIndex        =   3
      Top             =   4680
      Width           =   855
   End
   Begin VB.Frame Frame2 
      Caption         =   "已维修"
      Height          =   4455
      Left            =   0
      TabIndex        =   0
      Top             =   120
      Width           =   4815
      Begin VB.TextBox Text1 
         Height          =   1335
         Left            =   1800
         TabIndex        =   9
         Top             =   1200
         Width           =   2775
      End
      Begin VB.TextBox TextRepairID 
         Height          =   375
         Left            =   1800
         TabIndex        =   6
         Top             =   240
         Width           =   1575
      End
      Begin VB.ComboBox Combo1 
         Height          =   300
         Left            =   1800
         TabIndex        =   5
         Top             =   720
         Width           =   1575
      End
      Begin VB.TextBox TextRemake2 
         Height          =   1455
         Left            =   1800
         TabIndex        =   1
         Top             =   2760
         Width           =   2775
      End
      Begin VB.Label Label2 
         Caption         =   "故障现象:"
         Height          =   495
         Left            =   480
         TabIndex        =   10
         Top             =   1320
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "维修单编号:"
         Height          =   255
         Left            =   480
         TabIndex        =   8
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label1 
         Caption         =   "房间编号:"
         Height          =   315
         Left            =   480
         TabIndex        =   7
         Top             =   810
         Width           =   975
      End
      Begin VB.Label Label4 
         Caption         =   "解决方法:"
         Height          =   375
         Left            =   480
         TabIndex        =   2
         Top             =   2880
         Width           =   975
      End
   End
End
Attribute VB_Name = "FMRepairAfter"
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 DelRepair As New ADODB.Recordset
  Dim DBStr As String

  Dim AutoRHID As New ADODB.Recordset
  Dim i As Integer
  Dim sRHID As String
  Dim St As String

  '自动生成维修单总编号
  St = "select RepairHisID from RepairHistory"
  AutoRHID.CursorType = adOpenStatic
  AutoRHID.CursorLocation = adUseClient
  AutoRHID.Open St, g_DBConn, adOpenForwardOnly, adLockOptimistic
    
  If AutoRHID.EOF Then
    sRHID = "001"
    'Me.TextORID.Text = sRoomConsumedID
  Else
    AutoRHID.MoveLast
    i = AutoRHID.Fields("RepairHisID").Value + 1

    If i < 10 Then
      sRHID = "00" & i
    ElseIf i >= 10 & i < 100 Then
      sRHID = "0" & i
    End If
        
  End If

  AutoRHID.Close
    
  SqlStr = "insert into RepairHistory(RepairHisID,RepairIDThen,RoomID" & ",Remake,RemakeAfter) values('" & sRHID & "'" & ",'" & Trim(Me.TextRepairID.Text) & "'" & ",'" & Trim(Me.Combo1.Text) & "'" & ",'" & Replace(Me.Text1.Text, "'", "''") & "'" & ",'" & Replace(Me.TextRemake2.Text, "'", "''") & "');"
  g_DBConn.Execute SqlStr
    
  Str = "update RoomInfo set RoomState='空房' " & "where RoomID='" & Trim(Me.Combo1.Text) & "'"
  g_DBConn.Execute Str
    
  DBStr = "select * from RepairInfo where " & "RepairID='" & Trim(Me.TextRepairID.Text) & "'"
  DelRepair.Open DBStr, g_DBConn, adOpenStatic, adLockOptimistic
  DelRepair.Delete
  DelRepair.Close
    
  Unload Me
    
End Sub

Private Sub Form_Load()
  Dim ReadRepairID As New ADODB.Recordset
  Dim Str As String

  Me.Top = (Screen.Height - Me.Height) / 2    '垂直方向居中
  Me.Left = (Screen.Width - Me.Height) / 2    '水平方向居中
    
  '读取房间编号
  Dim iRoomID As Integer
  Dim strRoomID As String
  Dim iRow, iCol As Integer

  iRow = FMMain.MSFlexGrid1.Row
  iCol = FMMain.MSFlexGrid1.Col
    
  iRoomID = 10 * iRow + iCol + 1

  If iRoomID < 10 Then
    strRoomID = "0" & iRoomID
  ElseIf iRoomID < 100 And iRoomID >= 10 Then
    strRoomID = iRoomID
  End If

  FMRepairAfter.Combo1 = strRoomID
        
  '从数据库中读取维修单编号和故障现象
  Str = "select RepairID,Remake FROM RepairInfo where " & "RoomID='" & Trim(Me.Combo1.Text) & "'"
  ReadRepairID.Open Str, g_DBConn, adOpenStatic, adLockOptimistic

  If ReadRepairID.BOF Then
    MsgBox "该维修单不存在!"
    Exit Sub
  End If

  Me.TextRepairID.Text = ReadRepairID.Fields("RepairID").Value
  Me.Text1.Text = ReadRepairID.Fields("Remake").Value
  ReadRepairID.Close
  'Me.Text1.Enabled = False
    
End Sub

⌨️ 快捷键说明

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