?? frm_ticket.frm
字號:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frm_ticket
Caption = "購票信息管理"
ClientHeight = 4740
ClientLeft = 60
ClientTop = 450
ClientWidth = 11955
LinkTopic = "Form1"
ScaleHeight = 4740
ScaleWidth = 11955
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Height = 975
Left = 1440
TabIndex = 1
Top = 3360
Width = 9135
Begin VB.CommandButton fault
Caption = "退出"
Height = 375
Left = 7320
TabIndex = 6
Top = 360
Width = 1335
End
Begin VB.CommandButton cmd_que
Caption = "查詢"
Height = 375
Left = 5520
TabIndex = 5
Top = 360
Width = 1335
End
Begin VB.CommandButton cmd_del
Caption = "刪除"
Height = 375
Left = 3840
TabIndex = 4
Top = 360
Width = 1335
End
Begin VB.CommandButton cmd_edit
Caption = "修改"
Height = 375
Left = 2160
TabIndex = 3
Top = 360
Width = 1335
End
Begin VB.CommandButton cmd_add
Caption = "添加"
Height = 375
Left = 480
TabIndex = 2
Top = 360
Width = 1335
End
End
Begin MSFlexGridLib.MSFlexGrid FGridDatatable
Height = 2895
Left = 240
TabIndex = 0
Top = 240
Width = 11415
_ExtentX = 20135
_ExtentY = 5106
_Version = 393216
Rows = 1
Cols = 0
FixedRows = 0
FixedCols = 0
AllowBigSelection= 0 'False
FillStyle = 1
SelectionMode = 1
End
End
Attribute VB_Name = "frm_ticket"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub ShowTitle()
Dim i As Integer
With FGridDatatable
'設置表頭文字
.Cols = 9
.TextMatrix(0, 1) = "車票編號"
.TextMatrix(0, 2) = "公車編號"
.TextMatrix(0, 3) = "起始城市"
.TextMatrix(0, 4) = "到達城市"
.TextMatrix(0, 5) = "車票日期"
.TextMatrix(0, 6) = "車票時間"
.TextMatrix(0, 7) = "車票價格"
.TextMatrix(0, 8) = "備注"
'表頭項居中
'.FillStyle = flexFillRepeat
'.Col = 0
'.Rows = 1
'.Row = 0
'.RowSel = 1
'.ColSel = .Cols - 1
'.CellAlignment = 1
'設置單元大小
.ColWidth(0) = 200
.ColWidth(1) = 0
.ColWidth(2) = 1000
.ColWidth(3) = 1000
.ColWidth(4) = 1000
.ColWidth(5) = 1500
.ColWidth(6) = 1500
.ColWidth(7) = 1500
.ColWidth(8) = 1500
'.Row = 1
End With
End Sub
Private Sub cmd_add_Click()
frm_addticketinfo.Show
End Sub
Private Sub cmd_del_Click()
Dim SelectedRowIndex As Integer
Dim strSQL As String
SelectedRowIndex = FGridDatatable.Row
CurrentTicket = FGridDatatable.TextMatrix(SelectedRowIndex, 1)
If MsgBox("真的要刪除此條記錄嗎?", vbOKCancel + vbExclamation, "警告") = vbOK Then
OpenDB
strSQL = "delete from ticketinfo where ticketno ='" + CurrentTicket + "'"
objConn.Execute (strSQL)
CloseDB
MsgBox "記錄已刪除", vbOKOnly
frm_ticket.FGridDatatable.Clear
frm_ticket.ShowTitle
frm_ticket.loadData ("")
End If
End Sub
Private Sub cmd_edit_Click()
Dim SelectedRowIndex As Integer
SelectedRowIndex = FGridDatatable.Row
CurrentTicket = FGridDatatable.TextMatrix(SelectedRowIndex, 1)
frm_editticketinfo.Show 1
End Sub
Private Sub cmd_que_Click()
frm_queticketinfo.Show
End Sub
Private Sub fault_Click()
Unload Me
End Sub
Private Sub Form_Load()
ShowTitle
loadData ("")
End Sub
Public Sub loadData(InputSQL As String)
Dim strSQL As String
Dim i As Integer
If InputSQL = "" Then
strSQL = "Select * from ticketinfo"
Else
strSQL = InputSQL
End If
FGridDatatable.Rows = 1
OpenDB
objRS.Open strSQL, objConn, adOpenKeyset, adLockOptimistic
If Not objRS.EOF Then
For i = 1 To objRS.RecordCount
FGridDatatable.Rows = FGridDatatable.Rows + 1
FGridDatatable.TextMatrix(i, 1) = objRS.Fields(0).Value
FGridDatatable.TextMatrix(i, 2) = objRS.Fields(1).Value
FGridDatatable.TextMatrix(i, 3) = objRS.Fields(2).Value
FGridDatatable.TextMatrix(i, 4) = objRS.Fields(3).Value
FGridDatatable.TextMatrix(i, 5) = objRS.Fields(4).Value
FGridDatatable.TextMatrix(i, 6) = objRS.Fields(5).Value
FGridDatatable.TextMatrix(i, 7) = objRS.Fields(6).Value
FGridDatatable.TextMatrix(i, 8) = objRS.Fields(7).Value
'FGridDatatable.TextMatrix(i, 9) = objRS.Fields(8).Value
cmd_edit.Enabled = True
cmd_del.Enabled = True
If Not objRS.EOF Then
objRS.MoveNext
End If
Next i
FGridDatatable.Row = 0
FGridDatatable.Col = 0
FGridDatatable.RowSel = FGridDatatable.Rows - 1
FGridDatatable.ColSel = FGridDatatable.Cols - 1
FGridDatatable.CellAlignment = 2
FGridDatatable.Row = FGridDatatable.Rows - 1
cmd_del.Enabled = True
cmd_edit.Enabled = True
Else
cmd_edit.Enabled = False
cmd_del.Enabled = False
End If
objRS.Close
CloseDB
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -