frmpdcontrol.frm

来自「通用书店管理系统」· FRM 代码 · 共 177 行

FRM
177
字号
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmPDControl 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "盘点控制表"
   ClientHeight    =   2025
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4365
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2025
   ScaleWidth      =   4365
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdCancel 
      Height          =   420
      Left            =   3270
      Picture         =   "frmPDControl.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   1500
      Width           =   945
   End
   Begin VB.CommandButton cmdSave 
      Height          =   420
      Left            =   2100
      Picture         =   "frmPDControl.frx":14E4
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   1500
      Width           =   960
   End
   Begin VB.Frame Frame1 
      Height          =   1305
      Left            =   120
      TabIndex        =   4
      Top             =   75
      Width           =   4125
      Begin VB.TextBox txtDate 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   11.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1920
         TabIndex        =   1
         Top             =   735
         Width           =   1920
      End
      Begin MSComCtl2.DTPicker DTPLast 
         Height          =   390
         Left            =   1935
         TabIndex        =   0
         Top             =   210
         Width           =   1890
         _ExtentX        =   3334
         _ExtentY        =   688
         _Version        =   393216
         Format          =   58261505
         CurrentDate     =   37328
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "默认盘点日期:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   11.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   375
         Index           =   1
         Left            =   75
         TabIndex        =   6
         Top             =   810
         Width           =   1905
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "上次盘点时间:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   11.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   375
         Index           =   0
         Left            =   90
         TabIndex        =   5
         Top             =   270
         Width           =   1905
      End
   End
End
Attribute VB_Name = "frmPDControl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCancel_Click()
  Unload Me
End Sub

Private Sub cmdSave_Click()
  Dim sqlstring As String
    
  On Error GoTo SaveErr
    
  If Trim(txtDate.Text) = "" Then
    MsgBox "默认盘点时间不能为空!", , "警告"
    Exit Sub
  End If
  
  cN.BeginTrans
  '清空盘点控制表
  sqlstring = "delete from PDControl"
  cN.Execute sqlstring
  sqlstring = "Insert into PDControl (DatLast,intDefault) values (#" & Format(DTPLast.Value, "yyyy-mm-dd") & _
            "#," & CInt(txtDate.Text) & ")"
  cN.Execute sqlstring
  
  cN.CommitTrans
  Unload Me
  Exit Sub
SaveErr:
  cN.RollbackTrans
  MsgBox "保存记录失败:" & Err.Description, vbInformation

End Sub

Private Sub Form_Load()
  Dim sqlstring As String
  Dim rstmp As New ADODB.Recordset
  
  On Error GoTo Err
  
  Me.Move 3000, 3000
  
  sqlstring = "select * from PDControl"
  rstmp.Open sqlstring, cN, adOpenKeyset, adLockReadOnly
  If Not rstmp.EOF Then
     DTPLast.Value = Format(rstmp.Fields("datLast").Value, "yyyy-mm-dd")
     txtDate.Text = rstmp.Fields("intDefault").Value
  End If
  
  Exit Sub
Err:
  MsgBox "打开记录失败:" & Err.Description, vbInformation
End Sub

Private Sub Form_Unload(Cancel As Integer)
  SetToolBar ("0000X00X001X111")
End Sub

Private Sub txtDate_KeyPress(KeyAscii As Integer)
  KeyAscii = ValiText(KeyAscii, vbExpInteger, "", txtDate.Text, 2)
End Sub

⌨️ 快捷键说明

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