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

📄 module_01.frm

📁 朋友fdsfdsafdsafsafsa推荐的vb连接sql
💻 FRM
📖 第 1 页 / 共 3 页
字号:

On Error Resume Next

Frame3.Height = Me.ScaleHeight - Frame2.Height - 48
Frame3.Width = Me.ScaleWidth - 16

ListView1.Height = Frame3.Height * 14
ListView1.Width = Frame3.Width * 14 + 600



Frame1.Width = Me.ScaleWidth - Frame2.Width - 24



End Sub

Private Sub Form_Unload(Cancel As Integer)
End
End Sub


Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)

        ListView1.Sorted = True '排序开始
        
    If ListView1.SortOrder = lvwAscending Then
        ListView1.SortOrder = lvwDescending
    Else
        ListView1.SortOrder = lvwAscending
    End If

        ListView1.Sorted = False '排序开始
        
End Sub

Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)

    Call lit

End Sub


Private Sub m_add_Click()

TextS(1).Locked = False
m_add.Enabled = False
            '清空所有信息
            
tn = Mid(TreeView1.Nodes(TreeView1.SelectedItem.Index).Key, 2, 2)   '取得选中项的Key标识 此标识为数据库中表示的clsid
    
            
    strSQL = "select * from cdeasn where clsid='" & tn & "'"
    '调用语句执行处理
    If USESQL(1, strSQL) Then
        Else
        Exit Sub
    End If
    
        '判断如果查询结果为空 则不执退出
        If Rsbdata.EOF Then
            Call rest
            Exit Sub
        End If
        
        
        
                 
    'ts = nodename & "0000" 'Format(nodename, "0000")
    'ts = Mid(ts, 1, 4)
    'ti = Format(Rsbdata.Fields(10).Value + 1, "0000")
    'Text1.Text = ts & ti 'Format(Rsbdata.Fields(10).Value + 1, nodename & "000000")
            
            
            
    Text1.Text = Format(Rsbdata.Fields(10).Value + 1, tn & "000000")
            
           
            

            For i = 0 To 10
            TextS(i).Text = ""
            Next i
            
            TextS(1).Text = 0
            TextS(4).Text = 17
            TextS(5).Text = 17
            TextS(10).Text = 0
            TextS(11).Text = 0
            
            Check1.Value = 0
            Check2.Value = 0
            
            Combo1.Text = ""
            text6.Text = ""
            Text7.Text = ""
            'Text1.Text = ""
            
'ListView1.ColumnHeaders.Clear
'ListView1.ListItems.Clear
            
            work_bs = 1 '标识为新增状态
                      
            TextS(0).SetFocus
End Sub

Private Sub m_del_Click()



If DEL <> "28552943" Then
    MsgBox "你NO有足够的权限!" + Chr(10) + "请在""操作""菜单中输入可删除权限密码.", vbOKOnly + 48
    Exit Sub
End If



    yn = MsgBox("是否确认删除此商品?", vbYesNo + 32, NO可恢复的操作)

            If yn = 6 Then
                'nodename = Mid(TreeView1.Nodes(TreeView1.SelectedItem.index).Key, 2, Len(TreeView1.Nodes(TreeView1.SelectedItem.index).Key))   '取得选中项的Key标识 此标识为数据库中表示的clsid
                                              

                
                strSQL = "delete from bcd where gdsid='" & Text1.Text & "'"
                '调用语句执行处理
                Call USESQL(1, strSQL)
                strSQL = "delete from pkg where gdsid='" & Text1.Text & "'"
                '调用语句执行处理
                Call USESQL(1, strSQL)
            
                strSQL = "delete from gds where gdsid='" & Text1.Text & "'"
                '调用语句执行处理
                Call USESQL(1, strSQL)
                
            
            
                Call tnc '刷新数据
            
            End If
    
    
End Sub

Private Sub m_exit_Click()
End
End Sub

Private Sub m_save_Click()

'调用检查输入是否符合函数
If Not (check) Then Exit Sub


'如果标识在新增状态 则保存新的资料 否则保存原有资料编辑
If work_bs = 1 Then





'------------------


            If Check1.Value = 1 Then
                    t_01 = "y"
                Else
                    t_01 = "n"
            End If
            
            If Check2.Value = 1 Then
                    t_02 = "y"
                Else
                    t_02 = "n"
            End If
            




            t_03 = Format(Combo1.ListIndex + 1, "00")
                        
                        
    strSQL = "insert into gds(gdsid,clsid,gdsdes,salprc,bsepkg,spc,taxrto,saltaxrto,bnd,mftloc,mftfct,srtcde,rfnprc,rfntaxprc,isstpsal,isstp,dptid,authorno,udtpsn) VALUES('" & Text1.Text & "','" & Mid(Text1.Text, 1, 2) & "','" & TextS(0).Text & "'," & TextS(1).Text & ",'" & TextS(2).Text & "','" & TextS(3).Text & "',0." & TextS(4).Text & ",0." & TextS(5).Text & ",'" & TextS(6).Text & "','" & TextS(7).Text & "','" & TextS(8).Text & "','" & TextS(9).Text & "'," & TextS(10).Text & "," & TextS(11).Text & ",'" & t_01 & "','" & t_02 & "','" & t_03 & "','" & text6.Text & "','0')"
    If USESQL(1, strSQL) Then
        Else
        Exit Sub
    End If



    '取得商品编码最大值
    strSQL = "select * from cdeasn where clsid='" & Mid(Text1.Text, 1, 2) & "'"
    '调用语句执行处理
    If USESQL(1, strSQL) Then
        Else
        Exit Sub
    End If
    '更新商品编码自动生成表+1
    strSQL = "update cdeasn set curcdevlu=" & Rsbdata.Fields(10).Value + 1 & " where clsid='" & Mid(Text1.Text, 1, 2) & "'"
    If USESQL(1, strSQL) Then
        Else
        Exit Sub
    End If
    '得到时间
    'Dim da As Date
    da = Now
    For i = 1 To Len(da)
        ts = Mid(da, i, 1)
    If ts <> "-" And ts <> " " And ts <> ":" Then
        tm = tm & Mid(da, i, 1)
    End If
    Next
    
    
If Len(Text7.Text) > 0 Then

    '保存商品条形码
    strSQL = "insert into bcd(bcd,gdsid,udtpsn,udtdtm,pkgid) VALUES('" & Text7.Text & "','" & Text1.Text & "','" & 0 & "','" & tm & "','01')"
    If USESQL(1, strSQL) Then
        Else
        Exit Sub
    End If
    
End If
            
            
        
    '保存商品单位表
    strSQL = "insert into pkg(gdsid,pkgid,pkgdes,cnvrto,salprc,iscseorspt,udtdtm) VALUES('" & Text1.Text & "','01','" & TextS(2).Text & "',1," & TextS(1).Text & ",'1','" & tm & "')"
    If USESQL(1, strSQL) Then
        Else
        Exit Sub
    End If
    

    

    
'是修改现在商品信息
Else




            If Check1.Value = 1 Then
                    t_01 = "y"
                Else
                    t_01 = "n"
            End If
            
            If Check2.Value = 1 Then
                    t_02 = "y"
                Else
                    t_02 = "n"
            End If
            
            
    'temp = "0." & TextS(4).Text
    'temp = TextS(10).Text + temp * TextS(10).Text
    'TextS(11).Text = temp
    
    
            t_03 = Format(Combo1.ListIndex + 1, "00")

                        
            't_03 = Combo1.Text
            t_04 = text6.Text
            
            


    strSQL = "update gds set gdsdes='" & TextS(0).Text & "',salprc=" & TextS(1).Text & ",bsepkg='" & TextS(2).Text & "',spc='" & TextS(3).Text & "',taxrto=0." & TextS(4).Text & ",saltaxrto=0." & TextS(5).Text & ",bnd='" & TextS(6).Text & "',mftloc='" & TextS(7).Text & "',mftfct='" & TextS(8).Text & "',srtcde='" & TextS(9).Text & "',rfnprc=" & TextS(10).Text & ",rfntaxprc=" & TextS(11).Text & ",isstpsal='" & t_01 & "',isstp='" & t_02 & "',dptid='" & t_03 & "',authorno='" & text6.Text & "'" & " where gdsid='" & Text1.Text & "'"
    '调用语句执行处理
If USESQL(1, strSQL) = False Then
    MsgBox "错误在更新商品表.", 48
End If

    '得到时间
    'Dim da As Date
    da = Now
    For i = 1 To Len(da)
            ts = Mid(da, i, 1)
        If ts <> "-" And ts <> " " And ts <> ":" Then
            tm = tm & Mid(da, i, 1)
        End If
    Next
    
    
    
If Len(Text7.Text) > 0 Then

'先查询条形码是否存在
    strSQL = "select * from bcd where gdsid='" & Text1.Text & "'"
    If USESQL(1, strSQL) Then
        Else
        Exit Sub
    End If


'判断如果查询结果为空则新增商品条形码 否则更新
        If Rsbdata.EOF Then

            '保存商品条形码
            strSQL = "insert into bcd(bcd,gdsid,udtpsn,udtdtm,pkgid) VALUES('" & Text7.Text & "','" & Text1.Text & "','" & 0 & "','" & tm & "','01')"
            If USESQL(1, strSQL) Then
                Else
                Exit Sub
            End If
    
        Else
            '保存商品条形码
            strSQL = "update bcd set bcd='" & Text7.Text & "',udtpsn='" & 0 & "',udtdtm='" & tm & "',pkgid='01' where gdsid='" & Text1.Text & "'"

            If USESQL(1, strSQL) = False Then
                MsgBox "错误在更新商品条形码.", 48
            End If

        End If

    Else
    '如果变更为空的话 则删除此表
    strSQL = "delete from bcd where gdsid='" & Text1.Text & "'"
    '调用语句执行处理
    If USESQL(1, strSQL) Then
        Else
        Exit Sub
    End If
End If
    
    

    '保存商品单位表
    
    
    
'先查询商品单位表是否存在
    strSQL = "select * from pkg where gdsid='" & Text1.Text & "'"
    If USESQL(1, strSQL) Then
        Else
        Exit Sub
    End If

    
    
    '判断如果查询结果为空则新增商品条形码 否则更新
        If Rsbdata.EOF Then
                '保存商品单位表
                strSQL = "insert into pkg(gdsid,pkgid,pkgdes,cnvrto,salprc,iscseorspt,udtdtm) VALUES('" & Text1.Text & "','01','" & TextS(2).Text & "',1," & TextS(1).Text & ",'1','" & tm & "')"
                If USESQL(1, strSQL) Then
                    Else
                    Exit Sub
                End If
            Else
                strSQL = "update pkg set pkgid='01',pkgdes='" & TextS(2).Text & "',cnvrto=1,salprc=" & TextS(1).Text & ",iscseorspt='1',udtdtm='" & tm & "' where gdsid='" & Text1.Text & "'"
                    
                If USESQL(1, strSQL) = False Then
                    MsgBox "错误在更新商品单位表.", 48
                End If
        End If



    


    
    
    
    
    
    
    '-------------
End If


      





Call tnc



End Sub

Private Sub m_set_Click()
Form1.Show 1
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Text7.SetFocus
End If
End Sub

Private Sub TextS_KeyPress(Index As Integer, KeyAscii As Integer)



If Index = 1 Or Index = 10 Then

If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 And KeyAscii <> 13 Then
    KeyAscii = 0
End If


End If





If KeyAscii = 13 And Index = 0 Then
    TextS(2).SetFocus
End If
If KeyAscii = 13 And Index = 2 Then
    TextS(3).SetFocus
End If
If KeyAscii = 13 And Index = 3 Then
    TextS(6).SetFocus
End If
If KeyAscii = 13 And Index = 6 Then
    TextS(7).SetFocus
End If
If KeyAscii = 13 And Index = 7 Then
    TextS(1).SetFocus
    TextS(1).SelLength = Len(TextS(1))
End If
If KeyAscii = 13 And Index = 1 Then
    TextS(9).SetFocus
End If
If KeyAscii = 13 And Index = 9 Then
    TextS(8).SetFocus
End If
If KeyAscii = 13 And Index = 8 Then
    TextS(10).SetFocus
    TextS(10).SelLength = Len(TextS(10))
End If
If KeyAscii = 13 And Index = 10 Then
    Combo1.SetFocus
End If
If KeyAscii = 13 And Index = 4 Then
    TextS(5).SetFocus
    TextS(5).SelLength = Len(TextS(5))
End If
If KeyAscii = 13 And Index = 5 Then
    text6.SetFocus
End If


End Sub





Private Sub TextS_LostFocus(Index As Integer)


If Index = 10 Then

    temp = "0." & TextS(4).Text
    temp = TextS(10).Text + temp * TextS(10).Text
    TextS(11).Text = Format(temp, ".####") 'Round(temp, 4)

End If
If Index = 11 Then

    temp = "0." & TextS(4).Text
    temp = TextS(11).Text / (1 + temp)
    TextS(10).Text = Format(temp, ".####") 'Round(temp)

End If

End Sub

Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)


nodename = Mid(TreeView1.Nodes(TreeView1.SelectedItem.Index).Key, 2, Len(TreeView1.Nodes(TreeView1.SelectedItem.Index).Key)) '取得选中项的Key标识 此标识为数据库中表示的clsid
 
 
Node.Image = 2

If selebs Then
    TreeView1.Nodes(selebs).Image = 1
End If
selebs = Node.Index '保存本次选择的对象序号


        
        
If Node.Index = 1 Then
        m_save.Enabled = False
        m_add.Enabled = False
        m_del.Enabled = False
    Else
        m_save.Enabled = True
        m_add.Enabled = True
        m_del.Enabled = True
End If


'调用分类读取函数
'Call lit
Call tnc


End Sub

Private Sub work_Click()

End Sub

⌨️ 快捷键说明

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