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

📄 frmout.frm

📁 vb写得进销存
💻 FRM
📖 第 1 页 / 共 3 页
字号:
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "新建出货单"
            ImageIndex      =   9
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "加入货品"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "删除货品"
            ImageIndex      =   3
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "出货完成"
            ImageIndex      =   4
         EndProperty
         BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "打印出货单"
            ImageIndex      =   11
         EndProperty
         BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "退出"
            ImageIndex      =   10
         EndProperty
         BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Object.Visible         =   0   'False
            Caption         =   "确定"
            ImageIndex      =   6
         EndProperty
         BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Object.Visible         =   0   'False
            Caption         =   "取消"
            ImageIndex      =   7
         EndProperty
      EndProperty
      BorderStyle     =   1
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "合计(元)  "
      ForeColor       =   &H80000008&
      Height          =   270
      Left            =   300
      TabIndex        =   21
      Top             =   6735
      Width           =   4935
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "购货单位"
      Height          =   180
      Index           =   9
      Left            =   4500
      TabIndex        =   20
      Top             =   1065
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "出货时间"
      Height          =   180
      Index           =   2
      Left            =   4470
      TabIndex        =   3
      Top             =   1485
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "销售性质"
      Height          =   180
      Index           =   1
      Left            =   390
      TabIndex        =   2
      Top             =   1500
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "出货单编号"
      Height          =   180
      Index           =   0
      Left            =   360
      TabIndex        =   1
      Top             =   1080
      Width           =   900
   End
End
Attribute VB_Name = "frmOut"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'17

Private Sub Form_Load()
On Error GoTo eH

    adoHP.ConnectionString = g_cnnStr
    adoCHD.ConnectionString = g_cnnStr
    adoHP.RecordSource = "select * from 出货单 where 0=9"
    adoCHD.RecordSource = "select * from 出货单 where 0=9"
    adoHP.Refresh
    adoCHD.Refresh

    Toolbar1.Buttons(3).Enabled = False
    Toolbar1.Buttons(4).Enabled = False
    Toolbar1.Buttons(5).Enabled = False
    Toolbar1.Buttons(6).Enabled = False
    Frame1.Enabled = False
    
    If g_rst.State = 1 Then g_rst.Close
    Text9.Clear
    g_rst.Open "select distinct(客户名称) as t from 客户资料"
    While Not g_rst.EOF
        Text9.AddItem g_rst!t & ""
        g_rst.MoveNext
    Wend
    
    If g_rst.State = 1 Then g_rst.Close
    Text1.Clear
    g_rst.Open "select 销售性质 as t from 销售性质"
    While Not g_rst.EOF
        Text1.AddItem g_rst!t & ""
        g_rst.MoveNext
    Wend
Exit Sub
eH:
    MsgBox em & vbNewLine & "错误号:1701" & vbNewLine & "错误描述:" & Err.Description

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
On Error GoTo eH
    If KeyAscii = 13 Then
        If g_rst.State = 1 Then g_rst.Close
        g_rst.Open "select * from 出货单 where 出货单编号='" & Text2.Text & "'"
        If g_rst.EOF Then Beep: MsgBox "该出货单不存在!": Exit Sub
        Text1.Text = g_rst!销售性质 & ""
        Text9.Text = g_rst!购货单位 & ""
        DTPicker1.Value = Format(g_rst!出货时间 & "", "yyyy-MM-dd")
                adoCHD.RecordSource = "select * from 出货单 where 出货单编号='" & Text2 & "'"
                adoCHD.Refresh
    End If
Exit Sub
eH:
    MsgBox em & vbNewLine & "错误号:1705" & vbNewLine & "错误描述:" & Err.Description

End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
On Error GoTo eH
    If KeyAscii = 13 Then
        adoHP.RecordSource = "select * from 货品资料 where 货品代码='" & Text3 & "'"
        adoHP.Refresh

        If adoHP.Recordset.EOF Then
            MsgBox "您输入的货品资料不存在!", vbInformation + vbOKOnly, Me.Caption
        Else
            If Text1.Text = "零售" Then
                Text7.Text = adoHP.Recordset!销售定价
            ElseIf Text1.Text = "调货" Then
                Text7.Text = adoHP.Recordset!调货定价
            ElseIf Text1.Text = "批发" Then
                Text7.Text = adoHP.Recordset!批发定价
            End If
            
            If g_rst.State = 1 Then g_rst.Close
            g_rst.Open "select 库存数量 as c from 货品库存 where 货品代码='" & Text3.Text & "'"
            Text12.Text = CStr(g_rst!c)
            Text6.SetFocus
        End If
    End If
Exit Sub
eH:
    MsgBox em & vbNewLine & "错误号:1702" & vbNewLine & "错误描述:" & Err.Description

End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
On Error GoTo eH
    If KeyAscii = 13 Then
        If IsNumeric(Text6) = True Then
            If Val(Text6.Text) > Val(Text12.Text) Then
                Toolbar1.Buttons(10).Visible = False
                MsgBox "库存数量不足!"
            Else
                Toolbar1.Buttons(10).Visible = True
                Text8 = CStr(CLng(Text6) * CLng(Text7))
            End If
        Else
            MsgBox "请输入数字!", vbInformation + vbOKOnly, Me.Caption
        End If
    End If
Exit Sub
eH:
    MsgBox em & vbNewLine & "错误号:1703" & vbNewLine & "错误描述:" & Err.Description

End Sub

Private Sub Text6_Validate(Cancel As Boolean)
        If Text6 = "" Then Exit Sub
        If IsNumeric(Text6) = True Then
            Text8 = CStr(CLng(Text6) * CLng(Text7))
        Else
            MsgBox "请输入数字!", vbInformation + vbOKOnly, Me.Caption
        End If
End Sub

Private Sub Text7_Change()
    Text8 = CStr(Val(Text6) * Val(Text7))
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error GoTo eH
    Select Case Button.Caption
        Case "打印出货单"
            If drOut.Visible = True Then Unload drOut
            If DE.rsOut_分组.State = 1 Then DE.rsOut_分组.Close
            DE.rsOut_分组.Filter = "出货单编号='" & Text2.Text & "'"
            DE.rsOut_分组.Open
            
            drOut.Show
        Case "新建出货单"
            Text1 = ""
            Text2 = ""
            Text9 = ""
            Text10 = ""
            DTPicker1.Value = Date
        
            g_SQL = "select max(出货单编号) as m from 出货单"
            If g_rst.State = 1 Then g_rst.Close
            g_rst.Open g_SQL
             If IsNull(g_rst!m) Then
                Text2 = Format(Date, "yyyy-MM") & "-0001"
            Else
                If Format(Date, "yyyy-MM") <> Mid(g_rst!m, 1, 7) Then
                    Text2 = Format(Date, "yyyy-MM") & "-0001"
                Else
                    Text2 = Format(Date, "yyyy-MM-") & Format(Val(Mid(g_rst!m, 9, 4)) + 1, "0000")
                End If
            End If
            
            adoHP.RecordSource = "select * from 出货单 where 0=9"
            adoCHD.RecordSource = "select * from 出货单 where 0=9"
            adoHP.Refresh
            adoCHD.Refresh
            
            Toolbar1.Buttons(3).Enabled = True
            Toolbar1.Buttons(4).Enabled = True
            Toolbar1.Buttons(2).Enabled = False
        Case "出货完成"
            Toolbar1.Buttons(6).Enabled = True
            Toolbar1.Buttons(2).Enabled = True
            Toolbar1.Buttons(3).Enabled = False
            Toolbar1.Buttons(4).Enabled = False
            Toolbar1.Buttons(5).Enabled = False
            
            If g_rst.State = 1 Then g_rst.Close
            g_SQL = "select sum(小计) as t from 出货单 where 出货单编号='" & Text2 & "'"
            g_rst.Open g_SQL
            MsgBox "出货完成!"
            Text10 = CStr(g_rst!t & "")
        Case "加入货品"
            eButton (False)
            Frame1.Enabled = True
            Toolbar1.Buttons(2).Enabled = False
            
        Case "删除货品"
            If DG.Text = "" Then Exit Sub
            adoCHD.Recordset.Delete
            adoCHD.Recordset.Update
            MsgBox "删除成功!"
            adoCHD.Refresh
            
        Case "退出"
            Unload Me
        Case "确定"
            Toolbar1.Buttons(5).Enabled = True
            Set DG.DataSource = Nothing
            adoCHD.Recordset.AddNew
            
            adoCHD.Recordset!出货单编号 = Text2.Text
            adoCHD.Recordset!销售性质 = Text1.Text
            adoCHD.Recordset!购货单位 = Text9.Text
            adoCHD.Recordset!出货时间 = DTPicker1.Value
            adoCHD.Recordset!实售价 = Val(Text7.Text)
            adoCHD.Recordset!小计 = Val(Text8.Text)
            adoCHD.Recordset!货品代码 = Text3.Text
            adoCHD.Recordset!数量 = Val(Text6.Text)

            g_cmd.CommandText = "update 货品库存 set 库存数量=库存数量-" & Val(Text6.Text) & " where 货品代码='" & Text3.Text & "'"
            g_cmd.Execute
            
            eButton (True)
            adoCHD.Recordset.Update
            adoCHD.Refresh
            adoCHD.RecordSource = "select * from 出货单 where 出货单编号='" & Text2 & "'"
            adoCHD.Refresh
            adoHP.RecordSource = "select * from 出货单 where 0=9"
            Text8 = ""
            Text6 = ""
            Text3 = ""
            adoHP.Refresh
            Frame1.Enabled = False
            Set DG.DataSource = adoCHD
        Case "取消"
            eButton (True)
            Frame1.Enabled = False
    End Select
Exit Sub
eH:
    MsgBox em & vbNewLine & "错误号:1704" & vbNewLine & "错误描述:" & Err.Description

End Sub

Private Sub eButton(b As Boolean)
    'Toolbar1.Buttons(2).Enabled = b
    Toolbar1.Buttons(3).Enabled = b
    Toolbar1.Buttons(4).Enabled = b
    Toolbar1.Buttons(5).Enabled = b
    'Toolbar1.Buttons(6).Enabled = b
    Toolbar1.Buttons(8).Enabled = b
    Toolbar1.Buttons(10).Visible = Not b
    Toolbar1.Buttons(11).Visible = Not b
End Sub

⌨️ 快捷键说明

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