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

📄 frm_qckc.frm

📁 是一款专业的销售管理软件
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "编    号"
         Height          =   180
         Left            =   135
         TabIndex        =   5
         Top             =   255
         Width           =   720
      End
   End
End
Attribute VB_Name = "frm_qckc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Prices As Long                  '定义一个计算价格的变量
Dim i As Integer                    '运用在FOR循环中的变量
Dim StrTemp                         '用于显示编号信息的变量
Dim StrNum As Long                  '用于显示编号信息的变量
Dim STrId As String
Dim ETemp As Integer                '定义一个日志标识变量

'*** “添加”货品期初设置的事件过程 ***
Private Sub Cmd_Add_Click()
    For i = 0 To 5                                   '清空文本框中的内容
        Text1(i).Text = ""
    Next i
    Adodc1.RecordSource = "select * from tb_kcxx order by kc_ID"
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then
        Adodc1.Recordset.MoveLast
        StrNum = Val(Adodc1.Recordset.Fields("kc_ID")) + 1    '编号加1

        STrId = Val(Mid(Adodc1.Recordset.Fields("Kc_IDs"), 2, Len(Adodc1.Recordset.Fields("Kc_IDs"))))
        Select Case Len(Trim(STrId))    '位数不足者补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
        STrId = STrId + 1
        STrId = "J" & Trim(StrTemp) & Trim(Str(STrId))
        Text1(0).Text = StrNum
    Else
        STrId = "L000001"    '给出货编号赋一个初值
        Text1(0).Text = 1    '给编号赋一个初值
    End If
    Text1(1).SetFocus
    Cmd_Save.Enabled = True
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_kcxx where kc_ID=" + Str(Text1(0).Text) + ""   '判断要保存的记录信息在数据库中是否存在
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then
        MsgBox "该信息已经存在,信息保存不成功", 64
        Call TRefresh
    Else
        c = MsgBox("您确认要保存该信息吗?", 33)
        If c = vbOK Then
            If Text1(1).Text = "" Or Text1(3).Text = "" Or Text1(4).Text = "" Then
                MsgBox "货品数量、单价或名称不能为空值!", 48
            Else
                'IsNumeric函数用于判断输入的信息是否为数值型数据
                If Not IsNumeric(Text1(3).Text) Or Not IsNumeric(Text1(4).Text) Then
                    MsgBox "输入的货品数量或单价必须为数值型数据", 48
                Else
                    Call Main
                    NumId = Val(Mid(Text1(0).Text, 2, Len(Text1(0).Text)))
                    Prices = Val(Text1(3).Text) * Val(Text1(4).Text)
                    '保存期初货品入库信息
                    Set adoRs = adoCon.Execute("insert into tb_kcxx (kc_ID,kc_IDs,kc_Name,kc_SPEC,kc_UNIT,kc_Num,kc_Price,kc_Remark) values(" & Text1(0) & ",'" & STrId & "','" & Text1(1).Text & "','" & Text1(2).Text & "','" & Combo1.Text & "','" & Text1(3).Text & "','" & Text1(4).Text & "','" & Text1(5).Text & "')")
                    MsgBox "信息保存成功", 64
                    Cmd_Save.Enabled = False
                    Call TRefresh
                    adoCon.Close
                End If
            End If
        Else
        End If
    End If
    Call TRefresh         '调用数据刷新过程
End Sub

Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        Text1(3).SetFocus
    End If
End Sub

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

Private Sub DTPicker1_DropDown()
    If KeyCode = 13 Then
        Text1(5).SetFocus
    End If
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_kcxx"           '连接库存信息数据表
    Adodc1.Refresh
    Me.Left = (Screen.Width - Me.Width) / 2              '使窗体居中
    Me.Top = (Screen.Height - Me.Height) / 2
End Sub

Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        rtn = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3)     '运用API函数SetWindowPos,来实现取消窗体置前的功能
        If Index = 0 Then
            Adodc1.RecordSource = "select * from tb_kcxx where kc_ID=" + Str(Text1(0).Text) + ""
            Adodc1.Refresh
            On Error Resume Next
            If Adodc1.Recordset.RecordCount > 0 Then
                Text1(1).Text = Adodc1.Recordset.Fields("kc_name")
                Text1(2).Text = Adodc1.Recordset.Fields("KC_SPEC")
                Combo1.Text = Adodc1.Recordset.Fields("KC_UNIT")
                Text1(3).Text = Adodc1.Recordset.Fields("KC_Num")
                Text1(4).Text = Adodc1.Recordset.Fields("KC_Price")
                Text1(5).Text = Adodc1.Recordset.Fields("kc_remark")
            Else
                MsgBox "没有相关的库存信息", 48
            End If
        ElseIf Index = 1 Then
            Text1(2).SetFocus
        ElseIf Index = 2 Then
            Combo1.SetFocus
        ElseIf Index = 3 Then
            Text1(4).SetFocus
        ElseIf Index = 4 Then
            Text1(5).SetFocus
        End If
    End If
End Sub

'*** 自定义数据反绑定过程 ***
Private Sub JionBack()
    Dim SLen As Integer
    If Adodc1.Recordset.RecordCount > 0 Then
        StrNum = Val(Adodc1.Recordset.Fields("kc_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
        On Error Resume Next                    '执行错误处理
        Text1(0).Text = "S" & Trim(StrTemp) & Trim(Str(StrNum))
        Text1(1).Text = Adodc1.Recordset(1)
        Text1(2).Text = Adodc1.Recordset(2)
        Combo1.Text = Adodc1.Recordset(3)
        Text1(3).Text = Adodc1.Recordset(4)
        Text1(4).Text = Adodc1.Recordset(5)
        Text1(5).Text = Adodc1.Recordset(9)
    End If
End Sub
'*** 自定义数据刷新过程 ***
Private Sub TRefresh()
    Adodc1.RecordSource = "select * from tb_kcxx order by kc_ID"
    Adodc1.Refresh
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 Form_Unload(Cancel As Integer)
    frm_main.Enabled = True
End Sub

⌨️ 快捷键说明

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