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

📄 frmcustomer1.frm

📁 一个简单的用vb制作的公司贸易管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Index           =   4
         Left            =   240
         TabIndex        =   18
         Top             =   2760
         Width           =   1245
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "邮政编号:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Index           =   13
         Left            =   240
         TabIndex        =   17
         Top             =   3240
         Width           =   1125
      End
      Begin VB.Label Label2 
         BackStyle       =   0  'Transparent
         Caption         =   "国家:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   14
         Left            =   240
         TabIndex        =   16
         Top             =   3720
         Width           =   975
      End
      Begin VB.Label Label2 
         BackStyle       =   0  'Transparent
         Caption         =   "公司主页:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   2
         Left            =   240
         TabIndex        =   15
         Top             =   4200
         Width           =   975
      End
   End
   Begin VB.Frame Frame3 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "备注信息"
      ForeColor       =   &H80000008&
      Height          =   1215
      Left            =   120
      TabIndex        =   13
      Top             =   5160
      Width           =   7212
      Begin VB.TextBox txtItem 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   840
         Index           =   9
         Left            =   120
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   9
         Top             =   240
         Width           =   6852
      End
   End
   Begin VB.TextBox txtNo 
      Height          =   270
      Left            =   600
      TabIndex        =   12
      TabStop         =   0   'False
      Top             =   6720
      Visible         =   0   'False
      Width           =   735
   End
End
Attribute VB_Name = "frmCustomer1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'是否改动过记录,ture为改过
Dim mblChange As Boolean
Public txtsql As String

Private Sub cboItem_Change(Index As Integer)
    '有变化设置gblchange
    mblChange = True
End Sub

Private Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    EnterToTab KeyCode

End Sub

Private Sub cmdExit_Click()
    If mblChange And cmdSave.Enabled Then
        If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
            '保存
            Call cmdSave_Click
        End If
    End If
    Unload Me
End Sub

Private Sub cmdSave_Click()
    Dim intCount As Integer
    Dim SMeg As String
    Dim mrc As ADODB.Recordset
    Dim Msgtext As String

    For intCount = 0 To 8
        If Trim(txtItem(intCount) & " ") = "" Then
            Select Case intCount
              Case 0
                SMeg = "公司名称(CH)"
              Case 1
                SMeg = "公司名称(EN)"
              Case 2
                SMeg = "联系地址(CH)"
              Case 3
                SMeg = "联系地址(EN)"
              Case 4
                SMeg = "所在城市"
              Case 5
                SMeg = "省份/区域"
              Case 6
                SMeg = "邮政编码"
              Case 7
                SMeg = "国家"
              Case 8
                SMeg = "公司主页"
            End Select
            SMeg = SMeg & "不能为空!"
            MsgBox SMeg, vbOKOnly + vbExclamation, "警告"
            txtItem(intCount).SetFocus

            Exit Sub
        End If
    Next intCount

    If Not IsNumeric(Trim(txtItem(6))) Then
        MsgBox "邮政编码请输入数字!", vbOKOnly + vbExclamation, "警告"
        txtItem(6).SetFocus
        Exit Sub
    End If

    If gintCmode = 1 Then
        txtsql = "select * from customers where cn_CompanyName ='" & Trim(txtItem(0)) & "'"
        Set mrc = ExecuteSQL(txtsql, Msgtext)
        If mrc.EOF = False Then
            MsgBox "已经存在此公司的记录!", vbOKOnly + vbExclamation, "警告"
            txtItem(0).SetFocus
            Exit Sub
        End If
        mrc.Close
    End If

    If gintCmode = 2 Then
        '先删除已有记录
        txtsql = "delete from customers where CustomerID ='" & Trim(txtNo) & "'"
        Set mrc = ExecuteSQL(txtsql, Msgtext)
    End If

    '再加入新记录
    txtsql = "select * from customers "
    Set mrc = ExecuteSQL(txtsql, Msgtext)
    mrc.AddNew

    mrc.Fields(0) = txtNo
    For intCount = 0 To 9
        mrc.Fields(intCount + 1) = Trim(txtItem(intCount))
    Next intCount

    mrc.Update
    mrc.Close

    If gintCmode = 1 Then
        For intCount = 0 To 9
            txtItem(intCount) = ""
        Next intCount

        mblChange = False
        MsgBox "添加供应商信息成功!", vbOKOnly + vbExclamation, "添加供应商信息"

        Unload Me
        If flagCedit Then
            Unload frmCustomer
            frmCustomer.txtsql = "select * from customers"
            frmCustomer.Show
        End If

    ElseIf gintCmode = 2 Then
        Unload Me
        If flagCedit Then
            Unload frmCustomer
        End If
        frmCustomer.txtsql = "select * from customers"
        frmCustomer.Show

    End If

End Sub

Private Sub Command1_Click()

    frmLinkman.txtsql = "select * from 公司联系人 where 部门='" & Trim(txtItem(0)) & "'"
    frmLinkman.Show
    'frmLinkman1.txtItem(3).Text = Trim(txtItem(0))

End Sub

Private Sub Form_Load()
    Dim sSql As String
    Dim intCount As Integer
    Dim Msgtext As String
    Dim mrcc As ADODB.Recordset

    If gintCmode = 1 Then
        Command1.Enabled = False

        Me.Caption = Me.Caption & "添加"
        txtNo = GetRkno()
    ElseIf gintCmode = 2 Then

        Set mrcc = ExecuteSQL(txtsql, Msgtext)

        If mrcc.EOF = False Then
            With mrcc

                txtNo = mrcc.Fields(0)

                For intCount = 0 To 9
                    If Not IsNull(.Fields(intCount + 1)) Then
                        txtItem(intCount) = .Fields(intCount + 1)
                    End If
                Next intCount

            End With

        End If
        mrcc.Close
        Me.Caption = Me.Caption & "修改"

    ElseIf gintCmode = 3 Then

        Set mrcc = ExecuteSQL(txtsql, Msgtext)

        If mrcc.EOF = False Then
            With mrcc

                txtNo = mrcc.Fields(0)

                For intCount = 0 To 9
                    If Not IsNull(.Fields(intCount + 1)) Then
                        txtItem(intCount) = .Fields(intCount + 1)
                        txtItem(intCount).Enabled = False

                    End If
                Next intCount

            End With
            cmdSave.Enabled = False

        End If
        mrcc.Close
        Me.Caption = Me.Caption & "查看"
    End If

    mblChange = False

End Sub

Private Sub Form_Unload(Cancel As Integer)
    gintCmode = 0
End Sub

Private Sub txtItem_Change(Index As Integer)
    '有变化设置gblchange
    mblChange = True

End Sub

Private Sub txtItem_GotFocus(Index As Integer)
    txtItem(Index).SelStart = 0
    txtItem(Index).SelLength = Len(txtItem(Index))
    txtItem(Index).BackColor = &HFFFF&

End Sub

Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    EnterToTab KeyCode

End Sub

Private Sub txtItem_LostFocus(Index As Integer)
    txtItem(Index).BackColor = &H80000005
End Sub

⌨️ 快捷键说明

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