www.pudn.com > vb-sql-server.rar > frmInquireCK2.frm, change:2003-11-29,size:10075b


VERSION 5.00 
Begin VB.Form frmInquireCK2  
   BorderStyle     =   3  'Fixed Dialog 
   Caption         =   "进货信息查询——按仓库" 
   ClientHeight    =   2580 
   ClientLeft      =   48 
   ClientTop       =   336 
   ClientWidth     =   5604 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   2580 
   ScaleWidth      =   5604 
   ShowInTaskbar   =   0   'False 
   StartUpPosition =   1  'CenterOwner 
   Begin VB.CheckBox chkDate  
      Caption         =   "按时间:" 
      Height          =   252 
      Left            =   120 
      TabIndex        =   19 
      Top             =   720 
      Width           =   1095 
   End 
   Begin VB.ComboBox Combo1  
      Height          =   288 
      Index           =   0 
      Left            =   1440 
      Style           =   2  'Dropdown List 
      TabIndex        =   10 
      Top             =   120 
      Width           =   3852 
   End 
   Begin VB.Frame Frame1  
      Height          =   1212 
      Index           =   0 
      Left            =   1320 
      TabIndex        =   4 
      Top             =   600 
      Width           =   3972 
      Begin VB.ComboBox cboDay  
         Height          =   288 
         Index           =   1 
         Left            =   3048 
         Style           =   2  'Dropdown List 
         TabIndex        =   15 
         Top             =   720 
         Width           =   612 
      End 
      Begin VB.ComboBox cboMonth  
         Height          =   288 
         Index           =   1 
         Left            =   2136 
         Style           =   2  'Dropdown List 
         TabIndex        =   14 
         Top             =   720 
         Width           =   645 
      End 
      Begin VB.ComboBox cboYear  
         Height          =   288 
         Index           =   1 
         Left            =   960 
         Style           =   2  'Dropdown List 
         TabIndex        =   13 
         Top             =   720 
         Width           =   765 
      End 
      Begin VB.ComboBox cboDay  
         Height          =   288 
         Index           =   0 
         Left            =   3000 
         Style           =   2  'Dropdown List 
         TabIndex        =   8 
         Top             =   240 
         Width           =   612 
      End 
      Begin VB.ComboBox cboMonth  
         Height          =   288 
         Index           =   0 
         Left            =   2088 
         Style           =   2  'Dropdown List 
         TabIndex        =   1 
         Top             =   240 
         Width           =   645 
      End 
      Begin VB.ComboBox cboYear  
         Height          =   288 
         Index           =   0 
         Left            =   912 
         Style           =   2  'Dropdown List 
         TabIndex        =   0 
         Top             =   240 
         Width           =   765 
      End 
      Begin VB.Label Label1  
         Caption         =   "日" 
         Height          =   216 
         Index           =   0 
         Left            =   3720 
         TabIndex        =   18 
         Top             =   720 
         Width           =   240 
      End 
      Begin VB.Label Label1  
         Caption         =   "年" 
         Height          =   216 
         Index           =   3 
         Left            =   1800 
         TabIndex        =   17 
         Top             =   720 
         Width           =   240 
      End 
      Begin VB.Label Label1  
         Caption         =   "月" 
         Height          =   216 
         Index           =   4 
         Left            =   2808 
         TabIndex        =   16 
         Top             =   720 
         Width           =   240 
      End 
      Begin VB.Label lblitem  
         Caption         =   "终止时间:" 
         Height          =   252 
         Index           =   3 
         Left            =   240 
         TabIndex        =   12 
         Top             =   720 
         Width           =   1092 
      End 
      Begin VB.Label lblitem  
         Caption         =   "起始时间:" 
         Height          =   252 
         Index           =   1 
         Left            =   240 
         TabIndex        =   11 
         Top             =   240 
         Width           =   1092 
      End 
      Begin VB.Label Label1  
         Caption         =   "日" 
         Height          =   216 
         Index           =   7 
         Left            =   3720 
         TabIndex        =   7 
         Top             =   240 
         Width           =   240 
      End 
      Begin VB.Label Label1  
         Caption         =   "年" 
         Height          =   216 
         Index           =   1 
         Left            =   1752 
         TabIndex        =   6 
         Top             =   240 
         Width           =   240 
      End 
      Begin VB.Label Label1  
         Caption         =   "月" 
         Height          =   216 
         Index           =   2 
         Left            =   2760 
         TabIndex        =   5 
         Top             =   240 
         Width           =   240 
      End 
   End 
   Begin VB.CommandButton cmdOk  
      Caption         =   "确定 (&O)" 
      Default         =   -1  'True 
      Height          =   375 
      Left            =   1680 
      TabIndex        =   2 
      Top             =   2040 
      Width           =   1215 
   End 
   Begin VB.CommandButton cmdExit  
      Caption         =   "取消 (&X)" 
      Height          =   375 
      Left            =   3120 
      TabIndex        =   3 
      Top             =   2040 
      Width           =   1215 
   End 
   Begin VB.Label lblitem  
      Caption         =   "仓库名称:" 
      Height          =   255 
      Index           =   2 
      Left            =   240 
      TabIndex        =   9 
      Top             =   120 
      Width           =   975 
   End 
End 
Attribute VB_Name = "frmInquireCK2" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
'用于传递查询块 
 
 
 
 
Private Sub cmdExit_Click() 
    Me.Hide 
End Sub 
 
Private Sub cmdOK_Click() 
 
    Dim dBeginDate As String 
    Dim dEndDate As String 
    Dim sQSql As String 
    Dim sQSql1 As String 
    Dim sQSql2 As String 
     
     
    'sQSql = "select inh.in_date,inh.inh_no,dm_ck.dm,dm_ck.mc,dm_wz.dm,dm_wz.mc,inh.qihao,inh.sl,inh.in_danj,inh.i_zk,inh.i_zke,inh.ywman,dm_gf.dm,dm_gf.mc,inh.jsfk,inh.jz,inh.yf,inh.bz from inh inner join dm_gf on inh.gfdm = dm_gf.dm inner join dm_ck on inh.ckdm = dm_ck.dm inner join dm_wz on inh.wzdm = dm_wz.dm where dm_ck.mc = '" & Trim(Combo1(0)) & "'" 
    sQSql1 = "select inh.in_date,inh.inh_no,dm_ck.dm,dm_ck.mc,dm_wz.dm,dm_wz.mc,inh.sl,inh.in_danj,inh.i_zk,inh.i_zke,inh.ywman,dm_gf.dm,dm_gf.mc,inh.jsfk,inh.jz,inh.yf,inh.bz from inh inner join dm_gf on inh.gfdm = dm_gf.dm inner join dm_ck on inh.ckdm = dm_ck.dm inner join dm_wz on inh.wzdm = dm_wz.dm where inh.s_w = '0' and dm_ck.dm = '" & Trim(Combo1(0).ItemData(Combo1(0).ListIndex)) & "'" 
    sQSql2 = "union select inh.in_date,inh.inh_no,dm_ck.dm,dm_ck.mc,dm_service.dm,dm_service.mc,inh.sl,inh.in_danj,inh.i_zk,inh.i_zke,inh.ywman,dm_gf.dm,dm_gf.mc,inh.jsfk,inh.jz,inh.yf,inh.bz from inh inner join dm_gf on inh.gfdm = dm_gf.dm inner join dm_ck on inh.ckdm = dm_ck.dm inner join dm_service on inh.wzdm = dm_service.dm where inh.s_w = '1' and dm_ck.dm = '" & Trim(Combo1(0).ItemData(Combo1(0).ListIndex)) & "'" 
 
    If chkDate.Value = vbChecked Then 
        dBeginDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-" & cboDay(0)), "yyyy-mm-dd") 
        dEndDate = Format(CDate(cboYear(1) & "-" & cboMonth(1) & "-" & cboDay(1)), "yyyy-mm-dd") 
         
        sQSql1 = sQSql1 & " and inh.in_date >= '" & dBeginDate & " '" 
        sQSql1 = sQSql1 & " and inh.in_date <= '" & dEndDate & " '" 
         
        sQSql2 = sQSql2 & " and inh.in_date >= '" & dBeginDate & " '" 
        sQSql2 = sQSql2 & " and inh.in_date <= '" & dEndDate & " '" 
         
    End If 
     
    sQSql = sQSql1 & sQSql2 
     
    If Trim(sQSql) = "" Then 
        MsgBox "请设置查询条件!", vbOKOnly + vbExclamation, "警告" 
        Exit Sub 
    Else 
        frmInquireCK.txtSQL = sQSql 
         
        Me.Hide 
        frmInquireCK.Show 0 
    End If 
     
End Sub 
 
Private Sub Form_Load() 
     
     
    Dim i As Integer 
    Dim j As Integer 
    Dim sSql As String 
    Dim txtSQL As String 
    Dim MsgText As String 
    Dim mrc As ADODB.Recordset 
     
    txtSQL = "select distinct dm_ck.mc,dm_ck.dm  from inh inner join dm_ck on inh.ckdm = dm_ck.dm" 
    Set mrc = ExecuteSQL(txtSQL, MsgText) 
     
    If Not mrc.EOF Then 
        With mrc 
            Do While Not .EOF 
                Combo1(0).AddItem .Fields(0) 
                Combo1(0).ItemData(Combo1(0).NewIndex) = .Fields(1) 
                .MoveNext 
            Loop 
        End With 
         
        Combo1(0).ListIndex = 0 
    Else 
        cmdOk.Enabled = False 
    End If 
     
    mrc.Close 
     
   
    txtSQL = "select distinct datepart(yy,in_date) from inh" 
    Set mrc = ExecuteSQL(txtSQL, MsgText) 
    If mrc.EOF = False Then 
        With mrc 
            Do While Not .EOF 
                cboYear(0).AddItem .Fields(0) 
                cboYear(1).AddItem .Fields(0) 
                .MoveNext 
            Loop 
        End With 
         
        cboYear(0).ListIndex = 0 
        cboYear(1).ListIndex = 0 
         
        For j = 1 To 12 
            cboMonth(0).AddItem j 
            cboMonth(1).AddItem j 
        Next j 
        cboMonth(0).Text = Month(Now()) 
        cboMonth(1).Text = Month(Now()) 
         
        For j = 1 To 31 
            cboDay(0).AddItem j 
            cboDay(1).AddItem j 
        Next j 
        cboDay(0).Text = Day(Now()) 
        cboDay(1).Text = Day(Now()) 
    Else 
        cmdOk.Enabled = False 
    End If 
    mrc.Close 
End Sub