📄 form2.frm
字号:
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "时到"
Height = 255
Index = 3
Left = 1680
TabIndex = 12
Top = 1560
Width = 375
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "从"
Height = 255
Index = 3
Left = 480
TabIndex = 11
Top = 1440
Width = 255
End
End
Begin VB.CommandButton Command2
Caption = "修改"
Height = 276
Left = 4320
TabIndex = 3
Top = 3480
Width = 615
End
Begin VB.TextBox Text2
Height = 264
Left = 2520
TabIndex = 0
Top = 3480
Width = 615
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "机器数量"
Height = 255
Left = 1440
TabIndex = 2
Top = 3480
Width = 975
End
Begin VB.Label Label3
Caption = "台"
Height = 255
Left = 3240
TabIndex = 1
Top = 3540
Width = 255
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Dim rs1 As New ADODB.Recordset
Dim rsprice As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim iskt As Boolean
Dim isjstchkt As Boolean
Dim timefd As Integer
'Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub Command1_Click()
Dim i As Integer
isjstchkt = False
iskt = False
For i = 0 To 3
Label1(i).Visible = False
Label2(i).Visible = False
Label5(i).Visible = False
Label6(i).Visible = False
lststime(i).Enabled = False
lststime(i).ListIndex = 0
lststime(i).Visible = False
lstetime(i).Visible = False
lstetime(i).Enabled = False
lstetime(i).ListIndex = 0
txtprice(i).Visible = False
txtprice(i).Text = ""
Next i
Label1(0).Visible = True
Label2(0).Visible = True
Label5(0).Visible = True
Label6(0).Visible = True
lststime(0).Visible = True
lststime(0).Enabled = True
lstetime(0).Visible = True
lstetime(0).Enabled = True
txtprice(0).Visible = True
Command3.Enabled = False
End Sub
Private Sub Command2_Click()
If Not IsNumeric(Text2.Text) Then
MsgBox "机器数量输入错误"
Text2.Text = rs2!jqsl
Exit Sub
End If
rs2!jqsl = Val(Text2.Text)
rs2.Update
jqcount = Val(Text2.Text)
sykw = jqcount - zxrs
Form1.lsykw.Caption = Str(sykw)
End Sub
Private Sub Command3_Click()
Dim i As Integer
Dim rsxx As New ADODB.Recordset
timefd = 0
For i = 0 To 3
If lststime(i).Visible = True Then timefd = timefd + 1
Next i
Call bas.openrs(rsxx, "delete from 价格表")
Set rsxx = Nothing
rsprice.Requery
For i = 1 To timefd
rsprice.AddNew
rsprice!bh = i
rsprice!stime = TimeSerial(Val(lststime(i - 1).Text), 0, 0)
rsprice!etime = TimeSerial(Val(lstetime(i - 1).Text), 0, 0)
rsprice!price = CCur(Val(txtprice(i - 1).Text))
If Val(lstetime(i - 1).Text) >= Val(lststime(i - 1).Text) Then
rsprice!s2eprice = IIf(Val(lstetime(i - 1).Text) = Val(lststime(i - 1).Text), Val(txtprice(i - 1).Text) * 24, (Val(lstetime(i - 1).Text) - Val(lststime(i - 1).Text)) * Val(txtprice(i - 1).Text))
Else
rsprice!s2eprice = (Val(lstetime(i - 1).Text) - Val(lststime(i - 1).Text) + 24) * Val(txtprice(i - 1).Text)
End If
rsprice.Update
Next i
Command3.Enabled = False
End Sub
Private Sub Form_Load()
Dim i, j, fenduan As Integer
iskt = False
For i = 0 To 3
Label1(i).Visible = False
Label2(i).Visible = False
Label5(i).Visible = False
Label6(i).Visible = False
lststime(i).Visible = False
lstetime(i).Visible = False
txtprice(i).Visible = False
For j = 0 To 23
lststime(i).AddItem Str(j), j
lstetime(i).AddItem Str(j), j
Next j
Next i
Call bas.openrs(rsprice, "select * from 价格表 order by bh")
fenduan = bas.rscount(rsprice)
rsprice.MoveFirst
For i = 0 To fenduan - 1
Label1(i).Visible = True
Label2(i).Visible = True
Label5(i).Visible = True
Label6(i).Visible = True
lststime(i).Visible = True
lststime(i).Enabled = False
lststime(i).ListIndex = Hour(rsprice!stime)
lstetime(i).Visible = True
lstetime(i).Enabled = False
lstetime(i).ListIndex = Hour(rsprice!etime)
txtprice(i).Visible = True
txtprice(i).Text = Str(rsprice!price)
rsprice.MoveNext
Next i
Command3.Enabled = False
Call bas.openrs(rs2, "select jqsl from 机器数量")
Text2.Text = rs2!jqsl
End Sub
Private Sub Form_Unload(Cancel As Integer)
rs2.Close
Set rs2 = Nothing
rsprice.Close
Set rsprice = Nothing
End Sub
Private Sub lstetime_Click(Index As Integer)
If lstetime(Index).Enabled = False Then Exit Sub
isjstchkt = False
If lststime(0).Enabled = True Then lststime(0).Enabled = False
If Val(lstetime(Index).Text) < Val(lststime(Index).Text) Then
If Not iskt Then
If Val(lstetime(Index).Text) > Val(lststime(0).Text) And Index > 0 Then
MsgBox "时间选择错误"
Exit Sub
Else
iskt = True
isjstchkt = True
End If
End If
End If
If Val(lstetime(Index).Text) < Val(lststime(Index).Text) And iskt And Not isjstchkt Then
If Index > 0 Then
MsgBox "时间选择错误"
Exit Sub
End If
End If
If Val(lstetime(Index).Text) > Val(lststime(0).Text) And iskt And Not isjstchkt Then
If Index > 0 Then
MsgBox "时间选择错误"
Exit Sub
End If
End If
lstetime(Index).Enabled = False
Select Case Index
Case 0, 1
'Case 1
If lstetime(Index).Text = lststime(0).Text Then
Command3.Enabled = True
Else
lstetime(Index).Enabled = False
Label1(Index + 1).Visible = True
Label2(Index + 1).Visible = True
Label5(Index + 1).Visible = True
Label6(Index + 1).Visible = True
lststime(Index + 1).Visible = True
lststime(Index + 1).Enabled = False
lststime(Index + 1).ListIndex = Val(lstetime(Index).Text)
lstetime(Index + 1).Visible = True
lstetime(Index + 1).Enabled = True
txtprice(Index + 1).Visible = True
End If
Case 2
If lstetime(Index).Text = lststime(0).Text Then
Command3.Enabled = True
Else
lstetime(Index).Enabled = False
Label1(Index + 1).Visible = True
Label2(Index + 1).Visible = True
Label5(Index + 1).Visible = True
Label6(Index + 1).Visible = True
lststime(Index + 1).Visible = True
lststime(Index + 1).Enabled = False
lststime(Index + 1).ListIndex = Val(lstetime(Index).Text)
lstetime(Index + 1).Visible = True
lstetime(Index + 1).ListIndex = lststime(0).ListIndex
txtprice(Index + 1).Visible = True
Command3.Enabled = True
End If
End Select
End Sub
Private Sub txtprice_Change(Index As Integer)
If Command3.Enabled = False Then Command3.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -