cpform.frm

来自「一套VB完整的灯具销售管理系统设计」· FRM 代码 · 共 730 行 · 第 1/2 页

FRM
730 行
字号
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form cpform 
   AutoRedraw      =   -1  'True
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "产品管理"
   ClientHeight    =   5310
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7410
   Icon            =   "cpform.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5310
   ScaleWidth      =   7410
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access"
      DatabaseName    =   ""
      DefaultCursorType=   0  'DefaultCursor
      DefaultType     =   2  'UseODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   315
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   ""
      Top             =   5445
      Visible         =   0   'False
      Width           =   4875
   End
   Begin VB.Frame Frame1 
      Caption         =   "编辑区"
      ForeColor       =   &H000000C0&
      Height          =   4830
      Left            =   225
      TabIndex        =   0
      Top             =   210
      Width           =   6945
      Begin VB.TextBox djtxt 
         DataField       =   "单价"
         DataSource      =   "Data1"
         Enabled         =   0   'False
         Height          =   285
         Left            =   1440
         MaxLength       =   16
         TabIndex        =   13
         Top             =   870
         Width           =   1860
      End
      Begin MSDBGrid.DBGrid DBGrid1 
         Bindings        =   "cpform.frx":0442
         Height          =   2610
         Left            =   210
         OleObjectBlob   =   "cpform.frx":0452
         TabIndex        =   11
         Top             =   1320
         Width           =   4320
      End
      Begin VB.Frame Frame2 
         Height          =   3420
         Left            =   4965
         TabIndex        =   8
         Top             =   1230
         Width           =   1770
         Begin VB.CommandButton Nextfind 
            Caption         =   "查找下一个"
            Enabled         =   0   'False
            Height          =   375
            Left            =   300
            TabIndex        =   22
            Top             =   780
            Width           =   1200
         End
         Begin VB.CommandButton Find 
            Caption         =   "查询"
            Height          =   375
            Left            =   300
            TabIndex        =   21
            Top             =   360
            Width           =   1200
         End
         Begin VB.CommandButton closeform 
            Cancel          =   -1  'True
            Caption         =   "退出(&X)"
            Height          =   420
            Left            =   300
            TabIndex        =   12
            Top             =   2790
            Width           =   1200
         End
         Begin VB.CommandButton delete 
            Caption         =   "删除产品"
            Height          =   420
            Left            =   300
            TabIndex        =   10
            Top             =   1995
            Width           =   1200
         End
         Begin VB.CommandButton add 
            Caption         =   "添加产品"
            Height          =   375
            Left            =   300
            TabIndex        =   9
            Top             =   1575
            Width           =   1200
         End
      End
      Begin VB.CommandButton Last 
         Caption         =   "最后一个"
         Height          =   405
         Left            =   3555
         TabIndex        =   7
         Top             =   4215
         Width           =   1080
      End
      Begin VB.CommandButton Nextbutton 
         Caption         =   "下一个"
         Height          =   405
         Left            =   2445
         TabIndex        =   6
         Top             =   4215
         Width           =   1080
      End
      Begin VB.CommandButton Previous 
         Caption         =   "上一个"
         Height          =   405
         Left            =   1320
         TabIndex        =   5
         Top             =   4215
         Width           =   1080
      End
      Begin VB.CommandButton First 
         Caption         =   "第一个"
         Height          =   405
         Left            =   210
         TabIndex        =   4
         Top             =   4215
         Width           =   1080
      End
      Begin VB.TextBox pmtxt 
         DataField       =   "品名"
         DataSource      =   "Data1"
         Enabled         =   0   'False
         Height          =   315
         Left            =   1440
         MaxLength       =   20
         TabIndex        =   1
         Top             =   435
         Width           =   2955
      End
      Begin VB.Line Line3 
         BorderColor     =   &H00C0C0FF&
         X1              =   5010
         X2              =   6660
         Y1              =   810
         Y2              =   810
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "共"
         ForeColor       =   &H00FFFFFF&
         Height          =   180
         Index           =   1
         Left            =   5160
         TabIndex        =   20
         Top             =   555
         Width           =   180
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "种"
         ForeColor       =   &H00FFFFFF&
         Height          =   180
         Left            =   6315
         TabIndex        =   19
         Top             =   870
         Width           =   180
      End
      Begin VB.Label dq 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         ForeColor       =   &H0000FFFF&
         Height          =   225
         Left            =   5520
         TabIndex        =   18
         Top             =   885
         Width           =   690
      End
      Begin VB.Label zs 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         ForeColor       =   &H00FFFF00&
         Height          =   225
         Left            =   5505
         TabIndex        =   17
         Top             =   540
         Width           =   690
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "第"
         ForeColor       =   &H00FFFFFF&
         Height          =   180
         Index           =   0
         Left            =   5190
         TabIndex        =   16
         Top             =   885
         Width           =   180
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "种"
         ForeColor       =   &H0080FFFF&
         Height          =   180
         Index           =   1
         Left            =   6300
         TabIndex        =   15
         Top             =   555
         Width           =   180
      End
      Begin VB.Label Label2 
         BackColor       =   &H00400000&
         BorderStyle     =   1  'Fixed Single
         Height          =   795
         Index           =   0
         Left            =   4995
         TabIndex        =   14
         Top             =   405
         Width           =   1695
      End
      Begin VB.Line Line2 
         BorderColor     =   &H00FFFFFF&
         X1              =   45
         X2              =   4665
         Y1              =   4020
         Y2              =   4020
      End
      Begin VB.Line Line1 
         X1              =   60
         X2              =   4665
         Y1              =   4005
         Y2              =   4005
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "单价:"
         Height          =   180
         Left            =   810
         TabIndex        =   3
         Top             =   915
         Width           =   540
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "产品名称:"
         Height          =   180
         Left            =   465
         TabIndex        =   2
         Top             =   495
         Width           =   900
      End
   End
End
Attribute VB_Name = "cpform"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 
Private Sub add_Click()
'保存新记录
  If add.Caption = "保存" Then
     DBGrid1.Enabled = True
     add.Enabled = True
     Find.Enabled = True
     '移动按钮,全解
     First.Enabled = True
     Previous.Enabled = True
     Nextbutton.Enabled = True
     Last.Enabled = True
     add.Caption = "添加产品"
     delete.Caption = "删除产品"
     closeform.Enabled = True
     pmtxt.Enabled = False
     djtxt.Enabled = False
        Data1.Recordset.MoveLast
        '判断库是否为空
    Dim Db As Database, ef As Recordset, CountNum As Integer, xy As Integer
       Set Db = OpenDatabase(appData)
       Set ef = Db.OpenRecordset("cpk", dbOpenTable)
       CountNum = ef.RecordCount
       zs.Caption = CountNum
     If CountNum = 0 Then
     add.Enabled = True
     delete.Enabled = False
     First.Enabled = False
     Previous.Enabled = False
     Nextbutton.Enabled = False
     Last.Enabled = False
     Find.Enabled = False
     Else
      add.Enabled = True
      delete.Enabled = True
      First.Enabled = True
      Previous.Enabled = True
      Nextbutton.Enabled = True
      Last.Enabled = True
      Find.Enabled = True
      End If
      Db.Close
         Exit Sub
   End If
   '添加新记录代码
   DBGrid1.Enabled = False
   add.Enabled = False
   delete.Enabled = True
   '移动按钮,全锁
   First.Enabled = False
   Previous.Enabled = False
   Nextbutton.Enabled = False
   Last.Enabled = False
   Find.Enabled = False
   Nextfind.Enabled = False
   add.Caption = "保存"
   delete.Caption = "放弃"
   closeform.Enabled = False
   pmtxt.Enabled = True
   djtxt.Enabled = True
   pmtxt.SetFocus
   Data1.Recordset.AddNew
End Sub

Private Sub CloseForm_Click()
Unload Me
End Sub

Private Sub Data1_Reposition()
dq.Caption = Data1.Recordset.AbsolutePosition + 1
End Sub



Private Sub DBGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And DBGrid1.Col = 0 Then
   BK = DBGrid1.Text
   cpform.MousePointer = 11
   Load ADDCP
   cpform.MousePointer = 0
   ADDCP.Show 1
  End If
End Sub

Private Sub delete_Click()

 '按钮为(放弃)时用代码

⌨️ 快捷键说明

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