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

📄 frmfactoryadd.frm

📁 企业ERP系统 采用VB+SQL2000实现。 有客户合约
💻 FRM
字号:
VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmFactoryAdd 
   Caption         =   " 加工廠"
   ClientHeight    =   3840
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4140
   Icon            =   "frmFactoryAdd.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   3840
   ScaleWidth      =   4140
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdCancel 
      Caption         =   "關閉&C"
      Height          =   375
      Left            =   2640
      TabIndex        =   9
      Top             =   3360
      Width           =   615
   End
   Begin VB.CommandButton cmdOk 
      Caption         =   "確定&Y"
      Height          =   375
      Left            =   960
      TabIndex        =   7
      Top             =   3360
      Width           =   735
   End
   Begin TabDlg.SSTab SSTab1 
      Height          =   3255
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   4095
      _ExtentX        =   7223
      _ExtentY        =   5741
      _Version        =   393216
      Tabs            =   1
      TabHeight       =   520
      TabCaption(0)   =   "加工廠信息"
      TabPicture(0)   =   "frmFactoryAdd.frx":038A
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "Frame1"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).ControlCount=   1
      Begin VB.Frame Frame1 
         Height          =   2775
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Width           =   3855
         Begin VB.TextBox txtFactoryName 
            Height          =   270
            Left            =   1320
            TabIndex        =   8
            Top             =   360
            Width           =   1815
         End
         Begin VB.TextBox txtFactoryAddress 
            Height          =   270
            Left            =   1320
            TabIndex        =   6
            Top             =   1920
            Width           =   1815
         End
         Begin VB.TextBox txtFactoryAllName 
            Height          =   270
            Left            =   1320
            TabIndex        =   5
            Top             =   1080
            Width           =   1815
         End
         Begin VB.Label Label3 
            Caption         =   "加工廠地址"
            Height          =   375
            Left            =   240
            TabIndex        =   4
            Top             =   1920
            Width           =   1095
         End
         Begin VB.Label Label2 
            Caption         =   "加工廠全稱"
            Height          =   375
            Left            =   240
            TabIndex        =   3
            Top             =   1080
            Width           =   1095
         End
         Begin VB.Label Label1 
            Caption         =   "加工廠簡稱"
            Height          =   255
            Left            =   240
            TabIndex        =   2
            Top             =   360
            Width           =   1215
         End
      End
   End
End
Attribute VB_Name = "frmFactoryAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public newItem As Boolean 'true表示增加
Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdOK_Click()
    ''检查是否有相同编号
    Save newItem
End Sub

Private Sub Form_Load()
    '设置窗口大小
    FormInit Me, False
End Sub

'初始化
Public Sub InitInfo(FactoryName As String)
If newItem = False Then
    Dim rs As ADODB.Recordset

      SystemExecuteStart Me
     ' On Error GoTo errLabel
      Set rs = New ADODB.Recordset
      With rs
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        Set .ActiveConnection = cn
      End With
      Dim strSql As String
      strSql = "select * from Factory where FactoryName='" & FactoryName & "'"
      rs.Open strSql
        If Not rs.EOF Then
            txtFactoryName.Text = rs.Fields!FactoryName
            txtFactoryName.Locked = True
            txtFactoryAllName.Text = rs.Fields!FactoryAllName
            txtFactoryAddress = rs.Fields!FactoryAddress
        End If
      rs.Close
      Set rs = Nothing
      SystemExecuteEnd Me
End If
Exit Sub
errLabel:
    SystemExecuteEnd Me
    objDatabase.DatabaseError
End Sub
Private Sub Save(Optional blModi As Boolean)
    Dim strSql As String
    Dim rs As ADODB.Recordset
    
    strSql = "select * from Factory where FactoryName='" & Trim$(txtFactoryName.Text) & "'"
    On Error GoTo errHandle
    Set rs = New ADODB.Recordset
    With rs
      .CursorLocation = adUseClient
      .CursorType = adOpenDynamic
      .LockType = adLockOptimistic
      Set .ActiveConnection = cn
    End With
    rs.Open strSql
    If txtFactoryName.Text = "" Then
        MsgBox "工廠簡稱不能為空!", vbCritical, "提示"
        rs.Close
        Set rs = Nothing
        txtFactoryName.SetFocus
        Exit Sub
    End If
    If blModi Then
        If Not rs.EOF Then
            MsgBox "此加工廠已存在!", vbCritical, "提示"
            txtFactoryName.Text = ""
            txtFactoryName.SetFocus
            rs.Close
            Set rs = Nothing
            Exit Sub
        End If
        If MsgBox("是否增加操作员?", vbQuestion + vbYesNo, "询问") = vbNo Then
            rs.Close
            Set rs = Nothing
            Exit Sub
        End If
                
        rs.AddNew '新建
        rs.Fields!FactoryName = Trim$(txtFactoryName)
        rs.Fields!FactoryAllName = Trim$(txtFactoryAllName.Text)
        rs.Fields!FactoryAddress = Trim$(txtFactoryAddress.Text)
        rs.Fields!DTime = Now
        rs.Update
        MsgBox "新建成功!", vbInformation, "恭喜'"
    Else
        If rs.EOF Then '修改
            MsgBox "没有可修改的记录!", vbExclamation, "修改"
            rs.Close
            Set rs = Nothing
            txtFactoryName.SetFocus
            Exit Sub
        End If
        If MsgBox("是否修改记录?", vbYesNo + vbQuestion, "修改") = vbNo Then
            rs.Close
            Set rs = Nothing
            Exit Sub
        End If
        rs.Fields!FactoryName = Trim$(txtFactoryName)
        rs.Fields!FactoryAllName = Trim$(txtFactoryAllName.Text)
        rs.Fields!FactoryAddress = Trim$(txtFactoryAddress.Text)
        rs.Fields!DTime = Now
        rs.Update
        MsgBox "修改成功!", vbInformation, "恭喜"
    End If
    rs.Close
    Set rs = Nothing

    frmFactoryMan.FillMshf1 ("select * from Factory")
    Unload Me
    Exit Sub
    
errHandle:
    Set rs = Nothing
    objDatabase.DatabaseError
End Sub


⌨️ 快捷键说明

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