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

📄 frmcp.frm

📁 以前写的一个销售的管理系统,是牙刷销存管理系统,有销售,进货等功能,刚学VB时写的
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmzjcp 
   Caption         =   "兴盛牙刷销存管理系统--增加产品"
   ClientHeight    =   8595
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11880
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Moveable        =   0   'False
   ScaleHeight     =   8595
   ScaleWidth      =   11880
   StartUpPosition =   3  '窗口缺省
   WindowState     =   2  'Maximized
   Begin VB.TextBox txtczy 
      Appearance      =   0  'Flat
      BackColor       =   &H8000000B&
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   9600
      TabIndex        =   10
      Top             =   8040
      Width           =   1695
   End
   Begin VB.Frame Frame1 
      Caption         =   "增加新产品:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   7335
      Left            =   720
      TabIndex        =   6
      Top             =   600
      Width           =   10575
      Begin VB.CommandButton Command3 
         Caption         =   "返  回"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   7080
         TabIndex        =   5
         Top             =   5640
         Width           =   1335
      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            =   4800
         TabIndex        =   4
         Top             =   5640
         Width           =   1335
      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            =   2520
         MaskColor       =   &H00FF8080&
         TabIndex        =   3
         Top             =   5640
         Width           =   1335
      End
      Begin VB.TextBox txtgg 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   4920
         TabIndex        =   2
         Top             =   4320
         Width           =   2415
      End
      Begin VB.TextBox txttm 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   4920
         MaxLength       =   15
         TabIndex        =   1
         Top             =   2880
         Width           =   2415
      End
      Begin VB.TextBox txtid 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   4920
         TabIndex        =   0
         Top             =   1560
         Width           =   2415
      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
         ForeColor       =   &H00FF0000&
         Height          =   615
         Left            =   3120
         TabIndex        =   9
         Top             =   2880
         Width           =   1455
      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
         ForeColor       =   &H00FF0000&
         Height          =   495
         Left            =   3120
         TabIndex        =   8
         Top             =   4320
         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
         ForeColor       =   &H00FF0000&
         Height          =   495
         Left            =   3120
         TabIndex        =   7
         Top             =   1560
         Width           =   1455
      End
   End
   Begin VB.Label Label8 
      Caption         =   "操 作 员:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   375
      Left            =   8160
      TabIndex        =   11
      Top             =   8040
      Width           =   1575
   End
End
Attribute VB_Name = "frmzjcp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
  Command1.Enabled = False
  txtid.Enabled = True
  txttm.Enabled = True
  txtgg.Enabled = True
  txtid.Locked = False
  txttm.Locked = False
  txtgg.Locked = False
  txtid.SetFocus
  Command2.Enabled = True
End Sub
Private Sub Command2_Click()
DefaultType = dbUseODBC
Dim wk As Workspace
Dim db As Database
Dim rs As Recordset
Dim cx As Boolean
cx = False
Set wk = DBEngine.Workspaces(0)
Set db = OpenDatabase("xsys", dbDriverNoPrompt, False, "odbc;database=glxt;uid=;pwd=;dsn=xsys")
wk.BeginTrans
Set rs = db.OpenRecordset("xhk", dbOpenDynaset, dbwrite, dbOptimistic)
If txtid.Text = "" Or txttm.Text = "" Or txtgg.Text = "" Then
   MsgBox "填写不能为空,请重新输入!", vbInformation, "提示"
Else
   rs.MoveFirst
   Do While rs.EOF <> True
      If rs.Fields("产品编号") = Trim(txtid.Text) Then
         cx = True
         Exit Do
      Else
         rs.MoveNext
      End If
   Loop
   If MsgBox("请确认填写无误,否则修改!", vbOKCancel, "提示") = vbOK Then
      If cx = False Then
         With rs
              .AddNew
              .Fields("产品编号") = Trim(txtid.Text)
              .Fields("条码") = Trim(txttm.Text)
              .Fields("规格") = Trim(txtgg.Text)
              .Fields("数量") = 0
              .Update
              .Close
         End With
         wk.CommitTrans
         txtid.Text = ""
         txtid.Locked = True
         txttm.Text = ""
         txttm.Locked = True
         txtgg.Text = ""
         txtgg.Enabled = False
         txtid.Enabled = False
         txttm.Enabled = False
         Command1.Enabled = True
         Command2.Enabled = False
      Else
         MsgBox "此编号已存在,请重新编号!", vbCritical, "错误"
         txtid.Text = ""
         txtid.SetFocus
         rs.Close
      End If
  Else
      txtid.SetFocus
      rs.Close
  End If
End If
db.Close
End Sub

Private Sub Command3_Click()
  Unload Me
  frmmenu.Show
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
              If nexttabindex = 3 Then
                 Command2.SetFocus
                 Exit For
              End If
          Next i
          KeyAscii = 0
        End If
          
End Sub
Private Sub Form_Load()
  txtid.Enabled = False
  txttm.Enabled = False
  txtgg.Enabled = False
  txtid.Locked = True
  txttm.Locked = True
  txtgg.Locked = True
  txtczy.Text = frmlogin.Combo1.Text
  txtczy.Locked = True
  Command2.Enabled = False
End Sub

Private Sub txtgg_LostFocus()
  If Len(txtgg.Text) > 20 Then
     If MsgBox("此字段长不能超过二十位,请校正!", vbOKCancel, "错误") = vbOK Then
        txtgg.SetFocus
     Else
        Command3.SetFocus
     End If
  End If
End Sub

Private Sub txtid_LostFocus()
  If Len(txtid.Text) > 10 Then
     MsgBox "此字段长不能超过十位,请校正!", vbCritical, "错误"
     txtid.SetFocus
  End If
  
End Sub

Private Sub txttm_LostFocus()
  If Len(txttm.Text) <> 13 Then
     If MsgBox("此字段长只能是十三位,请校正!", vbOKCancel, "错误") = vbOK Then
        txttm.SetFocus
     Else
        Command3.SetFocus
     End If
  End If
End Sub

⌨️ 快捷键说明

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