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

📄 frmoutin.frm

📁 vb写得进销存
💻 FRM
📖 第 1 页 / 共 4 页
字号:
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "新建退货单"
            ImageIndex      =   11
         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      =   10
         EndProperty
         BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "退出"
            ImageIndex      =   9
         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 Label1 
      AutoSize        =   -1  'True
      Caption         =   "操作员"
      Height          =   180
      Index           =   14
      Left            =   4605
      TabIndex        =   31
      Top             =   1815
      Width           =   540
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "退货事由"
      Height          =   180
      Index           =   13
      Left            =   405
      TabIndex        =   30
      Top             =   2190
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "退货单编号"
      Height          =   180
      Index           =   12
      Left            =   375
      TabIndex        =   28
      Top             =   1005
      Width           =   900
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "出货单编号"
      Height          =   180
      Index           =   0
      Left            =   375
      TabIndex        =   27
      Top             =   1380
      Width           =   900
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "负责人"
      Height          =   180
      Index           =   1
      Left            =   405
      TabIndex        =   26
      Top             =   1800
      Width           =   540
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "退货时间"
      Height          =   180
      Index           =   2
      Left            =   4500
      TabIndex        =   25
      Top             =   1425
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "退货人"
      Height          =   180
      Index           =   9
      Left            =   4515
      TabIndex        =   24
      Top             =   1005
      Width           =   540
   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        =   23
      Top             =   5940
      Width           =   4935
   End
End
Attribute VB_Name = "frmOutIn"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'19

Private Sub Form_Load()
On Error GoTo eH
    If g_rst.State = 1 Then g_rst.Close
    Combo2.Clear: Combo1.Clear
    g_rst.Open "select 人员姓名 from 工作人员"
    While Not g_rst.EOF
        Combo2.AddItem g_rst!人员姓名
        Combo1.AddItem g_rst!人员姓名
        g_rst.MoveNext
    Wend

    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

    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

    Adodc1.ConnectionString = g_cnnStr
    Adodc1.RecordSource = "select * from 出货单,货品资料 where 出货单.货品代码=货品资料.货品代码 and 0=9"
    Adodc1.Refresh
    
    Toolbar1.Buttons(3).Enabled = False
    Toolbar1.Buttons(4).Enabled = False
    Toolbar1.Buttons(5).Enabled = False
    Toolbar1.Buttons(6).Enabled = False
    Frame1.Enabled = False
Exit Sub
eH:
    MsgBox em & vbNewLine & "错误号:1901" & vbNewLine & "错误描述:" & Err.Description

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
On Error GoTo eH
    If KeyAscii = 13 Then
        Adodc1.RecordSource = "select * from 出货单,货品资料 where 出货单.货品代码=货品资料.货品代码 and 出货单编号='" & Text2.Text & "'"
        Adodc1.Refresh
        If Adodc1.Recordset.EOF Then
            MsgBox "您输入的出货单号不存在,请重新输入.", vbOKOnly + vbExclamation
        End If
    End If
Exit Sub
eH:
    MsgBox em & vbNewLine & "错误号:1902" & vbNewLine & "错误描述:" & Err.Description

End Sub

Private Sub Text3_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 & "' and 货品代码='" & Text3.Text & "'"
        If g_rst.EOF Then
            MsgBox "该出货单中没有此货品!", vbExclamation + vbOKOnly
            Exit Sub
        End If
    
        adoHP.RecordSource = "select * from 货品资料 where 货品代码='" & Text3 & "'"
        adoHP.Refresh

        If adoHP.Recordset.EOF Then
            MsgBox "您输入的货品资料不存在!", vbInformation + vbOKOnly, Me.Caption
        Else
               
            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 & "错误号:1903" & vbNewLine & "错误描述:" & Err.Description

End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
On Error GoTo eH
    Dim c As Long
    If KeyAscii = 13 Then
        If IsNumeric(Text6) = True Then
            If g_rst.State = 1 Then g_rst.Close
            g_rst.Open "select 数量 as c from 出货单 where 出货单编号='" & Text2.Text & "' and 货品代码='" & Text3.Text & "'"
            c = g_rst!c
            If c < Val(Text6.Text) Then
                MsgBox "输入的数量大于出货单上记载的数量,请重新输入!", vbExclamation + vbOKOnly, Me.Caption
                Exit Sub
            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 & "错误号:1904" & 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 Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error GoTo eH
    Select Case Button.Caption
        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
                Text13 = "1"
            Else
                Text13 = CStr(CLng(g_rst!m) + 1)
            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 退货单号=" & Val(Text13)
            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
            
            g_cmd.CommandText = "update 货品库存 set 库存数量=库存数量-" & Val(Text6) & " where 货品代码='" & Text3 & "'"
            g_cmd.Execute
            
            adoCHD.Recordset.AddNew
            adoCHD.Recordset!出货单号 = Val(Text2.Text)
            adoCHD.Recordset!退货单号 = Val(Text13.Text)
            adoCHD.Recordset!货品代码 = Text3.Text
            adoCHD.Recordset!退货事由 = Text1.Text
            adoCHD.Recordset!退货数量 = Val(Text6.Text)
            adoCHD.Recordset!退货人 = Text9.Text
            adoCHD.Recordset!退货时间 = DTPicker1.Value
            adoCHD.Recordset!负责人 = Combo1.Text
            adoCHD.Recordset!操作员 = Combo2.Text
            adoCHD.Recordset!小计 = Val(Text8.Text)

            g_cmd.CommandText = "update 货品库存 set 库存数量=库存数量-" & Val(Text6.Text) & " where 货品代码='" & Text3.Text & "'"
            g_cmd.Execute
            g_cmd.CommandText = "update 出货单 set 数量=数量-" & Val(Text6.Text) & ",小计=小计-" & Val(Text8.Text) & " where 货品代码='" & Text3.Text & "' and 出货单编号=" & Text2
            g_cmd.Execute
            eButton (True)
            adoCHD.Recordset.Update
            adoCHD.Refresh
            adoCHD.RecordSource = "select * from 退货单 where 退货单号=" & Val(Text13)
            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
        Case "打印退货单"
            If drOutin.Visible = True Then Unload drOutin
            If DE.rsOutIn_分组.State = 1 Then DE.rsOutIn_分组.Close
            DE.rsOutIn_分组.Filter = "退货单号=" & Text13.Text
            DE.rsOutIn_分组.Open
            drOutin.Show 1
    End Select
Exit Sub
eH:
    MsgBox em & vbNewLine & "错误号:1905" & 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 + -