📄 frm_setprice.frm
字号:
Begin VB.TextBox txt_moneydel
Appearance = 0 'Flat
Height = 375
Left = -70560
TabIndex = 2
Top = 1320
Width = 1815
End
Begin VB.Label Label10
Caption = "电价编号:"
Height = 255
Left = 120
TabIndex = 19
Top = 840
Width = 975
End
Begin VB.Label Label2
Caption = "电价名称:"
Height = 255
Left = 120
TabIndex = 18
Top = 1440
Width = 1335
End
Begin VB.Label Label3
Caption = "电价金额:"
Height = 255
Left = 3480
TabIndex = 17
Top = 1440
Width = 975
End
Begin VB.Label Label4
Caption = "电价编号:"
Height = 255
Left = -74880
TabIndex = 16
Top = 840
Width = 975
End
Begin VB.Label Label5
Caption = "电价名称:"
Height = 255
Left = -74880
TabIndex = 15
Top = 1440
Width = 975
End
Begin VB.Label Label6
Caption = "电价金额:"
Height = 255
Left = -71520
TabIndex = 14
Top = 1440
Width = 975
End
Begin VB.Label Label7
Caption = "电价编号:"
Height = 255
Left = -74880
TabIndex = 13
Top = 840
Width = 975
End
Begin VB.Label Label8
Caption = "电价名称:"
Height = 255
Left = -74880
TabIndex = 12
Top = 1440
Width = 975
End
Begin VB.Label Label9
Caption = "电价金额:"
Height = 255
Left = -71520
TabIndex = 11
Top = 1440
Width = 975
End
End
Begin VB.Label Label11
BackStyle = 0 'Transparent
Caption = "设置电价"
ForeColor = &H00FF0000&
Height = 255
Left = 0
TabIndex = 20
Top = 0
Width = 1095
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "设置电价"
Height = 375
Left = 600
TabIndex = 0
Top = 480
Width = 1575
End
End
Attribute VB_Name = "frm_setprice"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
Dim i As Integer
Dim strsql As String
With MSHFlexGrid1
For i = 0 To 2
.ColWidth(i) = Me.MSHFlexGrid1.Width / 3
Next i
End With
strsql = "select * from price"
openrs strsql
Set Me.MSHFlexGrid1.DataSource = rs
clors
With MSHFlexGrid1
.TextMatrix(0, 0) = "电价编号"
.TextMatrix(0, 1) = "电价名称"
.TextMatrix(0, 2) = "电价金额"
End With
End Sub
Private Sub xpcmdbutton1_Click() '添加电价
Dim strsql As String
strsql = "select * from price"
openrs strsql
Do Until rs.EOF
If rs.Fields("price_id").Value = Trim(txt_id.Text) Then
MsgBox ("已经存在该电价编号"), vbOKOnly + vbInformation, "提示"
clors
Exit Sub
End If
rs.MoveNext
Loop
clors
strsql = "select * from price"
openrs strsql
rs.AddNew
rs.Fields("price_id") = Trim(txt_id.Text)
rs.Fields("price_name") = Trim(txt_name.Text)
rs.Fields("price_money") = Trim(txt_money.Text)
rs.UpdateBatch
clors
MsgBox ("已经成功添加电价!"), vbOKOnly + vbInformation, "提示"
strsql = "select * from price"
openrs strsql
Set Me.MSHFlexGrid1.DataSource = rs
clors
With MSHFlexGrid1
.TextMatrix(0, 0) = "电价编号"
.TextMatrix(0, 1) = "电价名称"
.TextMatrix(0, 2) = "电价金额"
End With
End Sub
Private Sub xpcmdbutton2_Click() '修改电价(此种做法可以修改电价编号)
Dim strsql As String
strsql = "select * from price where price_id='" & Trim(txt_idupdata.Text) & "' "
openrs strsql
If rs.EOF Then
MsgBox ("不存在该电价编号!"), vbOKOnly + vbInformation, "提示"
clors
Exit Sub
End If
openrs strsql
rs.Fields("price_name").Value = Trim(txt_nameupdata.Text)
rs.Fields("price_money").Value = Trim(txt_moneyupdata.Text)
rs.UpdateBatch
clors
MsgBox ("已经成功修改电价!"), vbOKOnly + vbInformation, "提示"
' txt_idupdata.Text = ""
' txt_nameupdata.Text = ""
' txt_moneyupdata.Text = ""
strsql = "select * from price"
openrs strsql
Set Me.MSHFlexGrid1.DataSource = rs
clors
With MSHFlexGrid1
.TextMatrix(0, 0) = "电价编号"
.TextMatrix(0, 1) = "电价名称"
.TextMatrix(0, 2) = "电价金额"
End With
End Sub
Private Sub xpcmdbutton3_Click() '查询电价(修改)
Dim strsql As String
strsql = "select * from price where price_id='" & Trim(txt_idupdata.Text) & "'"
openrs strsql
If rs.EOF Then
clors
MsgBox ("不存在该电价编号!"), vbOKOnly + vbInformation, "提示"
Exit Sub
End If
txt_nameupdata.Text = rs.Fields("price_name").Value
txt_moneyupdata.Text = rs.Fields("price_money").Value
clors
strsql = "select * from price"
openrs strsql
Set Me.MSHFlexGrid1.DataSource = rs
clors
With MSHFlexGrid1
.TextMatrix(0, 0) = "电价编号"
.TextMatrix(0, 1) = "电价名称"
.TextMatrix(0, 2) = "电价金额"
End With
End Sub
Private Sub xpcmdbutton4_Click() '删除电价
Dim strsql As String
strsql = "select * from price where price_id='" & Trim(txt_iddel.Text) & "' "
openrs strsql
If rs.EOF Then
MsgBox ("不存在该电价编号!"), vbOKOnly + vbInformation, "提示"
clors
Exit Sub
End If
rs.Delete
rs.UpdateBatch
clors
MsgBox ("已经成功该删除电价!"), vbOKOnly + vbInformation, "提示"
' txt_iddel.Text = ""
' txt_namedel.Text = ""
' txt_moneydel.Text = ""
strsql = "select * from price"
openrs strsql
Set Me.MSHFlexGrid1.DataSource = rs
clors
With MSHFlexGrid1
.TextMatrix(0, 0) = "电价编号"
.TextMatrix(0, 1) = "电价名称"
.TextMatrix(0, 2) = "电价金额"
End With
End Sub
Private Sub xpcmdbutton5_Click() '查询电价(删除)
Dim strsql As String
strsql = "select * from price where price_id='" & Trim(txt_iddel.Text) & "'"
openrs strsql
If rs.EOF Then
clors
MsgBox ("不存在该电价编号!"), vbOKOnly + vbInformation, "提示"
Exit Sub
End If
txt_namedel.Text = rs.Fields("price_name").Value
txt_moneydel.Text = rs.Fields("price_money").Value
clors
strsql = "select * from price"
openrs strsql
Set Me.MSHFlexGrid1.DataSource = rs
clors
With MSHFlexGrid1
.TextMatrix(0, 0) = "电价编号"
.TextMatrix(0, 1) = "电价名称"
.TextMatrix(0, 2) = "电价金额"
End With
End Sub
Private Sub xpcmdbutton6_Click() '查询电价(舔加)
Dim strsql As String
If Trim(txt_id.Text) = "" Then
MsgBox ("电价编号不能为空"), vbOKOnly + vbInformation, "提示"
Exit Sub
End If
strsql = "select * from price where price_id='" & Trim(txt_id.Text) & "'"
openrs strsql
If rs.EOF Then
MsgBox ("不存在该电价编号!"), vbOKOnly + vbInformation, "提示"
clors
Exit Sub
End If
txt_name.Text = rs.Fields("price_name").Value
txt_money.Text = rs.Fields("price_money").Value
clors
strsql = "select * from price"
openrs strsql
Set Me.MSHFlexGrid1.DataSource = rs
clors
With MSHFlexGrid1
.TextMatrix(0, 0) = "电价编号"
.TextMatrix(0, 1) = "电价名称"
.TextMatrix(0, 2) = "电价金额"
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -