Visual basic 数据库编程技术与实例源码 源码

源代码在线查看: frmuseraddedit.frm

软件大小: 18516 K
上传用户: simoncxl
关键词: Visual basic 源码 数据库
下载地址: 免注册下载 普通下载 VIP

相关代码

				VERSION 5.00
				Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
				Begin VB.Form frmUserAddEdit 
				   BorderStyle     =   3  'Fixed Dialog
				   Caption         =   "添加"
				   ClientHeight    =   2475
				   ClientLeft      =   2760
				   ClientTop       =   3750
				   ClientWidth     =   3930
				   Icon            =   "frmUserAddEdit.frx":0000
				   LinkTopic       =   "Form1"
				   LockControls    =   -1  'True
				   MaxButton       =   0   'False
				   MinButton       =   0   'False
				   ScaleHeight     =   2475
				   ScaleWidth      =   3930
				   ShowInTaskbar   =   0   'False
				   StartUpPosition =   1  '所有者中心
				   Begin VB.TextBox txtLX 
				      DataField       =   "lx"
				      DataSource      =   "Adodc1"
				      Height          =   285
				      Left            =   2055
				      TabIndex        =   12
				      Top             =   1620
				      Visible         =   0   'False
				      Width           =   765
				   End
				   Begin MSAdodcLib.Adodc Adodc1 
				      Height          =   330
				      Left            =   2655
				      Top             =   0
				      Width           =   1200
				      _ExtentX        =   2117
				      _ExtentY        =   582
				      ConnectMode     =   0
				      CursorLocation  =   3
				      IsolationLevel  =   -1
				      ConnectionTimeout=   15
				      CommandTimeout  =   30
				      CursorType      =   3
				      LockType        =   3
				      CommandType     =   8
				      CursorOptions   =   0
				      CacheSize       =   50
				      MaxRecords      =   0
				      BOFAction       =   0
				      EOFAction       =   0
				      ConnectStringType=   1
				      Appearance      =   1
				      BackColor       =   -2147483643
				      ForeColor       =   -2147483640
				      Orientation     =   0
				      Enabled         =   0
				      Connect         =   ""
				      OLEDBString     =   ""
				      OLEDBFile       =   ""
				      DataSourceName  =   ""
				      OtherAttributes =   ""
				      UserName        =   ""
				      Password        =   ""
				      RecordSource    =   ""
				      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.TextBox Text1 
				      DataField       =   "zh"
				      DataSource      =   "Adodc1"
				      Height          =   300
				      Index           =   1
				      Left            =   1155
				      TabIndex        =   0
				      Top             =   135
				      Width           =   2400
				   End
				   Begin VB.TextBox Text1 
				      DataField       =   "mc"
				      DataSource      =   "Adodc1"
				      Height          =   300
				      Index           =   2
				      Left            =   1155
				      TabIndex        =   1
				      Top             =   480
				      Width           =   2400
				   End
				   Begin VB.TextBox Text1 
				      DataField       =   "pwd"
				      DataSource      =   "Adodc1"
				      Height          =   300
				      IMEMode         =   3  'DISABLE
				      Index           =   3
				      Left            =   1155
				      PasswordChar    =   "*"
				      TabIndex        =   2
				      Top             =   825
				      Width           =   2400
				   End
				   Begin VB.TextBox Text1 
				      Height          =   300
				      IMEMode         =   3  'DISABLE
				      Index           =   4
				      Left            =   1155
				      PasswordChar    =   "*"
				      TabIndex        =   3
				      Top             =   1170
				      Width           =   2400
				   End
				   Begin VB.ComboBox Combo1 
				      Height          =   300
				      ItemData        =   "frmUserAddEdit.frx":000C
				      Left            =   1155
				      List            =   "frmUserAddEdit.frx":0016
				      Style           =   2  'Dropdown List
				      TabIndex        =   4
				      Top             =   1515
				      Width           =   2400
				   End
				   Begin VB.CommandButton cmdCancel 
				      Cancel          =   -1  'True
				      Caption         =   "取消(&C)"
				      Height          =   375
				      Left            =   2100
				      TabIndex        =   6
				      Top             =   1950
				      Width           =   1215
				   End
				   Begin VB.CommandButton cmdOK 
				      Caption         =   "确定(&O)"
				      Enabled         =   0   'False
				      Height          =   375
				      Left            =   420
				      TabIndex        =   5
				      Top             =   1950
				      Width           =   1215
				   End
				   Begin VB.Label Label5 
				      AutoSize        =   -1  'True
				      Caption         =   "帐号类别:"
				      Height          =   180
				      Left            =   225
				      TabIndex        =   11
				      Top             =   1575
				      Width           =   900
				   End
				   Begin VB.Label Label4 
				      AutoSize        =   -1  'True
				      Caption         =   "密码确认:"
				      Height          =   180
				      Left            =   225
				      TabIndex        =   10
				      Top             =   1230
				      Width           =   900
				   End
				   Begin VB.Label Label3 
				      AutoSize        =   -1  'True
				      Caption         =   "密码:"
				      Height          =   180
				      Left            =   585
				      TabIndex        =   9
				      Top             =   885
				      Width           =   540
				   End
				   Begin VB.Label Label2 
				      AutoSize        =   -1  'True
				      Caption         =   "名称:"
				      Height          =   180
				      Left            =   585
				      TabIndex        =   8
				      Top             =   540
				      Width           =   540
				   End
				   Begin VB.Label Label1 
				      AutoSize        =   -1  'True
				      Caption         =   "帐号:"
				      Height          =   180
				      Left            =   585
				      TabIndex        =   7
				      Top             =   195
				      Width           =   540
				   End
				End
				Attribute VB_Name = "frmUserAddEdit"
				Attribute VB_GlobalNameSpace = False
				Attribute VB_Creatable = False
				Attribute VB_PredeclaredId = True
				Attribute VB_Exposed = False
				Option Explicit
				Private mRS As ADODB.Recordset
				'设置
				Public Property Let UserADORecordset(ByRef vNewValue As ADODB.Recordset)
				    Set mRS = vNewValue
				End Property
				Private Sub cmdCancel_Click()
				    Adodc1.Recordset.CancelUpdate
				    Unload Me
				End Sub
				
				Private Sub cmdOK_Click()
				    On Error GoTo ErrHandler
				    '10:判断是添加还是修改
				    If Text1(1).Locked = False Then '是添加
				        If IsKeyColumnExists("SELECT Count(*) as ct FROM tbUser WHERE LCase(zh)='" & Text1(1).Text & "'", gadoCONN, _
				                             "所添加的帐号已经存在,请换一个帐号!") = True Then
				            Text1(1).SetFocus
				            Text1(1).SelStart = 0
				            Text1(1).SelLength = Len(Text1(3).Text)
				            Exit Sub
				        End If
				    End If
				    '20:判断密码是否正确
				    If Text1(3).Text  Text1(4).Text Then
				        MsgBox "两次输入的密码不相等,请重新输入!", vbOKOnly + vbInformation, Me.Caption
				        Text1(3).SetFocus
				        Text1(3).SelStart = 0
				        Text1(3).SelLength = Len(Text1(3).Text)
				        Exit Sub
				    End If
				    
				    '30:保存记录
				    Adodc1.Recordset.Move 0
				    
				    '-----------------------------------
				    Unload Me
				    Exit Sub
				ErrHandler:
				    ErrMessageBox Me.Name & ":cmdOK_Click()", Me.Caption
				End Sub
				Private Sub Combo1_Click()
				    cmdOK.Enabled = True
				    txtLX.Text = CStr(Combo1.ListIndex)
				End Sub
				
				Private Sub Form_Load()
				    On Error Resume Next
				    
				    '设置数据集
				    Set Adodc1.Recordset = mRS
				    '判断是添加还修改
				    If Text1(1).Text  "" Then '是修改
				        Me.Caption = "修改帐号"
				        Text1(1).Locked = True
				        Text1(1).BackColor = &H8000000F
				        
				        Combo1.ListIndex = ToLong(mRS("lx"))
				    Else
				        Me.Caption = "添加帐号"
				        
				        txtLX.Text = "1"
				        Combo1.ListIndex = 1
				    End If
				    '---------------------------------
				    cmdOK.Enabled = False
				End Sub
				Private Sub Text1_Change(Index As Integer)
				    If Text1(1).Text = "" Then
				        cmdOK.Enabled = False
				    Else
				        cmdOK.Enabled = True
				    End If
				End Sub
				Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
				    If KeyCode = vbKeyReturn Then '回车键
				        Select Case Index
				            Case 4
				                Combo1.SetFocus
				            Case Else
				                Text1(Index + 1).SetFocus
				        End Select
				    End If
				End Sub
				Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
				    If KeyCode = vbKeyReturn Then '回车键
				        SendKeys "{Tab}"
				    End If
				End Sub
							

相关资源