大佬教程收集整理的这篇文章主要介绍了机房收费系统之上下机,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
上下机这块儿,主要是算法,很容易乱,不过有第一次 的经验,现在也有些头绪,下面和大家分享一下:
U层:
''' <sumMary> ''' 上机 ''' </sumMary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <REMARKs></REMARKs> Private Sub btnLoginIn_Click(sender As Object,e As EventArgs) Handles btnLoginIn.Click Try If txtCardNo.Text = "" Then messageBox.Show("卡号不能为空!","提示") txtCardNo.Focus() End If Dim enCardNo As New CardInfoEntity enCardNo.CardNo = txtCardNo.Text.Trim() '第一步判断该卡是否存在 Dim bllfrmMain As New frmMainBLL Dim dtCard As New DataTable dtCard = bllfrmMain.IsCardExists(enCardNo) if DtCard.Rows.Count > 0 Then '第二步判断该卡是否正在上机 Dim dtLine As DataTable dtLine = bllfrmMain.isOnline(enCardNo) if DtLine.Rows.Count = 0 Then '第三步上机并更新T_LineInfo txtCash.Text = dtCard.Rows(0).Item("Cash").ToString().Trim txtDepartment.Text = dtCard.Rows(0).Item("Department") txtType.Text = "固定用户" txtSex.Text = dtCard.Rows(0).Item("Sex") txtstudentName.Text = dtCard.Rows(0).Item("studentName") txtstudentNo.Text = dtCard.Rows(0).Item("studentNo") txtOnDate.Text = datetiR_574_11845@e.Today.ToString("yyyy-MM-dd") txtOnTime.Text = datetiR_574_11845@e.Now.ToString("HH:mm ") Dim enLine As New LineInfoEntity Dim intResult As Integer enLine.CardNo = txtCardNo.Text.Trim() enLine.studentName = dtCard.Rows(0).Item("studentName") enLine.Computer = pubshare.strComputer enLine.onDate = txtOnDate.Text.Trim() enLine.onTime = txtOnTime.Text.Trim() intResult = bllfrmMain.AddOnline(enLinE) If intResult <= 0 Then Throw New Exception("添加上机信息失败") Else Label24.Visible = True Label24.Text = "欢 迎 光 临 !" End If End If Else Throw New Exception("该卡不存在") End If Catch ex As Exception MsgBox(ex.message,MsgBoxStyle.Exclamation,"提示") End Try End Sub
''' <sumMary> ''' 下机 ''' </sumMary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <REMARKs></REMARKs> Private Sub btnLogOut_Click(sender As Object,e As EventArgs) Handles btnLogOut.Click If txtCardNo.Text.Trim = "" Then messageBox.Show("卡号不能为空!") txtCardNo.Focus() Else Call OffLine() End If End Sub这里写的过程OffLine()如下:
Public Sub OffLine() Dim enOnLine As New Entity.LineInfoEntity Dim bllAllOffLine As New QueryOnStatusBLL Dim enLine As New LineInfoEntity '更新上机信息 Dim dtOnLine As DataTable '判断DataGridView中是否存在数据 Try '第一步,判断该用户是否正在上机 enOnLine.CardNo = txtCardNo.Text.Trim dtOnLine = bllAllOffLine.SELEctOnLine(enOnLinE) if DtOnLine.Rows.Count <= 0 Then Throw New Exception("该卡尚未上机") Else '第二步,获取收费信息 Dim dtBasicData As New DataTable Dim enBasicData As New BasicDataEntity Dim bllBasicData As New BasicDataBLL dtBasicData = bllBasicData.SELEctBasicData() enBasicData.Rate = dtBasicData.Rows(0).Item("Rate") enBasicData.PrepareTime = dtBasicData.Rows(0).Item("PrepareTime") enBasicData.UnitTime = dtBasicData.Rows(0).Item("UnitTime") '第三步,获取上机信息 Dim bllQueryOnStatus As New QueryOnStatusBLL Dim dtOnlineinfo As New DataTable Dim enOnlineinfo As New LineInfoEntity enOnlineinfo.CardNo = txtCardNo.Text.Trim dtOnlineinfo = bllQueryOnStatus.SELEctOnLine(enOnlineinfo) if DtOnlineinfo.Rows.Count <= 0 Then Throw New Exception("获取上机信息失败") End If '第四步,获取卡余额信息 Dim bllCard As New CardBLL Dim dtCard As New DataTable Dim enCard As New CardInfoEntity enCard.CardNo = txtCardNo.Text.Trim dtCard = bllCard.SELEctCash(enCard) if DtCard.Rows.Count <= 0 Then Throw New Exception("获取卡余额信息失败") End If '第五步,计算消费时间和消费金额 Dim consumeTime As Integer Dim intResult As Integer enLine.offDate = datetiR_574_11845@e.Today.ToString("yyyy-MM-dd") enLine.offTime = datetiR_574_11845@e.Now.ToString("HH:mm") enOnLine.onDate = dtOnlineinfo.Rows(0).Item("OnDate") enOnLine.onTime = dtOnlineinfo.Rows(0).Item("OnTime") enLine.Note = "正常下机" 'Dim a As Date = CDate(enOnLine.offDatE) consumeTime = Val(DateDiff("n",Format(CDate(enOnLine.onDatE)),CDate(enLine.offDatE)) + DateDiff("n",CDate(enOnLine.onTimE),CDate(enLine.offTimE))) - enBasicData.PrepareTime '如果消费时间小于0 If consumeTime < 0 Then consumeTime = 0 enLine.ConsumeCash = Val("0") enLine.Cash = dtCard.Rows(0).Item("Cash") intResult = bllAllOffLine.AllOffLine(enLinE) Else Dim intCard As Integer Dim enCardInfo As New CardInfoEntity Dim bllCardInfo As New CardBLL enLine.CardNo = txtCardNo.Text.Trim '如果消费时间不是30的倍数 If consumeTime Mod 30 > enBasicData.UnitTime Then enLine.ConsumeCash = Int(consumeTime / 30) * Val(enBasicData.RatE) + Val(enBasicData.RatE) enLine.Cash = Val(dtCard.Rows(0).Item("Cash")) - Val(enLine.ConsumeCash) '更新LineInfo intResult = bllAllOffLine.AllOffLine(enLinE) '更新卡表 enCardInfo.Cash = enLine.Cash enCardInfo.CardNo = txtCardNo.Text.Trim intCard = bllCardInfo.UpdCard(enCardInfo) '将上下机信息返回到主界面 Dim enCardNO As New CardInfoEntity Dim dtLine As New DataTable Dim bllfrmMain As New frmMainBLL enCardNO.CardNo = txtCardNo.Text.Trim dtLine = bllfrmMain.LineInfo(enCardNO) txtCash.Text = dtLine.Rows(0).Item("Cash") txtConsumeCash.Text = dtLine.Rows(0).Item("ConsumeCash") txtConsumeTime.Text = Format(consumeTime / 60,"0.00") txtDepartment.Text = dtLine.Rows(0).Item("Department") txtOffDate.Text = dtLine.Rows(0).Item("OffDate").ToString txtOffTime.Text = dtLine.Rows(0).Item("OffTime").ToString txtOnDate.Text = dtLine.Rows(0).Item("OnDate").ToString txtOnTime.Text = dtLine.Rows(0).Item("OnTime").ToString txtSex.Text = dtLine.Rows(0).Item("Sex") txtstudentName.Text = dtLine.Rows(0).Item("studentName") txtstudentNo.Text = dtLine.Rows(0).Item("studentNo") txtType.Text = dtLine.Rows(0).Item("Type") Label24.Text = "欢迎下次再来!" Else enLine.ConsumeCash = Int(consumeTime / 30) * Val(enBasicData.RatE) enLine.Cash = Val(dtCard.Rows(0).Item("Cash")) - Val(enLine.ConsumeCash) '更新T_LineInfo intResult = bllAllOffLine.AllOffLine(enLinE) '更新卡表 enCardInfo.Cash = enLine.Cash enCardInfo.CardNo = txtCardNo.Text.Trim intCard = bllCardInfo.UpdCard(enCardInfo) '将上下机信息返回到主界面 Dim enCardNO As New CardInfoEntity Dim dtLine As New DataTable Dim bllfrmMain As New frmMainBLL enCardNO.CardNo = txtCardNo.Text.Trim dtLine = bllfrmMain.LineInfo(enCardNO) txtCash.Text = dtLine.Rows(0).Item("Cash") txtConsumeCash.Text = dtLine.Rows(0).Item("ConsumeCash") txtConsumeTime.Text = Format(consumeTime / 60,"0.00") txtDepartment.Text = dtLine.Rows(0).Item("Department") txtOffDate.Text = dtLine.Rows(0).Item("OffDate").ToString txtOffTime.Text = dtLine.Rows(0).Item("OffTime").ToString txtOnDate.Text = dtLine.Rows(0).Item("OnDate").ToString txtOnTime.Text = dtLine.Rows(0).Item("OnTime").ToString txtSex.Text = dtLine.Rows(0).Item("Sex") txtstudentName.Text = dtLine.Rows(0).Item("studentName") txtstudentNo.Text = dtLine.Rows(0).Item("studentNo") txtType.Text = dtLine.Rows(0).Item("Type") End If End If End If Catch ex As Exception MsgBox(ex.message,"提示") End Try End Sub这里主要是U层的计算,剩下B层,D层和其他的没有区别,在调试代码的过程中,出现了一些问题,不过也都用各种办法解决了,突然发现抛异常真的能够非常有效的提高调试的效率,而且经过对每个窗体的调试,我发现调试绝不仅仅是用F11,是有一些技巧的,学会用这些技巧感觉比把逻辑理清楚更重要,大家有什么不同的见解,希望和大家交流!
以上是大佬教程为你收集整理的机房收费系统之上下机全部内容,希望文章能够帮你解决机房收费系统之上下机所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。