📄 form2.frm
字号:
VERSION 5.00
Object = "{DEF7CADD-83C0-11D0-A0F1-00A024703500}#7.0#0"; "todg7.ocx"
Begin VB.Form Form2
Caption = "用户设置"
ClientHeight = 4095
ClientLeft = 60
ClientTop = 345
ClientWidth = 7710
LinkTopic = "Form2"
MaxButton = 0 'False
ScaleHeight = 4095
ScaleWidth = 7710
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox Picture1
Height = 495
Left = 2880
ScaleHeight = 435
ScaleWidth = 4515
TabIndex = 2
Top = 3240
Width = 4575
Begin VB.CommandButton Command3
Caption = "退出"
Height = 500
Left = 3120
TabIndex = 5
Top = 0
Width = 1565
End
Begin VB.CommandButton Command2
Caption = "删除"
Height = 500
Left = 1560
TabIndex = 4
Top = 0
Width = 1565
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 500
Left = 0
TabIndex = 3
Top = 0
Width = 1565
End
End
Begin TrueOleDBGrid70.TDBGrid grid
Height = 2895
Left = 2880
TabIndex = 1
Top = 240
Width = 4695
_ExtentX = 8281
_ExtentY = 5106
_LayoutType = 0
_RowHeight = -2147483647
_WasPersistedAsPixels= 0
Columns(0)._VlistStyle= 0
Columns(0)._MaxComboItems= 5
Columns(0).DataField= ""
Columns(0)._PropDict= "_MaxComboItems,516,2;_VlistStyle,514,3"
Columns(1)._VlistStyle= 0
Columns(1)._MaxComboItems= 5
Columns(1).DataField= ""
Columns(1)._PropDict= "_MaxComboItems,516,2;_VlistStyle,514,3"
Columns.Count = 2
Splits(0)._UserFlags= 0
Splits(0).RecordSelectorWidth= 503
Splits(0)._SavedRecordSelectors= 0 'False
Splits(0).DividerColor= 13160660
Splits(0).SpringMode= 0 'False
Splits(0)._PropDict= "_ColumnProps,515,0;_UserFlags,518,3"
Splits(0)._ColumnProps(0)= "Columns.Count=2"
Splits(0)._ColumnProps(1)= "Column(0).Width=3281"
Splits(0)._ColumnProps(2)= "Column(0).DividerColor=0"
Splits(0)._ColumnProps(3)= "Column(0)._WidthInPix=3175"
Splits(0)._ColumnProps(4)= "Column(0).Order=1"
Splits(0)._ColumnProps(5)= "Column(1).Width=3281"
Splits(0)._ColumnProps(6)= "Column(1).DividerColor=0"
Splits(0)._ColumnProps(7)= "Column(1)._WidthInPix=3175"
Splits(0)._ColumnProps(8)= "Column(1).Order=2"
Splits.Count = 1
PrintInfos(0)._StateFlags= 0
PrintInfos(0).Name= "piInternal 0"
PrintInfos(0).PageHeaderFont= "Size=9,Charset=134,Weight=400,Underline=0,Italic=0,Strikethrough=0,Name=宋体"
PrintInfos(0).PageFooterFont= "Size=9,Charset=134,Weight=400,Underline=0,Italic=0,Strikethrough=0,Name=宋体"
PrintInfos(0).PageHeaderHeight= 0
PrintInfos(0).PageFooterHeight= 0
PrintInfos.Count= 1
DefColWidth = 0
HeadLines = 1
FootLines = 1
MultipleLines = 0
CellTipsWidth = 0
DeadAreaBackColor= 13160660
RowDividerColor = 13160660
RowSubDividerColor= 13160660
DirectionAfterEnter= 1
MaxRows = 250000
ViewColumnCaptionWidth= 0
ViewColumnWidth = 0
_PropDict = "_ExtentX,2003,3;_ExtentY,2004,3;_LayoutType,512,2;_RowHeight,16,3;_StyleDefs,513,0;_WasPersistedAsPixels,516,2"
_StyleDefs(0) = "_StyleRoot:id=0,.parent=-1,.alignment=3,.valignment=0,.bgcolor=&H80000005&"
_StyleDefs(1) = ":id=0,.fgcolor=&H80000008&,.wraptext=0,.locked=0,.transparentBmp=0"
_StyleDefs(2) = ":id=0,.fgpicPosition=0,.bgpicMode=0,.appearance=0,.borderSize=0,.ellipsis=0"
_StyleDefs(3) = ":id=0,.borderColor=&H80000005&,.borderType=0,.bold=0,.fontsize=900,.italic=0"
_StyleDefs(4) = ":id=0,.underline=0,.strikethrough=0,.charset=134"
_StyleDefs(5) = ":id=0,.fontname=宋体"
_StyleDefs(6) = "Style:id=1,.parent=0,.namedParent=33"
_StyleDefs(7) = "CaptionStyle:id=4,.parent=2,.namedParent=37"
_StyleDefs(8) = "HeadingStyle:id=2,.parent=1,.namedParent=34"
_StyleDefs(9) = "FooterStyle:id=3,.parent=1,.namedParent=35"
_StyleDefs(10) = "InactiveStyle:id=5,.parent=2,.bgcolor=&H8000000F&,.fgcolor=&H80000012&"
_StyleDefs(11) = "SelectedStyle:id=6,.parent=1,.namedParent=36"
_StyleDefs(12) = "EditorStyle:id=7,.parent=1"
_StyleDefs(13) = "HighlightRowStyle:id=8,.parent=1,.namedParent=38"
_StyleDefs(14) = "EvenRowStyle:id=9,.parent=1,.namedParent=39"
_StyleDefs(15) = "OddRowStyle:id=10,.parent=1,.namedParent=40"
_StyleDefs(16) = "RecordSelectorStyle:id=11,.parent=2,.namedParent=41"
_StyleDefs(17) = "FilterBarStyle:id=12,.parent=1,.namedParent=42"
_StyleDefs(18) = "Splits(0).Style:id=13,.parent=1"
_StyleDefs(19) = "Splits(0).CaptionStyle:id=22,.parent=4"
_StyleDefs(20) = "Splits(0).HeadingStyle:id=14,.parent=2"
_StyleDefs(21) = "Splits(0).FooterStyle:id=15,.parent=3"
_StyleDefs(22) = "Splits(0).InactiveStyle:id=16,.parent=5"
_StyleDefs(23) = "Splits(0).SelectedStyle:id=18,.parent=6"
_StyleDefs(24) = "Splits(0).EditorStyle:id=17,.parent=7"
_StyleDefs(25) = "Splits(0).HighlightRowStyle:id=19,.parent=8"
_StyleDefs(26) = "Splits(0).EvenRowStyle:id=20,.parent=9"
_StyleDefs(27) = "Splits(0).OddRowStyle:id=21,.parent=10"
_StyleDefs(28) = "Splits(0).RecordSelectorStyle:id=23,.parent=11"
_StyleDefs(29) = "Splits(0).FilterBarStyle:id=24,.parent=12"
_StyleDefs(30) = "Splits(0).Columns(0).Style:id=28,.parent=13"
_StyleDefs(31) = "Splits(0).Columns(0).HeadingStyle:id=25,.parent=14"
_StyleDefs(32) = "Splits(0).Columns(0).FooterStyle:id=26,.parent=15"
_StyleDefs(33) = "Splits(0).Columns(0).EditorStyle:id=27,.parent=17"
_StyleDefs(34) = "Splits(0).Columns(1).Style:id=32,.parent=13"
_StyleDefs(35) = "Splits(0).Columns(1).HeadingStyle:id=29,.parent=14"
_StyleDefs(36) = "Splits(0).Columns(1).FooterStyle:id=30,.parent=15"
_StyleDefs(37) = "Splits(0).Columns(1).EditorStyle:id=31,.parent=17"
_StyleDefs(38) = "Named:id=33:Normal"
_StyleDefs(39) = ":id=33,.parent=0"
_StyleDefs(40) = "Named:id=34:Heading"
_StyleDefs(41) = ":id=34,.parent=33,.valignment=2,.bgcolor=&H8000000F&,.fgcolor=&H80000012&"
_StyleDefs(42) = ":id=34,.wraptext=-1"
_StyleDefs(43) = "Named:id=35:Footing"
_StyleDefs(44) = ":id=35,.parent=33,.valignment=2,.bgcolor=&H8000000F&,.fgcolor=&H80000012&"
_StyleDefs(45) = "Named:id=36:Selected"
_StyleDefs(46) = ":id=36,.parent=33,.bgcolor=&H8000000D&,.fgcolor=&H8000000E&"
_StyleDefs(47) = "Named:id=37:Caption"
_StyleDefs(48) = ":id=37,.parent=34,.alignment=2"
_StyleDefs(49) = "Named:id=38:HighlightRow"
_StyleDefs(50) = ":id=38,.parent=33,.bgcolor=&H8000000D&,.fgcolor=&H8000000E&"
_StyleDefs(51) = "Named:id=39:EvenRow"
_StyleDefs(52) = ":id=39,.parent=33,.bgcolor=&HFFFF00&"
_StyleDefs(53) = "Named:id=40:OddRow"
_StyleDefs(54) = ":id=40,.parent=33"
_StyleDefs(55) = "Named:id=41:RecordSelector"
_StyleDefs(56) = ":id=41,.parent=34"
_StyleDefs(57) = "Named:id=42:FilterBar"
_StyleDefs(58) = ":id=42,.parent=33"
End
Begin VB.Frame Frame1
Caption = "用户信息"
Height = 3735
Left = 120
TabIndex = 0
Top = 120
Width = 2655
Begin VB.TextBox Text5
Height = 300
Left = 960
TabIndex = 15
Top = 3120
Width = 1455
End
Begin VB.TextBox Text4
Height = 300
Left = 960
TabIndex = 13
Top = 2400
Width = 1455
End
Begin VB.TextBox Text3
Height = 300
Left = 960
TabIndex = 11
Top = 1680
Width = 1455
End
Begin VB.TextBox Text2
Height = 300
Left = 960
TabIndex = 9
Top = 960
Width = 1455
End
Begin VB.TextBox Text1
Height = 300
Left = 960
TabIndex = 7
Top = 360
Width = 1455
End
Begin VB.Label Label5
Caption = "部门名称"
Height = 375
Left = 120
TabIndex = 14
Top = 3120
Width = 735
End
Begin VB.Label Label4
Caption = "部门编号"
Height = 375
Left = 120
TabIndex = 12
Top = 2520
Width = 735
End
Begin VB.Label Label3
Caption = "用户密码"
Height = 375
Left = 120
TabIndex = 10
Top = 1800
Width = 735
End
Begin VB.Label Label2
Caption = "用户名称"
Height = 495
Left = 120
TabIndex = 8
Top = 1080
Width = 735
End
Begin VB.Label Label1
Caption = "用户编号"
Height = 375
Left = 120
TabIndex = 6
Top = 480
Width = 735
End
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public rs As New ADODB.Recordset
Public rs2 As New ADODB.Recordset
Private Sub Command1_Click()
On Error GoTo err:
'Dim sql As String
If rs.State = 1 Then rs.Close
rs.CursorLocation = adUseClient
rs.Open "select * from users where userid='" & Text1.Text & "'", Conn, 3, 2
If rs.EOF = True Then
rs.AddNew
rs!userid = Text1.Text
rs!UserName = Text2.Text
rs!Password = Text3.Text
rs!bmbh = Text4.Text
rs!bmmc = Text5.Text
rs.Update
MsgBox "用户添加成功!", 64
rs2.Requery
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Set grid.DataSource = rs2
Else
MsgBox "该用户编号已存在,请指定其他编号", 64
Text1.SetFocus
Exit Sub
End If
Exit Sub
err:
MsgBox err.Description
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
If rs2.State = 1 Then rs2.Close
rs2.CursorLocation = adUseClient
rs2.Open "select userid '用户编号',username '用户名称',password '用户密码',bmbh '部门编号',bmmc '部门名称' from users", Conn
If rs2.EOF = False Then
Set grid.DataSource = rs2
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text1.Text = "" Then
MsgBox "用户编号不能为空", 64
Text1.SetFocus
Else
Text2.SetFocus
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text2.Text = "" Then
MsgBox "用户名字不能为空", 64
Text2.SetFocus
Else
Text3.SetFocus
End If
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text3.Text = "" Then
MsgBox "密码不能为空", 64
Text3.SetFocus
Else
Text4.SetFocus
End If
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text4.Text = "" Then
MsgBox "部门编号不能为空", 64
Text4.SetFocus
Else
Text5.SetFocus
End If
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text5.Text = "" Then
MsgBox "部门名称不能为空", 64
Text5.SetFocus
Else
Command1.SetFocus
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -