⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmnew.frm

📁 以前写的一个销售的管理系统,是牙刷销存管理系统,有销售,进货等功能,刚学VB时写的
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmnew 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "兴盛牙刷销存管理系统--增加操作员"
   ClientHeight    =   3195
   ClientLeft      =   3690
   ClientTop       =   3120
   ClientWidth     =   4680
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   Begin VB.TextBox txtbm 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2160
      TabIndex        =   2
      Top             =   1800
      Width           =   1695
   End
   Begin VB.TextBox txtpwd 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      IMEMode         =   3  'DISABLE
      Left            =   2160
      TabIndex        =   1
      Top             =   960
      Width           =   1695
   End
   Begin VB.TextBox txtuser 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2160
      TabIndex        =   0
      Top             =   120
      Width           =   1695
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确  认"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   720
      TabIndex        =   3
      Top             =   2640
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "返  回"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2760
      TabIndex        =   4
      Top             =   2640
      Width           =   1095
   End
   Begin VB.Label Label3 
      Caption         =   "部    门:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   720
      TabIndex        =   7
      Top             =   1800
      Width           =   1455
   End
   Begin VB.Label Label1 
      Caption         =   "用 户 名:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   720
      TabIndex        =   6
      Top             =   240
      Width           =   1335
   End
   Begin VB.Label Label2 
      Caption         =   "密    码:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   720
      TabIndex        =   5
      Top             =   1080
      Width           =   1335
   End
End
Attribute VB_Name = "frmnew"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
  DefaultType = dbUseODBC
  Dim db As Database
  Dim rs As Recordset
  Dim cx As Boolean
  cx = False
  Set db = OpenDatabase("xsys", dbDriverNoPrompt, False, "odbc;database=glxt;uid=;pwd=;dsn=xsys")
  Set rs = db.OpenRecordset("yhk", dbOpenDynaset, dbwrite, dbOptimistic)
  Do While rs.EOF <> True
     If rs.Fields("用户名") = Trim(txtuser.Text) Then
        cx = True
        Exit Do
     End If
     If rs.EOF = True Then
        Exit Do
     End If
     rs.MoveNext
  Loop
  If txtuser.Text = "" Or txtpwd.Text = "" Or txtbm = "" Then
     MsgBox "填写不能为空,请重新填写!", vbCritical, "错误"
  Else
     If MsgBox("请确认填写无误,否则修改!", vbOKCancel, "提示") = vbOK Then
        If cx = True Then
           MsgBox "此用户已存在,请重新分配用户!"
           txtuser.SetFocus
        Else
           With rs
             .AddNew
             .Fields("用户名") = Trim(txtuser.Text)
             .Fields("密码") = Trim(txtpwd.Text)
             .Fields("部门") = Trim(txtbm.Text)
             .Update
             .Close
           End With
           MsgBox "用户分配成功!", vbInformation, "提示"
           txtuser.Text = ""
           txtpwd.Text = ""
           txtbm.Text = ""
        End If
     Else
        Command2.SetFocus
     End If
  End If
  db.Close
End Sub

Private Sub Command2_Click()
  Unload Me
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
  Dim nexttabindex As Integer, i As Integer
       If KeyAscii = 13 Then
          If Screen.ActiveControl.TabIndex = Count - 1 Then
             nexttabindex = 0
          Else
             nexttabindex = Screen.ActiveControl.TabIndex + 1
          End If
          For i = 0 To Count - 1
              If Me.Controls(i).TabIndex = nexttabindex Then
                 Me.Controls(i).SetFocus
                 Exit For
              End If
          Next i
          KeyAscii = 0
        End If
End Sub

Private Sub txtuser_lostfocus()
  DefaultType = dbUseODBC
  Dim db As Database
  Dim rs As Recordset
  Dim cx As Boolean
  cx = False
  Set db = OpenDatabase("xsys", dbDriverNoPrompt, False, "odbc;database=glxt;uid=;pwd=;dsn=xsys")
  Set rs = db.OpenRecordset("yhk", dbOpenDynaset, dbwrite, dbOptimistic)
  Do While rs.EOF <> True
     If rs.Fields("用户名") = LTrim(txtuser.Text) Then
        cx = True
        Exit Do
     End If
     If rs.EOF = True Then
        Exit Do
     End If
     rs.MoveNext
  Loop
  If cx = True Then
     MsgBox "此用户已存在,请重新分配用户!"
     txtuser.Text = ""
     txtuser.SetFocus
  End If
  rs.Close
  db.Close
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -