📄 taxi.vb
字号:
iFee = System.Math.Floor(iFee)
End If
Fee.Text = Str(System.Math.Floor(iFee)) + "元"
End If
End Sub
Private Sub N1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N1.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N1.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N1.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N1.Text
End If
End Sub
Private Sub N2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N2.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N2.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N2.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N2.Text
End If
End Sub
Private Sub N3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N3.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N3.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N3.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N3.Text
End If
End Sub
Private Sub N4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N4.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N4.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N4.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N4.Text
End If
End Sub
Private Sub N5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N5.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N5.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N5.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N5.Text
End If
End Sub
Private Sub N6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N6.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N6.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N6.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N6.Text
End If
End Sub
Private Sub N7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N7.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N7.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N7.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N7.Text
End If
End Sub
Private Sub N8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N8.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N8.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N8.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N8.Text
End If
End Sub
Private Sub N9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N9.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N9.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N9.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N9.Text
End If
End Sub
Private Sub N0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N0.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + N0.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + N0.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + N0.Text
End If
End Sub
Private Sub Ndot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ndot.Click
If iFocus = 1 Then
thisDistance.Text = thisDistance.Text + Ndot.Text
End If
If iFocus = 2 Then
ThisTime.Text = ThisTime.Text + Ndot.Text
End If
If iFocus = 3 Then
ZK.Text = ZK.Text + Ndot.Text
End If
End Sub
Private Sub ZK_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ZK.GotFocus
iFocus = 3
End Sub
Private Sub thisDistance_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles thisDistance.GotFocus
iFocus = 1
End Sub
Private Sub ThisTime_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ThisTime.GotFocus
iFocus = 2
End Sub
Private Sub NBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NBack.Click
If iFocus = 1 Then
thisDistance.Text = ""
End If
If iFocus = 2 Then
ThisTime.Text = ""
End If
If iFocus = 3 Then
ZK.Text = ""
End If
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Application.Exit()
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub MenuItem1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
MsgBox("本程序用于计算乘坐出租车的计价,并为每次乘车做好记录。程序的主要特点是编写了对应于多输入点的输入,以防止系统输入方法遮挡程序区域。程序由mhlxxl@sina.com开发。2005年10月16日晚", MsgBoxStyle.Information, "程序说明")
End Sub
Private Sub MenuItem2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Application.Exit()
End Sub
Private Sub NWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NWrite.Click
If Fee.Text <> "" Then
If MsgBox("写入乘车记录将不能删除,继续否?", MsgBoxStyle.YesNo, "请确认") = MsgBoxResult.Yes Then
'Dim fn As System.IO.StreamWriter = New System.IO.StreamWriter(myAppPath + "\TaxiRec.txt", True, System.Text.Encoding.Default)
'fn.WriteLine("乘车金额:" + Str(iFee) + " 元 " + Now())
'fn.Close()
Dim aa As Date
Dim bb As Integer
Dim cc As Integer
cn = New System.Data.SqlServerCe.SqlCeConnection("Data Source=" + myAppPath + "\taxirec.sdf")
If cn.State = ConnectionState.Open Then cn.Close()
cn.Open()
aa = System.Convert.ToDateTime(Now())
bb = System.Convert.ToInt16(iFee)
cc = System.Convert.ToInt16(thisDistance.Text)
SQL = "insert into TaxiRec(ttime,money,distance) values(" + "'" + aa + "'," + Str(bb) + "," + Str(cc) + ")"
Dim cmd As New System.Data.SqlServerCe.SqlCeCommand(SQL, cn)
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
cn.Close()
End If
Else
MsgBox("请先计算出本次乘车费用!", MsgBoxStyle.Critical, "提示")
End If
End Sub
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
MsgBox("程序正在完善,请等待......", MsgBoxStyle.Information, "对不起")
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
NWrite.Text = "写入乘车记录" + Microsoft.VisualBasic.Left(TimeString(), 5)
End Sub
Private Sub MenuItem3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
Dim TaxiRec As New TaxiRec
TaxiRec.Show()
End Sub
Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
If MsgBox("真的要清空乘车记录吗?", MsgBoxStyle.YesNo, "请确认") = MsgBoxResult.Yes Then
cn = New System.Data.SqlServerCe.SqlCeConnection("Data Source=" + myAppPath + "\taxirec.sdf")
If cn.State = ConnectionState.Open Then cn.Close()
cn.Open()
SQL = "delete TaxiRec"
Dim cmd As New System.Data.SqlServerCe.SqlCeCommand(SQL, cn)
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
cn.Close()
End If
End Sub
Private Sub CreateDatabase()
' If the database exists, blow it away.
'If System.IO.File.Exists(myAppPath + "\taxirec.sdf") Then
' System.IO.File.Delete(myAppPath + "\taxirec.sdf")
'End If
' If the database does not already exist, then create it.
If Not System.IO.File.Exists(myAppPath + "\TaxiRec.sdf") Then
SQLEngine = New System.Data.SqlServerCe.SqlCeEngine("data source=" + myAppPath + "\taxirec.sdf")
SQLEngine.CreateDatabase()
cn = New System.Data.SqlServerCe.SqlCeConnection("Data Source=" + myAppPath + "\taxirec.sdf")
cn.Open()
SQL = "CREATE TABLE TaxiRec (TTime datetime NOT NULL,Money smallint NOT NULL,distance smallint not null)"
Dim cmd As New System.Data.SqlServerCe.SqlCeCommand(SQL, cn)
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
cn.Close()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -