机房收费系统——基本数据设定

前言

机房中基本数据设定窗体的作用是让管理员对机房的收费价格随时把控,其中,可以设定单位时间费用,最少金额,最少上机时间等等,其中任何一个数据为空都是不行的,那设置好几个弹框的话会不会影响客户体验,增强客户体验的舒适度是我们要重视的。很多网页登录界面输入框为空时字体为红以提示用户,我就借鉴的这种办法,看看效果吧!
机房收费系统——基本数据设定_第1张图片

机房收费系统——基本数据设定_第2张图片

部分代码片段

初始设置的窗体中的文本框内容不得修改。

'窗体初始设置
Private Sub Form_Load()
    txtRegularCost.Text = 2
    txtInterimCost.Text = 3
    txtUpTime.Text = 30
    txtOnTime.Text = 2
    txtPreTime.Text = 2
    txtMinCost.Text = 5
    
    txtRegularCost.Enabled = False
    txtInterimCost.Enabled = False
    txtUpTime.Enabled = False
    txtOnTime.Enabled = False
    txtPreTime.Enabled = False
    txtMinCost.Enabled = False
    
    cmdDetermine.Enabled = True
End Sub

文本框为空时红字以提示客户。让窗体运行时*号不可见。

Private Sub Form_Load()
	Label13.Visible = False
	Label14.Visible = False
	Label15.Visible = False
	Label16.Visible = False
	Label17.Visible = False
	Label18.Visible = False
End Sub

Private Sub cmdDetermine_Click()
	If Trim(txtRegularCost.Text) = "" Then
	        Label13.Visible = True
	        Label13.ForeColor = vbRed
	        Label1.ForeColor = vbRed
	        Exit Sub
	    End If
	    
	    If Trim(txtInterimCost.Text) = "" Then
	        Label14.Visible = True
	        Label14.ForeColor = vbRed
	        Label3.ForeColor = vbRed
	        Exit Sub
	    End If
	    
	    If Trim(txtUpTime.Text) = "" Then
	        Label15.Visible = True
	        Label15.ForeColor = vbRed
	        Label5.ForeColor = vbRed
	        Exit Sub
	    End If
	
	    If Trim(txtOnTime.Text) = "" Then
	        Label16.Visible = True
	        Label16.ForeColor = vbRed
	        Label7.ForeColor = vbRed
	        Exit Sub
	    End If
	    
	    If Trim(txtPreTime.Text) = "" Then
	        Label17.Visible = True
	        Label17.ForeColor = vbRed
	        Label9.ForeColor = vbRed
	        Exit Sub
	    End If
	    
	    If Trim(txtMinCost.Text) = "" Then
	        Label18.Visible = True
	        Label18.ForeColor = vbRed
	        Label11.ForeColor = vbRed
	        Exit Sub
	    End If
End Sub

修改信息时文本框可改。

'修改信息
Private Sub cmdModify_Click()
    txtRegularCost.Enabled = True
    txtInterimCost.Enabled = True
    txtUpTime.Enabled = True
    txtOnTime.Enabled = True
    txtPreTime.Enabled = True
    txtMinCost.Enabled = True
    
    cmdDetermine.Enabled = True
End Sub

用户点击确定后,将数据更新到数据库,更新成功后要让确定按钮不可点击。

'确定设置内容
Private Sub cmdDetermine_Click()
    
    txtSQL = "select * from basicdata_info"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    
    If mrc.EOF = False Then
        mrc.Delete
        Exit Sub
    Else
        mrc.AddNew
        mrc.Fields(0) = txtRegularCost.Text
        mrc.Fields(1) = txtInterimCost.Text
        mrc.Fields(2) = txtUpTime.Text
        mrc.Fields(3) = txtOnTime.Text
        mrc.Fields(4) = txtPreTime.Text
        mrc.Fields(5) = txtMinCost.Text
        mrc.Fields(6) = userName
        mrc.Fields(7) = Date
        mrc.Fields(8) = Time
        mrc.Update
        mrc.Close
        MsgBox "基本数据设定成功!", 48, "提示"
    End If
    
    txtRegularCost.Enabled = False
    txtInterimCost.Enabled = False
    txtUpTime.Enabled = False
    txtOnTime.Enabled = False
    txtPreTime.Enabled = False
    txtMinCost.Enabled = False
    cmdDetermine.Enabled = False
End Sub

取消修改其中分为几种情况,1.已经修改没确定取消,要对客户进行提醒,取消后数据将不会保存。2.已经修改点击确定后取消,直接让窗体隐藏即可。3.什么也没有修改点击取消,隐藏窗体即可。

'取消修改
Private Sub cmdExit_Click()
Dim mcclean As Integer

    If mcclean = True And cmdDetermine.Enabled = True Then
        MsgBox "取消后修改的数据不会更新哦!", 48, "提示"
        Me.Hide
        Exit Sub
    Else
        Me.Hide
    End If
End Sub

结语

看起来不起眼的窗体也要捋清思路,不然看起来简单,做起来就会遇到问题。多思考,继续加油!

你可能感兴趣的:(---机房收费系统,机房收费系统)