📄 frmdevice.frm
字号:
Left = 4200
Top = 5040
Visible = 0 'False
Width = 1815
_ExtentX = 3201
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataListLib.DataCombo dco_TypeId
Height = 330
Left = 3120
TabIndex = 8
Top = 165
Width = 1575
_ExtentX = 2778
_ExtentY = 582
_Version = 393216
Style = 2
Text = ""
End
Begin MSDataListLib.DataCombo dco_Branch
Height = 330
Left = 5760
TabIndex = 10
Top = 165
Width = 1575
_ExtentX = 2778
_ExtentY = 582
_Version = 393216
Style = 2
Text = ""
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "所属支行"
Height = 180
Left = 4920
TabIndex = 11
Top = 240
Width = 720
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "设备分类"
Height = 180
Left = 2280
TabIndex = 9
Top = 240
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "设备编号"
Height = 180
Left = 240
TabIndex = 1
Top = 240
Width = 720
End
End
Attribute VB_Name = "FrmDevice"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private SchCnd As String
Private Sub Cmd_Add_Click()
'将Modify变量设置为False,表示当前状态为插入新记录
FrmDeviceEdit.Modify = False
'初始化FrmDeviceEdit信息
FrmDeviceEdit.txtDevNo = "" '设备编号
FrmDeviceEdit.txtModel = "" '设备型号
FrmDeviceEdit.txtPrice = 0 '单价
FrmDeviceEdit.txtPlace = "" '数量
FrmDeviceEdit.dtStartDate = Now '开通时间
FrmDeviceEdit.txtAdmin = "" '管理员
FrmDeviceEdit.txtPoster = CurUser.UserName '提交人
'启动编辑窗体
FrmDeviceEdit.Show 1
'刷新DataGrid表格的内容
GridRefresh
End Sub
Private Sub Cmd_Del_Click()
If Adodc1.Recordset.EOF = True Then
MsgBox "请选择记录"
Exit Sub
End If
If MsgBox("是否确定要删除 ", vbYesNo, "请确认") = vbNo Then
Exit Sub
End If
MyDevice.Delete (Trim(Adodc1.Recordset.Fields(0))) '删除设备信息
GridRefresh '刷新DataGrid表格的内容
End Sub
Private Sub Cmd_Exit_Click()
Unload Me
End Sub
Private Sub GridRefresh()
'判断是否有查询字段
If Len(Trim(txtDevNo)) = 0 Then
SchCnd = ""
Else '设置查询条件
SchCnd = " AND d.DevNo = '" + Trim(txtDevNo) + "'"
End If
If Len(Trim(dco_TypeId.Text)) > 0 Then
SchCnd = SchCnd + " AND d.TypeId =" + Trim(dco_TypeId.BoundText())
End If
If Len(Trim(dco_Branch.Text)) > 0 Then
SchCnd = SchCnd + " AND d.BranchID = " + Trim(dco_Branch.BoundText())
End If
Adodc1.ConnectionString = Conn '设置连接字符串
Adodc1.RecordSource = "SELECT d.DevNo AS 设备编号,t1.InfoName AS 分类," _
+ " t2.InfoName As 设备品牌, d.Model AS 设备型号, d.Price AS 购买价格," _
+ "d.Place AS 布放地点, t3.InfoName AS 所属支行, d.StartDate AS 开通时间," _
+ "d.Administrator AS 管理员,d.Poster AS 提交人, d.Status As 状态 " _
+ " FROM Device d,BaseInfo t1, BaseInfo t2, BaseInfo t3" _
+ " WHERE d.TypeId=t1.InfoId And d.EnterpriseID=t2.InfoId And d.BranchID=t3.InfoId " _
+ SchCnd + " ORDER BY d.DevNo"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1 '设置数据源
DataGrid1.Columns(0).Width = 800 '设置列宽度
DataGrid1.Columns(1).Width = 1200
DataGrid1.Columns(2).Width = 1200
DataGrid1.Columns(3).Width = 1200
DataGrid1.Columns(4).Width = 1200
DataGrid1.Columns(5).Width = 1000
DataGrid1.Columns(6).Width = 1200
DataGrid1.Columns(7).Width = 800
DataGrid1.Columns(8).Width = 1200
DataGrid1.Columns(9).Width = 1200
DataGrid1.Columns(10).Width = 1200
End Sub
'修改
Private Sub Cmd_Modi_Click()
If Adodc1.Recordset.EOF = True Then
MsgBox "请选择记录"
Exit Sub
End If
'将Modify变量设置为False,表示当前状态为插入新记录
FrmDeviceEdit.Modify = True
'初始化FrmDeviceEdit信息
FrmDeviceEdit.OriId = Trim(Adodc1.Recordset.Fields(0)) '设备编号
FrmDeviceEdit.txtDevNo = Trim(Adodc1.Recordset.Fields(0)) '设备编号
FrmDeviceEdit.dco_TypeId.Text = Trim(Adodc1.Recordset.Fields(1)) '分类编号
FrmDeviceEdit.dco_Enterprise.Text = Trim(Adodc1.Recordset.Fields(2)) '设备品牌
FrmDeviceEdit.txtModel = Trim(Adodc1.Recordset.Fields(3)) '设备型号
FrmDeviceEdit.txtPrice = Trim(Adodc1.Recordset.Fields(4)) '购买价格
FrmDeviceEdit.txtPlace = Trim(Adodc1.Recordset.Fields(5)) '布放地点
FrmDeviceEdit.dco_Branch.Text = Trim(Adodc1.Recordset.Fields(6)) '支行
FrmDeviceEdit.dtStartDate.Value = Trim(Adodc1.Recordset.Fields(7)) '开通时间
FrmDeviceEdit.txtAdmin = Trim(Adodc1.Recordset.Fields(8)) '管理员
FrmDeviceEdit.txtPoster = Trim(Adodc1.Recordset.Fields(9)) ' 提交人
'编辑时设备编号和数量不能更改
FrmDeviceEdit.txtDevNo.Enabled = False
'启动编辑窗体
FrmDeviceEdit.Show 1
GridRefresh '刷新DataGrid表格的内容
End Sub
Private Sub Cmd_Reset_Click()
SchCnd = ""
txtDevNo = ""
dco_TypeId.Text = ""
dco_Branch.Text = ""
GridRefresh
End Sub
Private Sub Cmd_Search_Click()
GridRefresh
End Sub
Private Sub Form_Load()
' 设备分类信息
Adodc2.ConnectionString = Conn '设置连接字符串
Adodc2.RecordSource = "SELECT * FROM BaseInfo WHERE TypeId=1" '选择设备分类
Adodc2.Refresh
Set dco_TypeId.RowSource = Adodc2 '绑定数据源
dco_TypeId.ListField = "InfoName" '显示列名
dco_TypeId.BoundColumn = "InfoId" '绑定列值
' 支行信息
Adodc3.ConnectionString = Conn '设置连接字符串
Adodc3.RecordSource = "SELECT * FROM BaseInfo WHERE TypeId=3" '选择支行
Adodc3.Refresh
Set dco_Branch.RowSource = Adodc3 '绑定数据源
dco_Branch.ListField = "InfoName" '显示列名
dco_Branch.BoundColumn = "InfoId" '绑定列值
'刷新设备信息
GridRefresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -