?? frmstudent.frm
字號:
Top = 5760
Visible = 0 'False
Width = 1215
_ExtentX = 2143
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 2
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=eislink"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "eislink"
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from 學生信息 "
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label Label18
Caption = "性別"
Height = 255
Left = 4200
TabIndex = 23
Top = 4320
Width = 615
End
Begin VB.Label Label17
Caption = "學籍編號"
Height = 255
Left = 3360
TabIndex = 22
Top = 5760
Width = 855
End
Begin VB.Label Label15
Caption = "民族編號"
Height = 255
Left = 6000
TabIndex = 21
Top = 5040
Width = 975
End
Begin VB.Label Label13
Caption = "政治面貌編號"
Height = 255
Left = 3120
TabIndex = 20
Top = 5040
Width = 1335
End
Begin VB.Label Label6
Caption = "姓名"
Height = 255
Left = 2640
TabIndex = 19
Top = 4320
Width = 735
End
Begin VB.Label Label4
Caption = "學號"
Height = 255
Left = 0
TabIndex = 18
Top = 4320
Width = 855
End
Begin VB.Label Label8
Caption = "身份證號"
Height = 255
Left = 7320
TabIndex = 17
Top = 4320
Width = 975
End
Begin VB.Label Label9
Caption = "班級編號"
Height = 255
Left = 0
TabIndex = 16
Top = 5040
Width = 975
End
Begin VB.Label Label10
Caption = "籍貫編號"
Height = 255
Left = 0
TabIndex = 15
Top = 5760
Width = 855
End
Begin VB.Label Label12
Caption = "年級"
Height = 255
Left = 5520
TabIndex = 14
Top = 4320
Width = 855
End
End
Attribute VB_Name = "frmStudent"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private bAdd As Boolean
Private Sub LoadData()
Dim strFilter As String
Dim db As New DataBases
Dim rs As Recordset
If Len(Trim(txbOne.Text)) = 0 Then
If Len(Trim(txbTwo.Text)) = 0 Then
If Len(Trim(txbThree.Text)) = 0 Then
strFilter = ""
Else
strFilter = "where 年級 like '"
strFilter = strFilter + Trim(txbThree.Text) + "%'"
End If
Else
strFilter = "where 姓名 like '"
strFilter = strFilter + Trim(txbTwo.Text) + "%'"
If Len(Trim(txbThree.Text)) <> 0 Then
strFilter = strFilter + " and 年級 like '"
strFilter = strFilter + Trim(txbThree.Text) + "%'"
End If
End If
Else
strFilter = "where 學號 like '"
strFilter = strFilter + Trim(txbOne.Text) + "%'"
If Len(Trim(txbTwo.Text)) <> 0 Then
strFilter = strFilter + " and 姓名 like '"
strFilter = strFilter + Trim(txbTwo.Text) + "%'"
If Len(Trim(txbThree.Text)) <> 0 Then
strFilter = strFilter + " and 年級 like '"
strFilter = strFilter + Trim(txbThree.Text) + "%'"
End If
Else
If Len(Trim(txbThree.Text)) <> 0 Then
strFilter = strFilter + " and 年級 like '"
strFilter = strFilter + Trim(txbThree.Text) + "%'"
End If
End If
End If
Set rs = db.RunSelectSQLUpdatable("select * from 學生信息 " + strFilter)
'根據(jù)查詢條件重新填充DataGrid
Set Adodc1.Recordset = rs
End Sub
Private Sub btnSearch_Click()
LoadData
End Sub
Private Sub Form_Load()
Dim db As New DataBases
Adodc1.ConnectionString = db.sConn
Adodc2.ConnectionString = db.sConn
Adodc3.ConnectionString = db.sConn
Adodc4.ConnectionString = db.sConn
Adodc5.ConnectionString = db.sConn
Adodc6.ConnectionString = db.sConn
cbbSex.AddItem ("男")
cbbSex.AddItem ("女")
LoadData
SetTextBoxState (False)
End Sub
Private Sub SetToolBarState(ByVal bState As Boolean)
'設置Button的是否能夠單擊
Toolbar1.Buttons("btnFirst").Enabled = bState
Toolbar1.Buttons("btnBefore").Enabled = bState
Toolbar1.Buttons("btnNext").Enabled = bState
Toolbar1.Buttons("btnLast").Enabled = bState
Toolbar1.Buttons("btnNew").Enabled = bState
Toolbar1.Buttons("btnModify").Enabled = bState
Toolbar1.Buttons("btnDelete").Enabled = bState
Toolbar1.Buttons("btnSave").Enabled = Not bState
Toolbar1.Buttons("btnCancel").Enabled = Not bState
grdDataGrid.Enabled = bState
End Sub
Private Sub SetTextBoxState(ByVal bState As Boolean)
Me.txbClassId.Enabled = bState
Me.txbName.Enabled = bState
Me.cbbSex.Enabled = bState
Me.txbGrade.Enabled = bState
Me.txbPID.Enabled = bState
Me.cbbClassId.Enabled = bState
Me.cbbPolity.Enabled = bState
Me.cbbNation.Enabled = bState
Me.cbbBirthPlace.Enabled = bState
Me.cbbStatus.Enabled = bState
End Sub
Private Sub Clear()
Me.txbClassId.Text = ""
Me.txbName.Text = ""
Me.cbbSex.Text = ""
Me.txbGrade.Text = ""
Me.txbPID.Text = ""
Me.cbbClassId.Text = ""
Me.cbbPolity.Text = ""
Me.cbbNation.Text = ""
Me.cbbBirthPlace.Text = ""
Me.cbbStatus.Text = ""
End Sub
Private Sub SaveForUpdate()
Adodc1.Recordset.UpdateBatch adAffectAll
End Sub
Private Sub DeleteData()
Dim db As New DataBases
Dim strSQL As String
Dim rs As ADODB.Recordset
strSQL = "select 編號 from 成績表 where 學號=" + txbClassId.Text
Set rs = db.RunSelectSQL(strSQL)
If rs.RecordCount = 0 Then
Adodc1.Recordset.Delete adAffectCurrent
Adodc1.Recordset.UpdateBatch adAffectAll
Else
Call MsgBox("請先刪除該生的其它成績信息", vbOKOnly)
End If
End Sub
Private Sub SaveForAdd()
Dim db As New DataBases
Dim strSQL As String
strSQL = "insert into 學生信息(學號, 姓名, 班級編號, 性別, 年級, 身份證號, 政治面貌編號, 民族編號, 籍貫編號, 學籍編號) values ('"
strSQL = strSQL + Trim(txbClassId.Text) + "','"
strSQL = strSQL + Trim(txbName.Text) + "','"
strSQL = strSQL + Trim(cbbClassId.Text) + "','"
strSQL = strSQL + Trim(cbbSex.Text) + "','"
strSQL = strSQL + Trim(txbGrade.Text) + "','"
strSQL = strSQL + Trim(txbPID.Text) + "','"
strSQL = strSQL + Trim(cbbPolity.Text) + "','"
strSQL = strSQL + Trim(cbbNation.Text) + "','"
strSQL = strSQL + Trim(cbbBirthPlace.Text) + "','"
strSQL = strSQL + Trim(cbbStatus.Text) + "')"
db.RunSelectSQL (strSQL)
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If StrComp(Button.Key, "btnFirst") = 0 Then
Adodc1.Recordset.MoveFirst
ElseIf StrComp(Button.Key, "btnBefore") = 0 Then
Adodc1.Recordset.MovePrevious
ElseIf StrComp(Button.Key, "btnNext") = 0 Then
Adodc1.Recordset.MoveNext
ElseIf StrComp(Button.Key, "btnLast") = 0 Then
Adodc1.Recordset.MoveLast
ElseIf StrComp(Button.Key, "btnNew") = 0 Then
bAdd = True
Adodc1.Recordset.AddNew
SetTextBoxState (True)
SetToolBarState (False)
Clear
ElseIf StrComp(Button.Key, "btnModify") = 0 Then
bAdd = False
SetTextBoxState (True)
SetToolBarState (False)
ElseIf StrComp(Button.Key, "btnDelete") = 0 Then
If MsgBox("確定要刪除嗎?", vbYesNo) = vbYes Then
DeleteData
End If
ElseIf StrComp(Button.Key, "btnSave") = 0 Then
SetTextBoxState (False)
SetToolBarState (True)
If bAdd = True Then
'為新增數(shù)據(jù)保存
SaveForAdd
Adodc1.Recordset.CancelUpdate
LoadData
Else
'為更新數(shù)據(jù)保存
SaveForUpdate
End If
ElseIf StrComp(Button.Key, "btnCancel") = 0 Then
SetTextBoxState (False)
SetToolBarState (True)
ElseIf StrComp(Button.Key, "btnExit") = 0 Then
Hide
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -