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

📄 frmcpbs.frm

📁 以前写的一个销售的管理系统,是牙刷销存管理系统,有销售,进货等功能,刚学VB时写的
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmcpbs 
   Caption         =   "产品报损"
   ClientHeight    =   8595
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11880
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   Moveable        =   0   'False
   ScaleHeight     =   8595
   ScaleWidth      =   11880
   StartUpPosition =   3  '窗口缺省
   WindowState     =   2  'Maximized
   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            =   600
      TabIndex        =   7
      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        =   6
         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        =   5
         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        =   4
         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             =   3000
         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
         TabIndex        =   1
         Top             =   1800
         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             =   600
         Width           =   2415
      End
      Begin VB.TextBox txtquan 
         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        =   3
         Top             =   4200
         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        =   11
         Top             =   1800
         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        =   10
         Top             =   3000
         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        =   9
         Top             =   600
         Width           =   1455
      End
      Begin VB.Label Label4 
         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        =   8
         Top             =   4200
         Width           =   1575
      End
   End
End
Attribute VB_Name = "frmcpbs"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
  txtid.Enabled = True
  txttm.Enabled = True
  txtgg.Enabled = True
  txtquan.Enabled = True
  txtid.Locked = False
  txttm.Locked = True
  txtgg.Locked = True
  txtquan.Locked = False
  Command1.Enabled = False
  Command2.Enabled = True
  txtid.SetFocus
End Sub

Private Sub Command2_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("cpk", dbOpenDynaset, dbwrite, dbOptimistic)
  If txtid.Text = "" Or txtquan.Text = "" Then
     If MsgBox("填写不能为空,请重新输入!", vbOKCancel, "错误") = vbOK Then
        Command3.SetFocus
     Else
        Command3.SetFocus
     End If
  Else
     rs.MoveFirst
     Do While rs.EOF <> True
        If rs.Fields("产品编号") = LTrim(txtid.Text) Then
           cx = True
           Exit Do
        Else
           rs.MoveNext
        End If
     Loop
     If MsgBox("请确认填写无误,否则修改!", vbOKCancel, "提示") = vbOK Then
        If cx = False Then
           MsgBox "此产品编号不存在,请重新输入!", vbCritical, "错误"
           txtid.Text = ""
           txtid.SetFocus
        Else
           txttm.Locked = False
           txtgg.Locked = False
           If rs.Fields("数量") = 0 Then
                 MsgBox "已无库存,请先入库!", vbCritical, "错误"
                 Command3.SetFocus
           Else
              If rs.Fields("数量") - CLng(LTrim(txtquan.Text)) < 0 Then
                 MsgBox "存货不足,请调整出库数量!", vbCritical, "错误"
                 txtquan.SetFocus
              Else
                 With rs
                      .Edit
                      .Fields("数量") = .Fields("数量") - CLng(LTrim(txtquan.Text))
                      .Update
                 End With
                 txtid.Text = ""
                 txttm.Text = ""
                 txtgg.Text = ""
                 txtquan.Text = ""
                 txttm.Locked = True
                 txtgg.Locked = True
                 txtid.Enabled = False
                 txttm.Enabled = False
                 txtgg.Enabled = False
                 txtquan.Enabled = False
                 Command2.Enabled = False
                 Command1.Enabled = True
               End If
            End If
        End If
        rs.Close
        db.Close
    Else
        txtid.SetFocus
    End If
End If
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 = 4 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
  txtquan.Enabled = False
  Command2.Enabled = False
End Sub
Private Sub txtid_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("xhk", dbOpenDynaset, dbwrite, dbOptimistic)
  If txtid.Text = "" Then
     If MsgBox("填写不能为空,请重新输入!", vbOKCancel, "错误") = vbOK Then
        Command3.SetFocus
     Else
        Command3.SetFocus
     End If
  Else
     rs.MoveFirst
     Do While rs.EOF <> True
        If rs.Fields("产品编号") = LTrim(txtid.Text) Then
           cx = True
           Exit Do
        Else
           rs.MoveNext
        End If
     Loop
     If cx = False Then
        MsgBox "此产品编号不存在,请重新输入!", vbCritical, "错误"
        txtid.Text = ""
        txtid.SetFocus
     Else
        txttm.Enabled = True
        txtgg.Enabled = True
        txttm.Text = rs.Fields("条码")
        txtgg.Text = rs.Fields("规格")
        txttm.Locked = True
        txtgg.Locked = True
     End If
     rs.Close
     db.Close
  End If
End Sub

⌨️ 快捷键说明

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