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

📄 frm_gys.frm

📁 是一款专业的销售管理软件
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         BackColor       =   &H80000018&
         Height          =   300
         Index           =   3
         Left            =   1485
         TabIndex        =   8
         Top             =   1590
         Width           =   1710
      End
      Begin VB.TextBox Text1 
         BackColor       =   &H80000018&
         Height          =   300
         Index           =   2
         Left            =   1485
         TabIndex        =   6
         Top             =   1125
         Width           =   1710
      End
      Begin VB.TextBox Text1 
         BackColor       =   &H80000018&
         Height          =   300
         Index           =   1
         Left            =   1485
         TabIndex        =   4
         Top             =   675
         Width           =   1710
      End
      Begin VB.TextBox Text1 
         BackColor       =   &H80000018&
         Height          =   300
         Index           =   0
         Left            =   1485
         TabIndex        =   2
         Top             =   225
         Width           =   1710
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "备      注"
         Height          =   180
         Left            =   375
         TabIndex        =   11
         Top             =   2625
         Width           =   900
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "传      真"
         Height          =   180
         Left            =   375
         TabIndex        =   9
         Top             =   2160
         Width           =   900
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "联系电话"
         Height          =   180
         Left            =   375
         TabIndex        =   7
         Top             =   1710
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "业务联系人"
         Height          =   180
         Left            =   375
         TabIndex        =   5
         Top             =   1260
         Width           =   900
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "供应商名称"
         Height          =   180
         Left            =   375
         TabIndex        =   3
         Top             =   795
         Width           =   900
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "供应商编号"
         Height          =   180
         Left            =   375
         TabIndex        =   1
         Top             =   300
         Width           =   900
      End
   End
End
Attribute VB_Name = "frm_gys"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Dim i As Integer         '用于FOR循环中的变量
Dim StrNum As Long       '定义一个用于保存编号信息的变量
Dim ETemp  As Integer    '定义一个标识变量,用于标识添加的日志

Private Sub Cmd_Add_Click()
    On Error Resume Next
    For i = 0 To 5
        Text1(i).Text = ""
    Next i
    Adodc1.RecordSource = "select * from tb_gys order by gys_id"
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then
        Adodc1.Recordset.MoveLast
        StrNum = Val(Adodc1.Recordset.Fields("gys_IDs")) + 1
        'Len函数用于取字符串的长度,Trim函数用于去除字符串中的空格,关于这两个函数的具体用法
        Select Case Len(Trim(StrNum))                     '位数不足则用0补其
        Case 1
            StrTemp = "00000"
        Case 2
            StrTemp = "0000"
        Case 3
            StrTemp = "000"
        Case 4
            StrTemp = "00"
        Case 5
            StrTemp = "0"
        Case 6
            StrTemp = ""
        End Select
        Text1(0).Text = "GYS" & Trim(StrTemp) & Trim(Str(StrNum))  '在文本框中显示供应商编号信息
    Else
        Text1(0).Text = "GYS000001"                                '如果数据库中没有记录,则给供应商编号赋一个初值
        StrNum = 1
    End If
    Text1(1).SetFocus
    Cmd_Save.Enabled = True
    Cmd_Del.Enabled = False
    Cmd_Edit.Enabled = False
End Sub

Private Sub Cmd_del_Click()
    rtn = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3)      '运用API函数SetWindowPos,来实现取消窗体置前的功能
    If Adodc1.Recordset.EOF = False Then
        c = MsgBox("您确认要删除该记录吗?", 17, "删除提示信息")
        If c = vbOK Then
            Adodc1.Recordset.Delete     '删除所选中的记录信息
            Adodc1.Refresh
            ETemp = 1                   '删除标识
            Call joinRZ                 '调用添加日志过程,添加删除信息日志
            For i = 0 To 5           '在删除完信息之后,清空文本框中的内容
                Text1(i).Text = ""
            Next i
            Cmd_Del.Enabled = False
            Call TRefresh                 '调用数据刷新过程
        End If
    Else
        MsgBox "当前数据库中已经没有可删除的记录", 64
    End If
End Sub

Private Sub Cmd_edit_Click()
    rtn = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3)      '运用API函数SetWindowPos,来实现取消窗体置前的功能
    If Text1(0).Text = "" Or Text1(1).Text = "" Then
        MsgBox "请选择需要改动的记录信息!", 48
    Else
        c = MsgBox("确认要修改该记录吗?", 33)
        If c = vbOK Then                                   '如果确认修改的话进行修改操作
            If Text1(1).Text = "" Then
                MsgBox "供应商名称不能为空值!", 48
            Else
                Call Main     '调用公共模块中的连接数据库函数
                '利用SQL语句修改供应商信息
                Set adoRs = adoCon.Execute("UPDATE tb_gys SET gys_Name='" + Text1(1).Text + "',gys_lxr='" + Text1(2).Text + "',gys_phone='" + Text1(3).Text + "',gys_fax='" + Text1(4).Text + "',gys_remark='" + Text1(5).Text + "',gys_date='" + Str(Now) + "',gys_jlxgr='" + Name1 + "' where gys_ID='" + Text1(0) + "'")
                ETemp = 0                   '修改标识
                Call joinRZ                 '调用添加日志过程,添加修改信息日志
                MsgBox "信息修改成功", 64
                Cmd_Edit.Enabled = False
                adoCon.Close                  '关闭数据连接
                Call TRefresh                 '调用数据刷新过程
            End If
        Else
        End If
    End If
End Sub
Private Sub Cmd_exit_Click()
    Unload Me
End Sub

Private Sub Cmd_save_Click()
    rtn = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3)     '运用API函数SetWindowPos,来实现取消窗体置前的功能
    Adodc1.RecordSource = "select * from tb_gys where gys_ID='" + Text1(0) + "'"    '检索所要保存的信息在数据库中是否已经存在
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then
        MsgBox "该信息已经存在,信息保存不成功", 64
    Else
        c = MsgBox("您确认要保存该信息吗?", 33)
        If c = vbOK Then
            If Text1(1).Text = "" Or Text1(2).Text = "" Then                  '确保供应商名称及联系人信息输入不为空值
                MsgBox "供应商名称及联系人等信息不能为空值!", 48
            Else
                Call Main                                            '调用公共模块中的连接数据库函数
                'Val是字符转换函数,用于将字符型数据转换为数值型数据,Mid函数是用于取字符串中具体值的函数
                NumId = Val(Mid(Text1(0).Text, 2, Len(Text1(0).Text)))
                '保存供应商信息
                Set adoRs = adoCon.Execute("insert into tb_GYS(gys_ids,gys_id,GYS_Name,GYS_lxr,gys_phone,gys_fax,gys_remark) values(" & StrNum & ",'" & Text1(0).Text & "','" & Text1(1).Text & "','" & Text1(2).Text & "','" & Text1(3).Text & "','" & Text1(4).Text & "','" & Text1(5).Text & "')")
                MsgBox "信息保存成功", 64
                Cmd_Save.Enabled = False
                adoCon.Close
                Call TRefresh                               '调用数据刷新过程
            End If
        Else
        End If
    End If
End Sub

Private Sub DataGrid1_Click()
    Call JionBack                                        '调用数据信息反绑定过程
    Cmd_Del.Enabled = True
    Cmd_Edit.Enabled = True
    Cmd_Save.Enabled = False
End Sub


Private Sub Form_Load()
    rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)     '运用API函数SetWindowPos,来实现使窗体置前的功能
    Adodc1.ConnectionString = CnnStr
    Adodc1.RecordSource = "select * from tb_gys"
    Adodc1.Refresh
    Me.Left = (Screen.Width - Me.Width) / 2
    Me.Top = (Screen.Height - Me.Height) / 2
End Sub

Private Sub joinRZ()

    Open (App.Path & "\系统日志.ini") For Input As #1
    Do While Not EOF(1)
        Line Input #1, Intext
        TStr = TStr + Intext + Chr(13) + Chr(10)
    Loop
    Close #1
    If ETemp = 0 Then         '添加修改信息日志
        TStr = TStr + "   " + Name1 + "               " + Format(Now, "yyyy-mm-dd hh:mm:ss") + "            " + "修改票号 " + Text1(0).Text + "(" + Text1(1).Text + ")" + Chr(13) + Chr(10)
    ElseIf ETemp = 1 Then     '添加删除信息日志
        TStr = TStr + "   " + Name1 + "               " + Format(Now, "yyyy-mm-dd hh:mm:ss") + "            " + "删除票号 " + Text1(0).Text + "(" + Text1(1).Text + ")" + Chr(13) + Chr(10)
    End If
    Open (App.Path & "\系统日志.ini") For Output As #1   '将日志信息保存到文件当中
    Print #1, TStr
    Close #1
End Sub

Private Sub JionBack()
    On Error Resume Next     '执行错误处理
    Dim SLen As Integer
    If Adodc1.Recordset.RecordCount > 0 Then
        StrNum = Val(Adodc1.Recordset.Fields("gys_ID"))
        SLen = Len(Trim(StrNum))
        Select Case SLen    '位数不足者补0
        Case 1
            StrTemp = "00000"
        Case 2
            StrTemp = "0000"
        Case 3
            StrTemp = "000"
        Case 4
            StrTemp = "00"
        Case 5
            StrTemp = "0"
        Case 6
            StrTemp = ""
        End Select
        '将数据信息反绑定到文本框当中
        Text1(0).Text = Adodc1.Recordset(1)
        Text1(1).Text = Adodc1.Recordset(2)
        Text1(2).Text = Adodc1.Recordset(3)
        Text1(3).Text = Adodc1.Recordset(4)
        Text1(4).Text = Adodc1.Recordset(5)
        Text1(5).Text = Adodc1.Recordset(6)
    End If
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If Index = 1 Then
            Text1(2).SetFocus
        ElseIf Index = 2 Then
            Text1(3).SetFocus
        ElseIf Index = 3 Then
            Text1(4).SetFocus
        ElseIf Index = 4 Then
            Text1(5).SetFocus
        ElseIf Index = 5 Then
            Call Cmd_save_Click
            Cmd_Add.SetFocus
        End If
    End If
End Sub

Private Sub TRefresh()
    Adodc1.RecordSource = "select * from tb_gys order by gys_ID"
    Adodc1.Refresh
End Sub
Private Sub Form_Unload(Cancel As Integer)
    frm_main.Enabled = True
End Sub

⌨️ 快捷键说明

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