www.pudn.com > vb-sql-server.rar > frmZC1.frm, change:2003-12-06,size:34855b


VERSION 5.00 
Begin VB.Form frmZC1  
   BorderStyle     =   3  'Fixed Dialog 
   Caption         =   "转仓单信息" 
   ClientHeight    =   6732 
   ClientLeft      =   48 
   ClientTop       =   336 
   ClientWidth     =   6132 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   6732 
   ScaleWidth      =   6132 
   ShowInTaskbar   =   0   'False 
   StartUpPosition =   1  'CenterOwner 
   Begin VB.TextBox txtItem  
      Height          =   276 
      Index           =   16 
      Left            =   840 
      MaxLength       =   200 
      MultiLine       =   -1  'True 
      TabIndex        =   34 
      Top             =   6720 
      Visible         =   0   'False 
      Width           =   492 
   End 
   Begin VB.TextBox txtItem  
      Height          =   276 
      Index           =   15 
      Left            =   240 
      MaxLength       =   200 
      MultiLine       =   -1  'True 
      TabIndex        =   33 
      Top             =   6720 
      Visible         =   0   'False 
      Width           =   492 
   End 
   Begin VB.TextBox txtItem  
      Height          =   276 
      Index           =   14 
      Left            =   4320 
      MaxLength       =   200 
      MultiLine       =   -1  'True 
      TabIndex        =   32 
      Top             =   6720 
      Visible         =   0   'False 
      Width           =   492 
   End 
   Begin VB.TextBox txtItem  
      Height          =   276 
      Index           =   13 
      Left            =   4920 
      MaxLength       =   200 
      MultiLine       =   -1  'True 
      TabIndex        =   31 
      Top             =   6720 
      Visible         =   0   'False 
      Width           =   492 
   End 
   Begin VB.TextBox txtItem  
      Height          =   276 
      Index           =   12 
      Left            =   4920 
      MaxLength       =   200 
      MultiLine       =   -1  'True 
      TabIndex        =   30 
      Top             =   6360 
      Visible         =   0   'False 
      Width           =   492 
   End 
   Begin VB.TextBox txtItem  
      Height          =   276 
      Index           =   11 
      Left            =   4320 
      MaxLength       =   200 
      MultiLine       =   -1  'True 
      TabIndex        =   29 
      Top             =   6360 
      Visible         =   0   'False 
      Width           =   492 
   End 
   Begin VB.TextBox txtItem  
      Height          =   276 
      Index           =   10 
      Left            =   840 
      MaxLength       =   200 
      MultiLine       =   -1  'True 
      TabIndex        =   28 
      Top             =   6360 
      Visible         =   0   'False 
      Width           =   492 
   End 
   Begin VB.TextBox txtItem  
      Height          =   276 
      Index           =   9 
      Left            =   240 
      MaxLength       =   200 
      MultiLine       =   -1  'True 
      TabIndex        =   27 
      Top             =   6360 
      Visible         =   0   'False 
      Width           =   492 
   End 
   Begin VB.Frame Frame1  
      Caption         =   "其它信息:" 
      Height          =   1692 
      Index           =   3 
      Left            =   120 
      TabIndex        =   21 
      Top             =   4200 
      Width           =   5895 
      Begin VB.TextBox txtItem  
         Enabled         =   0   'False 
         Height          =   1320 
         Index           =   7 
         Left            =   120 
         MaxLength       =   200 
         MultiLine       =   -1  'True 
         ScrollBars      =   2  'Vertical 
         TabIndex        =   38 
         Top             =   240 
         Width           =   5652 
      End 
   End 
   Begin VB.Frame Frame1  
      Caption         =   "商品信息:" 
      Height          =   1335 
      Index           =   2 
      Left            =   120 
      TabIndex        =   17 
      Top             =   2760 
      Width           =   5895 
      Begin VB.ComboBox Combo1  
         Height          =   288 
         Index           =   4 
         Left            =   1320 
         Style           =   2  'Dropdown List 
         TabIndex        =   37 
         Top             =   240 
         Width           =   1452 
      End 
      Begin VB.TextBox txtItem  
         Height          =   270 
         Index           =   5 
         Left            =   4080 
         MaxLength       =   20 
         TabIndex        =   35 
         Top             =   600 
         Width           =   1455 
      End 
      Begin VB.TextBox txtItem  
         Height          =   270 
         Index           =   6 
         Left            =   1320 
         MaxLength       =   20 
         TabIndex        =   7 
         Top             =   960 
         Width           =   1455 
      End 
      Begin VB.TextBox txtItem  
         Enabled         =   0   'False 
         Height          =   270 
         Index           =   4 
         Left            =   4080 
         MaxLength       =   20 
         TabIndex        =   6 
         Top             =   240 
         Width           =   1455 
      End 
      Begin VB.ComboBox Combo1  
         Enabled         =   0   'False 
         Height          =   288 
         Index           =   3 
         Left            =   1320 
         Style           =   2  'Dropdown List 
         TabIndex        =   5 
         Top             =   600 
         Width           =   1452 
      End 
      Begin VB.Label Label2  
         Caption         =   "商品类型:" 
         Height          =   252 
         Index           =   11 
         Left            =   240 
         TabIndex        =   36 
         Top             =   240 
         Width           =   1092 
      End 
      Begin VB.Label Label2  
         Caption         =   "总金额:" 
         Height          =   252 
         Index           =   6 
         Left            =   360 
         TabIndex        =   22 
         Top             =   960 
         Width           =   1092 
      End 
      Begin VB.Label Label2  
         Caption         =   "转仓数量:" 
         Height          =   252 
         Index           =   2 
         Left            =   3000 
         TabIndex        =   20 
         Top             =   600 
         Width           =   1092 
      End 
      Begin VB.Label Label2  
         Caption         =   "商品编号:" 
         Height          =   252 
         Index           =   10 
         Left            =   3000 
         TabIndex        =   19 
         Top             =   240 
         Width           =   1092 
      End 
      Begin VB.Label Label2  
         Caption         =   "商品名称:" 
         Height          =   252 
         Index           =   3 
         Left            =   240 
         TabIndex        =   18 
         Top             =   600 
         Width           =   1092 
      End 
   End 
   Begin VB.Frame Frame1  
      Caption         =   "仓库选择:" 
      Height          =   1215 
      Index           =   1 
      Left            =   120 
      TabIndex        =   14 
      Top             =   1440 
      Width           =   5895 
      Begin VB.ComboBox Combo1  
         Height          =   315 
         Index           =   2 
         Left            =   4080 
         Style           =   2  'Dropdown List 
         TabIndex        =   24 
         Top             =   720 
         Width           =   1572 
      End 
      Begin VB.TextBox txtItem  
         Enabled         =   0   'False 
         Height          =   270 
         Index           =   3 
         Left            =   1320 
         MaxLength       =   20 
         TabIndex        =   23 
         Top             =   720 
         Width           =   1455 
      End 
      Begin VB.TextBox txtItem  
         Enabled         =   0   'False 
         Height          =   270 
         Index           =   2 
         Left            =   1320 
         MaxLength       =   20 
         TabIndex        =   3 
         Top             =   360 
         Width           =   1455 
      End 
      Begin VB.ComboBox Combo1  
         Height          =   315 
         Index           =   1 
         Left            =   4080 
         Style           =   2  'Dropdown List 
         TabIndex        =   4 
         Top             =   360 
         Width           =   1572 
      End 
      Begin VB.Label Label2  
         Caption         =   "转入仓库名称:" 
         Height          =   255 
         Index           =   8 
         Left            =   2880 
         TabIndex        =   26 
         Top             =   720 
         Width           =   1335 
      End 
      Begin VB.Label Label2  
         Caption         =   "转入仓库代码:" 
         Height          =   255 
         Index           =   9 
         Left            =   120 
         TabIndex        =   25 
         Top             =   720 
         Width           =   1455 
      End 
      Begin VB.Label Label2  
         Caption         =   "转出仓库名称:" 
         Height          =   255 
         Index           =   7 
         Left            =   2880 
         TabIndex        =   16 
         Top             =   360 
         Width           =   1575 
      End 
      Begin VB.Label Label2  
         Caption         =   "转出仓库代码:" 
         Height          =   255 
         Index           =   4 
         Left            =   120 
         TabIndex        =   15 
         Top             =   360 
         Width           =   1335 
      End 
   End 
   Begin VB.Frame Frame1  
      Caption         =   "转仓单基本信息:" 
      Height          =   1212 
      Index           =   0 
      Left            =   120 
      TabIndex        =   10 
      Top             =   120 
      Width           =   5775 
      Begin VB.TextBox txtItem  
         Height          =   270 
         Index           =   1 
         Left            =   3960 
         MaxLength       =   20 
         TabIndex        =   2 
         Top             =   360 
         Width           =   1572 
      End 
      Begin VB.ComboBox Combo1  
         Height          =   315 
         Index           =   0 
         Left            =   1200 
         Style           =   2  'Dropdown List 
         TabIndex        =   1 
         Top             =   720 
         Width           =   1572 
      End 
      Begin VB.TextBox txtItem  
         Height          =   270 
         Index           =   0 
         Left            =   1200 
         MaxLength       =   20 
         TabIndex        =   0 
         Top             =   360 
         Width           =   1572 
      End 
      Begin VB.Label Label2  
         Caption         =   "转仓单号:" 
         Height          =   255 
         Index           =   5 
         Left            =   240 
         TabIndex        =   13 
         Top             =   360 
         Width           =   1095 
      End 
      Begin VB.Label Label2  
         Caption         =   "订货日期:" 
         Height          =   255 
         Index           =   0 
         Left            =   2880 
         TabIndex        =   12 
         Top             =   360 
         Width           =   975 
      End 
      Begin VB.Label Label2  
         Caption         =   "业务员:" 
         Height          =   255 
         Index           =   1 
         Left            =   240 
         TabIndex        =   11 
         Top             =   720 
         Width           =   1095 
      End 
   End 
   Begin VB.CommandButton cmdExit  
      Caption         =   "返回 (&X)" 
      Height          =   375 
      Left            =   3000 
      TabIndex        =   9 
      Top             =   6240 
      Width           =   1215 
   End 
   Begin VB.CommandButton cmdSave  
      Caption         =   "保存 (&S)" 
      Height          =   375 
      Left            =   1560 
      TabIndex        =   8 
      Top             =   6240 
      Width           =   1215 
   End 
End 
Attribute VB_Name = "frmZC1" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
'是否改动过记录,ture为改过 
Dim mblChange As Boolean 
Dim mrc As ADODB.Recordset 
Public txtSQL As String 
 
Private Sub cmdExit_Click() 
    If mblChange And cmdSave.Enabled Then 
        If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then 
            '保存 
            Call cmdSave_Click 
        End If 
    End If 
    Unload Me 
End Sub 
 
Private Sub cmdSave_Click() 
    Dim intCount As Integer 
    Dim sMeg As String 
    Dim MsgText As String 
     
   
    For intCount = 0 To 4 
        If Trim(txtItem(intCount) & " ") = "" Then 
            Select Case intCount 
                Case 0 
                    sMeg = "转仓单号" 
                Case 1 
                    sMeg = "转仓日期" 
                Case 2 
                    sMeg = "转出仓库代码" 
                Case 3 
                    sMeg = "转入仓库代码" 
                Case 4 
                    sMeg = "商品代码" 
            End Select 
            sMeg = sMeg & "不能为空!" 
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告" 
            txtItem(intCount).SetFocus 
            Exit Sub 
        End If 
    Next intCount 
     
    For intCount = 5 To 6 
        If Trim(txtItem(intCount) & " ") = "" Then 
            Select Case intCount 
                Case 5 
                    sMeg = "商品数量" 
                Case 6 
                    sMeg = "总金额" 
            End Select 
            sMeg = sMeg & "不能为空!" 
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告" 
            txtItem(intCount).SetFocus 
            Exit Sub 
        End If 
    Next intCount 
     
     
    For intCount = 0 To 3 
        If Trim(Combo1(intCount) & " ") = "" Then 
            Select Case intCount 
                Case 0 
                    sMeg = "业务员" 
                Case 1 
                    sMeg = "转出仓库名称" 
                Case 2 
                    sMeg = "转入仓库名称" 
                Case 3 
                    sMeg = "商品名称" 
            End Select 
            sMeg = sMeg & "不能为空!" 
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告" 
            Combo1(intCount).SetFocus 
            Exit Sub 
        End If 
    Next intCount 
    
     
    
    '添加判断是否有相同的ID记录 
    If gintZCmode = 1 Then 
        txtSQL = "select * from zc where zc_no ='" & Trim(txtItem(0)) & "'" 
        Set mrc = ExecuteSQL(txtSQL, MsgText) 
        If mrc.EOF = False Then 
            MsgBox "已经存在此转仓单编号的记录!", vbOKOnly + vbExclamation, "警告" 
            txtItem(0).SetFocus 
            Exit Sub 
        End If 
        mrc.Close 
    End If 
     
    '判断转出仓库是否和转入仓库相同 
    If txtItem(2) = txtItem(3) Then 
        MsgBox "转出仓库和转入仓库相同,请重新选择仓库!", vbOKOnly + vbExclamation, "警告" 
        Combo1(1).SetFocus 
        Exit Sub 
    End If 
         
     '判断转出商品数量是否超过库存 
    If gintZCmode = 1 Then 
        If CDbl(txtItem(6)) > CDbl(txtItem(10)) Then 
            MsgBox "转出商品数量超过库存,请重新选择转出商品数量!", vbOKOnly + vbExclamation, "警告" 
            txtItem(6).SetFocus 
            Exit Sub 
        End If 
    ElseIf gintZCmode = 2 Then 
        If (txtItem(2) = txtItem(11)) And (txtItem(4) = txtItem(13)) And (Trim(Combo1(4).ItemData(Combo1(4).ListIndex) = txtItem(16))) Then 
            If CDbl(txtItem(10)) + CDbl(txtItem(15)) < CDbl(txtItem(6)) Then 
                MsgBox "转出商品数量超过库存,请重新选择转出商品数量!", vbOKOnly + vbExclamation, "警告" 
                txtItem(6).SetFocus 
                Exit Sub 
            End If 
        Else 
            If CDbl(txtItem(6)) > CDbl(txtItem(10)) Then 
                MsgBox "转出商品数量超过库存,请重新选择转出商品数量!", vbOKOnly + vbExclamation, "警告" 
                txtItem(6).SetFocus 
                Exit Sub 
            End If 
        End If 
                 
    End If 
    
     
    '先删除已有记录 
    txtSQL = "delete from zc where zc_no ='" & Trim(txtItem(0)) & "'" 
    Set mrc = ExecuteSQL(txtSQL, MsgText) 
    
     
    '再加入新记录 
    txtSQL = "insert zc values ('" 
     
    For intCount = 0 To 1 
        txtSQL = txtSQL & Trim(txtItem(intCount)) & "','" 
    Next intCount 
     
    txtSQL = txtSQL & Trim(Combo1(0).ItemData(Combo1(0).ListIndex)) & "','" 
     
    For intCount = 2 To 4 
        txtSQL = txtSQL & Trim(txtItem(intCount)) & "','" 
    Next intCount 
     
    txtSQL = txtSQL & Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) & "','" 
     
    For intCount = 5 To 6 
        txtSQL = txtSQL & Trim(txtItem(intCount)) & "','" 
    Next intCount 
     
     
    txtSQL = txtSQL & Trim(txtItem(7)) & "')" 
     
    Set mrc = ExecuteSQL(txtSQL, MsgText) 
         
    If gintZCmode = 1 Then 
     
        '出库商品更新 
        txtSQL = "select sl,total_je from kucun where ckdm = '" & Trim(txtItem(2)) 
        txtSQL = txtSQL & "' and wzdm = '" & Trim(txtItem(4)) 
        txtSQL = txtSQL & "' and s_w = '" & Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) & "'" 
         
 
         
        Set mrc = ExecuteSQL(txtSQL, MsgText) 
         
        If Not mrc.EOF Then 
            mrc.Fields(0) = mrc.Fields(0) - CDbl(txtItem(5)) 
            mrc.Fields(1) = mrc.Fields(1) - CDbl(txtItem(6)) 
            mrc.Update 
        End If 
         
        mrc.Close 
         
        '入库商品更新 
        txtSQL = "select sl,total_je from kucun where ckdm = '" & Trim(txtItem(3)) 
        txtSQL = txtSQL & "' and wzdm = '" & Trim(txtItem(4)) 
        txtSQL = txtSQL & "' and s_w = '" & Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) & "'" 
 
 
         
        Set mrc = ExecuteSQL(txtSQL, MsgText) 
         
        If Not mrc.EOF Then 
            mrc.Fields(0) = mrc.Fields(0) + CDbl(txtItem(5)) 
            mrc.Fields(1) = mrc.Fields(1) + CDbl(txtItem(6)) 
            mrc.Update 
            mrc.Close 
        Else 
            mrc.Close 
             
            txtSQL = "execute kucun_setup '" 
            txtSQL = txtSQL & txtItem(1) & "','" 
            txtSQL = txtSQL & GetRkno() & "','" 
            txtSQL = txtSQL & txtItem(3) & "','" 
            txtSQL = txtSQL & txtItem(4) & "','" 
            txtSQL = txtSQL & txtItem(5) & "','" 
            txtSQL = txtSQL & txtItem(6) & "','" 
            txtSQL = txtSQL & Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) & "'" 
             
            Set mrc = ExecuteSQL(txtSQL, MsgText) 
             
        End If 
         
        MsgBox "添加记录成功!", vbOKOnly + vbExclamation, "添加记录" 
        
         
        txtItem(1) = Format(Now, "yyyy-mm-dd") 
         
        mblChange = False 
         
        Unload frmZC 
        frmZC.txtSQL = "select * from zc" 
        frmZC.Show 
         
    ElseIf gintZCmode = 2 Then 
         
        '出库商品恢复 
        txtSQL = "select sl,total_je from kucun where ckdm = '" & Trim(txtItem(11).Text) 
        txtSQL = txtSQL & "' and wzdm = '" & Trim(txtItem(13).Text) 
        'txtSQL = txtSQL & "' and qihao = '" & Trim(txtItem(5)) & "'" 
        txtSQL = txtSQL & "' and s_w = '" & Trim(txtItem(16)) & "'" 
 
 
         
        Set mrc = ExecuteSQL(txtSQL, MsgText) 
         
        If Not mrc.EOF Then 
            mrc.Fields(0) = mrc.Fields(0) + CDbl(txtItem(14).Text) 
            mrc.Fields(1) = mrc.Fields(1) + CDbl(txtItem(15).Text) 
            mrc.Update 
        End If 
         
        mrc.Close 
 
        '入库商品恢复 
        txtSQL = "select sl,total_je from kucun where ckdm = '" & Trim(txtItem(12)) 
        txtSQL = txtSQL & "' and wzdm = '" & Trim(txtItem(13)) 
        'txtSQL = txtSQL & "' and qihao = '" & Trim(txtItem(5)) & "'" 
        txtSQL = txtSQL & "' and s_w = '" & Trim(txtItem(16)) & "'" 
 
 
         
        Set mrc = ExecuteSQL(txtSQL, MsgText) 
         
        If Not mrc.EOF Then 
            mrc.Fields(0) = mrc.Fields(0) - CDbl(txtItem(14).Text) 
            mrc.Fields(1) = mrc.Fields(1) - CDbl(txtItem(15).Text) 
            mrc.Update 
        End If 
         
        mrc.Close 
         
        '出库商品更新 
        txtSQL = "select sl,total_je from kucun where ckdm = '" & Trim(txtItem(2)) 
        txtSQL = txtSQL & "' and wzdm = '" & Trim(txtItem(4)) 
        'txtSQL = txtSQL & "' and qihao = '" & Trim(txtItem(5)) & "'" 
        txtSQL = txtSQL & "' and s_w = '" & Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) & "'" 
 
         
        Set mrc = ExecuteSQL(txtSQL, MsgText) 
         
        If Not mrc.EOF Then 
            mrc.Fields(0) = mrc.Fields(0) - CDbl(txtItem(5)) 
            mrc.Fields(1) = mrc.Fields(1) - CDbl(txtItem(6)) 
            mrc.Update 
        End If 
         
        mrc.Close 
         
         
        '入库商品更新 
        txtSQL = "select sl,total_je from kucun where ckdm = '" & Trim(txtItem(3)) 
        txtSQL = txtSQL & "' and wzdm = '" & txtItem(4) 
        'txtSQL = txtSQL & "' and qihao = '" & Trim(txtItem(5)) & "'" 
        txtSQL = txtSQL & "' and s_w = '" & Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) & "'" 
 
        Set mrc = ExecuteSQL(txtSQL, MsgText) 
         
        If Not mrc.EOF Then 
            mrc.Fields(0) = mrc.Fields(0) + CDbl(txtItem(5)) 
            mrc.Fields(1) = mrc.Fields(1) + CDbl(txtItem(6)) 
            mrc.Update 
            mrc.Close 
        Else 
            mrc.Close 
             
            
            txtSQL = "execute kucun_setup '" 
            txtSQL = txtSQL & txtItem(1) & "','" 
            txtSQL = txtSQL & GetRkno() & "','" 
            txtSQL = txtSQL & txtItem(3) & "','" 
            txtSQL = txtSQL & txtItem(4) & "','" 
            txtSQL = txtSQL & txtItem(5) & "','" 
            txtSQL = txtSQL & txtItem(6) & "','" 
            txtSQL = txtSQL & Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) & "'" 
             
             
             
            Set mrc = ExecuteSQL(txtSQL, MsgText) 
             
        End If 
         
     
     
        Unload Me 
        Unload frmZC 
         
        frmZC.txtSQL = "select * from zc" 
        frmZC.Show 
    End If 
     
End Sub 
 
Private Sub Combo1_Change(Index As Integer) 
    mblChange = True 
     
     
End Sub 
 
Private Sub Combo1_Click(Index As Integer) 
    Dim mrcc As ADODB.Recordset 
    Dim mrcd As ADODB.Recordset 
    Dim MsgText As String 
     
     
    If Index = 1 Then 
         
            Combo1(3).Clear 
             
            txtItem(2) = Combo1(1).ItemData(Combo1(1).ListIndex) 
         
            
'            txtSQL = "select dm_wz.dm,dm_wz.mc from dm_wz inner join kucun on dm_wz.dm = kucun.wzdm where kucun.sl > '0' and kucun.ckdm = '" & txtItem(2) & "'" 
'            Set mrcc = ExecuteSQL(txtSQL, MsgText) 
             
'            If Not mrcc.EOF Then 
'                Do While Not mrcc.EOF 
'                    Combo1(3).AddItem mrcc.Fields(1) 
'                    Combo1(3).ItemData(Combo1(3).NewIndex) = mrcc.Fields(0) 
'                    mrcc.MoveNext 
'                Loop 
'            End If 
             
'            mrcc.Close 
             
             
             
             
    ElseIf Index = 2 Then 
            txtItem(3) = Combo1(2).ItemData(Combo1(2).ListIndex) 
     
 
    ElseIf Index = 3 Then 
        If Trim(Combo1(4) & " ") = "" Then 
            MsgBox "请先选择商品类型!", vbOKOnly + vbExclamation, "警告" 
            Combo1(4).SetFocus 
            Exit Sub 
        ElseIf Trim(Combo1(1) & "") = "" Then 
            MsgBox "请先选择转出仓库!", vbOKOnly + vbExclamation, "警告" 
            Combo1(1).SetFocus 
            Exit Sub 
        Else 
             
 
        txtItem(4) = Combo1(3).ItemData(Combo1(3).ListIndex) 
         
        If Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) = 0 Then 
            txtSQL = "select kucun.wzdm,danj=(kucun.total_je/kucun.sl),kucun.total_je from kucun inner join dm_wz on kucun.wzdm = dm_wz.dm where kucun.ckdm = '" & Trim(txtItem(2)) & "'" 
            txtSQL = txtSQL & " and kucun.wzdm = '" & Trim(txtItem(4)) & "' and kucun.s_w = '" & Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) & "'" 
        ElseIf Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) = 1 Then 
            txtSQL = "select kucun.wzdm,danj=(kucun.total_je/kucun.sl),kucun.total_je from kucun inner join dm_service on kucun.wzdm = dm_service.dm where kucun.ckdm = '" & Trim(txtItem(2)) & "'" 
            txtSQL = txtSQL & " and kucun.wzdm = '" & Trim(txtItem(4)) & "' and kucun.s_w = '" & Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) & "'" 
        End If 
         
             
             
'            txtSQL = "select kucun.wzdm,kucun.qihao,danj=(kucun.total_je/kucun.sl),kucun.total_je from dm_wz inner join  kucun on dm_wz.dm = kucun.wzdm where dm_wz.mc = '" & Trim(Combo1(Index)) & "' and kucun.ckdm ='" & Trim(txtItem(2)) & "'" 
            Set mrcc = ExecuteSQL(txtSQL, MsgText) 
                         
            If Not mrcc.EOF Then 
                txtItem(4) = mrcc.Fields(0) 
                txtItem(9) = mrcc.Fields(1) 
                txtItem(10) = mrcc.Fields(2) 
            End If 
             
            mrcc.Close 
        End If 
     
    ElseIf Index = 4 Then 
        Combo1(3).Clear 
        Combo1(3).Enabled = True 
         
        If Trim(Combo1(1)) = "" Then 
            MsgBox "请先选择转出仓库!", vbOKOnly + vbExclamation, "警告" 
        Else 
            If Combo1(4).ItemData(Combo1(4).ListIndex) = 0 Then '配件 
                txtSQL = "select dm,mc  from dm_wz " 
                Set mrcc = ExecuteSQL(txtSQL, MsgText) 
                             
                Do While Not mrcc.EOF 
                    Combo1(3).AddItem mrcc.Fields(1) 
                    Combo1(3).ItemData(Combo1(3).NewIndex) = mrcc.Fields(0) 
                    mrcc.MoveNext 
                Loop 
                 
                mrcc.Close 
             
            ElseIf Combo1(4).ItemData(Combo1(4).ListIndex) = 1 Then 
                txtSQL = "select dm_slb.lb,dm_slb.lb1,dm_service.dm from dm_service inner join dm_slb on dm_service.lbdm = dm_slb.lbcode1 " 
                Set mrcc = ExecuteSQL(txtSQL, MsgText) 
                             
                Do While Not mrcc.EOF 
                    Combo1(3).AddItem (Trim(mrcc.Fields(0)) + Trim(mrcc.Fields(1))) 
                    Combo1(3).ItemData(Combo1(3).NewIndex) = mrcc.Fields(2) 
                    mrcc.MoveNext 
                Loop 
                 
                mrcc.Close 
            End If 
        End If 
     
             
    End If 
 
End Sub 
 
Private Sub Form_Load() 
    Dim intCount As Integer 
    Dim MsgText As String 
    Dim i As Integer 
    Dim mrcc As ADODB.Recordset 
     
    For i = 0 To 3 
         Combo1(i).Clear 
    Next i 
   
    Combo1(4).AddItem "手机及配件" 
    Combo1(4).ItemData(Combo1(4).NewIndex) = 0 
    Combo1(4).AddItem "服      务" 
    Combo1(4).ItemData(Combo1(4).NewIndex) = 1 
  
   
   
    If gintZCmode = 1 Then 
        Me.Caption = Me.Caption & "添加" 
        For i = 0 To 7 
            txtItem(i).Text = "" 
        Next i 
         
        For i = 9 To 16 
            txtItem(i).Text = "" 
        Next i 
         
         
        For i = 0 To 3 
            Combo1(i).Clear 
        Next i 
         
         
         
    ElseIf gintZCmode = 2 Then 
        Set mrc = ExecuteSQL(txtSQL, MsgText) 
         
        If mrc.EOF = False Then 
            With mrc 
                For intCount = 0 To 1 
                    txtItem(intCount) = .Fields(intCount) 
                Next intCount 
                 
                txtSQL = "select dm,mc from dm_ywy where dm = '" & Trim(.Fields(2)) & "'" 
                Set mrcc = ExecuteSQL(txtSQL, MsgText) 
                 
                If Not mrcc.EOF Then 
                    Combo1(0).AddItem mrcc.Fields(1) 
                    Combo1(0).ItemData(Combo1(0).NewIndex) = mrcc.Fields(0) 
                    Combo1(0).ListIndex = 0 
                    mrcc.Close 
                End If 
                 
                For intCount = 2 To 4 
                    txtItem(intCount) = .Fields(intCount + 1) 
                Next intCount 
                 
                For intCount = 5 To 7 
                    txtItem(intCount) = .Fields(intCount + 2) 
                Next intCount 
                 
                txtSQL = "select dm,mc from dm_ck where dm = '" & Trim(.Fields(3)) & "'" 
                Set mrcc = ExecuteSQL(txtSQL, MsgText) 
                 
                If Not mrcc.EOF Then 
                    Combo1(1).AddItem mrcc.Fields(1) 
                    Combo1(1).ItemData(Combo1(1).NewIndex) = mrcc.Fields(0) 
                    Combo1(1).ListIndex = 0 
                    mrcc.Close 
                End If 
                 
                txtSQL = "select dm,mc from dm_ck where dm = '" & Trim(.Fields(4)) & "'" 
                Set mrcc = ExecuteSQL(txtSQL, MsgText) 
                 
                If Not mrcc.EOF Then 
                    Combo1(2).AddItem mrcc.Fields(1) 
                    Combo1(2).ItemData(Combo1(2).NewIndex) = mrcc.Fields(0) 
                    Combo1(2).ListIndex = 0 
                    mrcc.Close 
                End If 
                 
                 
                If Trim(.Fields(6)) = 0 Then 
                    Combo1(4).ListIndex = 0 
                     
                     
                    txtSQL = "select dm,mc from dm_wz where dm = '" & Trim(.Fields(5)) & "'" 
                    Set mrcc = ExecuteSQL(txtSQL, MsgText) 
                     
                    If Not mrcc.EOF Then 
                        Combo1(3).AddItem mrcc.Fields(1) 
                        Combo1(3).ItemData(Combo1(3).NewIndex) = mrcc.Fields(0) 
                        Combo1(3).ListIndex = 0 
                        mrcc.Close 
                    End If 
                     
                ElseIf Trim(.Fields(6)) = 1 Then 
                    Combo1(4).ListIndex = 1 
                     
                    txtSQL = "select dm_slb.lb,dm_slb.lb1,dm_service.dm from dm_service inner join dm_slb on dm_service.lbdm = dm_slb.lbcode1 where dm_service.dm = '" & .Fields(5) & "'" 
                    Set mrcc = ExecuteSQL(txtSQL, MsgText) 
                    If Not mrcc.EOF Then 
                        Combo1(2).AddItem Trim(mrcc.Fields(0)) + Trim(mrcc.Fields(1)) 
                        Combo1(2).ItemData(Combo1(2).NewIndex) = mrcc.Fields(2) 
                        Combo1(2).ListIndex = 0 
                        mrcc.Close 
                    End If 
                     
                     
                End If 
                 
                 
                 
                 
                For intCount = 2 To 6 
                    txtItem(intCount + 9) = txtItem(intCount) 
                Next intCount 
                 
'                For intCount = 5 To 6 
'                    txtItem(intCount + 9) = txtItem(intCount) 
'                Next intCount 
                 
                txtItem(16) = Trim(Combo1(4).ItemData(Combo1(4).ListIndex)) 
                 
                 
            End With 
        End If 
         
        Me.Caption = Me.Caption & "修改" 
    End If 
     
     
    txtSQL = "select dm,mc from dm_ywy" 
    Set mrcc = ExecuteSQL(txtSQL, MsgText) 
     
    If Not mrcc.EOF Then 
        Do While Not mrcc.EOF 
            If Trim(mrcc.Fields(1)) <> Trim(Combo1(0)) Then 
                Combo1(0).AddItem mrcc.Fields(1) 
                Combo1(0).ItemData(Combo1(0).NewIndex) = mrcc.Fields(0) 
            End If 
            mrcc.MoveNext 
        Loop 
    End If 
     
    mrcc.Close 
     
    txtItem(1) = Format(Now, "yyyy-mm-dd") 
    txtItem(1).Enabled = False 
     
    txtSQL = "select dm,mc from dm_ck" 
    Set mrcc = ExecuteSQL(txtSQL, MsgText) 
     
    If Not mrcc.EOF Then 
        Do While Not mrcc.EOF 
            If Trim(mrcc.Fields(1)) <> Trim(Combo1(1)) Then 
                Combo1(1).AddItem mrcc.Fields(1) 
                Combo1(1).ItemData(Combo1(1).NewIndex) = mrcc.Fields(0) 
            End If 
            If Trim(mrcc.Fields(1)) <> Trim(Combo1(2)) Then 
                Combo1(2).AddItem mrcc.Fields(1) 
                Combo1(2).ItemData(Combo1(2).NewIndex) = mrcc.Fields(0) 
            End If 
            mrcc.MoveNext 
        Loop 
    End If 
     
    mrcc.Close 
     
     
    mblChange = False 
End Sub 
 
Private Sub Form_Unload(Cancel As Integer) 
    gintZCmode = 0 
End Sub 
 
 
 
Private Sub txtItem_Change(Index As Integer) 
    Dim intCount As Integer 
    '用于计算工资 
    Dim dblTotal As Double 
     
   
    '有变化设置gblchange 
    mblChange = True 
     
    If Not Trim(Combo1(3)) = "" Then 
     
        If (Index = 5) Then 
            If Trim(txtItem(9)) <> "" Then 
                dblTotal = 0 
                 
                dblTotal = CDbl(txtItem(5)) * CDbl(txtItem(9)) 
                       
                txtItem(6) = Format(dblTotal, "#0.00") 
            Else 
                MsgBox "指定仓库中没有指定商品,请重新选择", vbOKCancel + vbExclamation, "警告" 
                Combo1(1).SetFocus 
            End If 
             
        End If 
    End If 
             
    Exit Sub 
End Sub 
 
Private Sub txtItem_GotFocus(Index As Integer) 
    txtItem(Index).SelStart = 0 
    txtItem(Index).SelLength = Len(txtItem(Index)) 
End Sub 
 
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) 
    EnterToTab KeyCode 
End Sub 
 
Private Sub txtItem_KeyPress(Index As Integer, KeyAscii As Integer) 
     
    If Index >= 6 And Index <= 7 Then 
        'MsgBox KeyCode 
        '对键入字符进行控制 
        'txtQuantity(Index).Locked = False 
        '小数点只允许输入一次 
        If KeyAscii = 190 Then 
            If InStr(Trim(txtItem(Index)), ".") = 0 Then 
                If Len(Trim(txtItem(Index))) > 0 Then 
                    txtItem(Index).Locked = False 
                Else 
                    txtItem(Index).Locked = True 
                End If 
            Else 
                txtItem(Index).Locked = True 
            End If 
            Exit Sub 
        End If 
        '非数字不能输入 
        If KeyAscii > 57 Or KeyAscii < 48 Then 
            txtItem(Index).Locked = True 
        Else 
            txtItem(Index).Locked = False 
        End If 
        '允许Backspace 
        If KeyAscii = 8 Then 
            txtItem(Index).Locked = False 
        End If 
        'Delete键 
        If KeyAscii = 46 Then 
            txtItem(Index).Locked = False 
        End If 
    End If 
     
     
End Sub