📄 dbrepair.vb
字号:
Option Strict On
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Text
Public Class DBRepair
Inherits DBOperation
Private _HouseNo As String
Private _RepairNo As String
Private _EquipmentName As String
Private _RepairReason As String
Private _RepairFee As Double
Private _RepairPerson As String
Private _Result As String
Private _ReportDate As Date
Private _Memo As String
' 初始化连接数据库的字符串
Protected Const SQL_CONNECTION_STRING As String = _
"Server=localhost;" & _
"DataBase=;" & _
"Integrated Security=SSPI"
Protected Const MSDE_CONNECTION_STRING As String = _
"Server=(local)\NetSDK;" & _
"DataBase=;" & _
"Integrated Security=SSPI"
Protected Const CONNECTION_ERROR_MSG As String = _
"要运行这个实例,机器上必须安装有SQL Server " & _
"或者 MSDE,并且带有Northwind数据库"
Protected bolDidPreviouslyConnect As Boolean = False
Protected bolDidCreateTable As Boolean = False
Protected connectionString As String = SQL_CONNECTION_STRING
Property HouseNo() As String
Get
Return _HouseNo
End Get
Set(ByVal value As String)
_HouseNo = value
End Set
End Property
Property RepairNo() As String
Get
Return _RepairNo
End Get
Set(ByVal value As String)
_RepairNo = value
End Set
End Property
Property EquipmentName() As String
Get
Return _EquipmentName
End Get
Set(ByVal value As String)
_EquipmentName = value
End Set
End Property
Property RepairReason() As String
Get
Return _RepairReason
End Get
Set(ByVal value As String)
_RepairReason = value
End Set
End Property
Property RepairFee() As Double
Get
Return _RepairFee
End Get
Set(ByVal value As Double)
_RepairFee = value
End Set
End Property
Property RepairPerson() As String
Get
Return _RepairPerson
End Get
Set(ByVal value As String)
_RepairPerson = value
End Set
End Property
Property Result() As String
Get
Return _Result
End Get
Set(ByVal value As String)
_Result = value
End Set
End Property
Property Memo() As String
Get
Return _Memo
End Get
Set(ByVal value As String)
_Memo = value
End Set
End Property
Sub AddRepair()
Dim SQLString As String
Dim MSG As String
SQLString = "INSERT INTO tbRepair VALUES('" & HouseNo & "','"
SQLString += EquipmentName & "','" & RepairReason & "','"
SQLString += RepairFee & "','" & RepairPerson & "','"
SQLString += Result & "','" & Now.Date & "','"
SQLString += Memo & "')"
DBOperate(SQLString, MSG)
' MsgBox(MSG, MsgBoxStyle.Exclamation, "信息框")
End Sub
Sub DelRepair()
connectionString = SQL_CONNECTION_STRING
Dim scnnNorthwind As New SqlConnection(connectionString)
Dim scmd As New SqlCommand("DeleteRepair", scnnNorthwind)
Dim sda As New SqlDataAdapter(scmd)
Dim dsProducts As New DataSet
Dim sparCatID As New SqlParameter
With sparCatID
.ParameterName = "@RepairNo"
.SqlDbType = SqlDbType.Int
.Value = RepairNo
End With
scmd.ExecuteNonQuery()
End Sub
Function LoadRepair(ByVal FindType As Integer) As DataTable
Dim SQLString As String
Dim MSG As String
Dim Column As String = ""
Column += "RepairNo AS 维修编号,HouseNo AS 房屋编号, EquipmentName AS 设备名称,"
Column += "RepairReason AS 报修原因, RepairFee AS 维修费用,"
Column += "RepairPerson AS 维修人员, Result AS 维修结果,"
Column += "ReportDate AS 报修日期,Memo AS 备注"
If FindType = 1 Then
SQLString = "SELECT " & Column & " FROM tbRepair WHERE RepairNo = '" & RepairNo & "'"
ElseIf FindType = 2 Then
SQLString = "SELECT " & Column & " FROM tbRepair WHERE HouseNo = '" & HouseNo & "'"
ElseIf FindType = 3 Then
SQLString = "SELECT " & Column & " FROM tbRepair WHERE EquipmentName = '" & EquipmentName & "'"
ElseIf FindType = 4 Then
SQLString = "SELECT " & Column & " FROM tbRepair WHERE RepairPerson = '" & RepairPerson & "'"
End If
Return DBOperate(SQLString, MSG)
End Function
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -