www.pudn.com > netserver.zip > frmBiaoBiao.frm


VERSION 5.00 
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX" 
Begin VB.Form frmBiaoBiao  
   BorderStyle     =   1  'Fixed Single 
   Caption         =   "生成报表" 
   ClientHeight    =   2715 
   ClientLeft      =   45 
   ClientTop       =   330 
   ClientWidth     =   5925 
   Icon            =   "frmBiaoBiao.frx":0000 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   2715 
   ScaleWidth      =   5925 
   StartUpPosition =   1  '所有者中心 
   Begin VB.Data Data1  
      Caption         =   "Data1" 
      Connect         =   "Access 2000;" 
      DatabaseName    =   "" 
      DefaultCursorType=   0  '缺省游标 
      DefaultType     =   2  '使用 ODBC 
      Exclusive       =   0   'False 
      Height          =   285 
      Left            =   840 
      Options         =   0 
      ReadOnly        =   0   'False 
      RecordsetType   =   1  'Dynaset 
      RecordSource    =   "" 
      Top             =   2040 
      Visible         =   0   'False 
      Width           =   1140 
   End 
   Begin VB.ComboBox Combo2  
      Height          =   300 
      ItemData        =   "frmBiaoBiao.frx":0442 
      Left            =   1800 
      List            =   "frmBiaoBiao.frx":0449 
      Style           =   2  'Dropdown List 
      TabIndex        =   9 
      Top             =   1440 
      Width           =   3735 
   End 
   Begin MSComCtl2.DTPicker DTP2  
      Height          =   375 
      Left            =   3840 
      TabIndex        =   7 
      Top             =   840 
      Width           =   1695 
      _ExtentX        =   2990 
      _ExtentY        =   661 
      _Version        =   393216 
      Format          =   23789568 
      CurrentDate     =   36936 
   End 
   Begin MSComCtl2.DTPicker DTP1  
      Height          =   375 
      Left            =   1800 
      TabIndex        =   5 
      Top             =   840 
      Width           =   1695 
      _ExtentX        =   2990 
      _ExtentY        =   661 
      _Version        =   393216 
      Format          =   23789568 
      CurrentDate     =   36936 
   End 
   Begin VB.ComboBox Combo1  
      Height          =   300 
      ItemData        =   "frmBiaoBiao.frx":0459 
      Left            =   1800 
      List            =   "frmBiaoBiao.frx":0466 
      Locked          =   -1  'True 
      Style           =   2  'Dropdown List 
      TabIndex        =   2 
      Top             =   360 
      Width           =   3735 
   End 
   Begin VB.CommandButton Command2  
      Cancel          =   -1  'True 
      Caption         =   "取消" 
      Height          =   375 
      Left            =   4080 
      TabIndex        =   1 
      Top             =   2040 
      Width           =   1215 
   End 
   Begin VB.CommandButton Command1  
      Caption         =   "生成报表" 
      Default         =   -1  'True 
      Height          =   375 
      Left            =   2520 
      TabIndex        =   0 
      Top             =   2040 
      Width           =   1215 
   End 
   Begin VB.Label Label4  
      Caption         =   "选择计算机:" 
      Height          =   255 
      Left            =   240 
      TabIndex        =   8 
      Top             =   1440 
      Width           =   1455 
   End 
   Begin VB.Label Label3  
      Caption         =   "到" 
      Height          =   255 
      Left            =   3600 
      TabIndex        =   6 
      Top             =   960 
      Width           =   375 
   End 
   Begin VB.Label Label2  
      Caption         =   "报表日期:" 
      Height          =   255 
      Left            =   240 
      TabIndex        =   4 
      Top             =   960 
      Width           =   1575 
   End 
   Begin VB.Label Label1  
      Caption         =   "报表类型:" 
      Height          =   255 
      Left            =   240 
      TabIndex        =   3 
      Top             =   360 
      Width           =   1575 
   End 
End 
Attribute VB_Name = "frmBiaoBiao" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Private Sub Command1_Click() 
'生成报表 
On Error Resume Next 
Me.Visible = False 
frmJinDu.Show , frmMain 
DoEvents 
Screen.MousePointer = 11 
'frmPrinter.RTBox.Text = "" 
 
'frmPrinter.RTBox.SelFontSize = 22 
'frmPrinter.RTBox.SelBold = True 
'frmPrinter.RTBox.SelAlignment = 2 
'frmPrinter.RTBox.SelText = Combo1.Text & "报表" + vbCrLf 
 
'frmPrinter.RTBox.SelFontSize = 9 
'frmPrinter.RTBox.SelItalic = True 
'If DTP1.Year = DTP2.Year And DTP1.Month = DTP2.Month And DTP1.Day = DTP2.Day Then 
'frmPrinter.RTBox.SelText = Format(DTP1.Value, "long date") + vbCrLf 
'Else 
'frmPrinter.RTBox.SelText = "从" + Format(DTP1.Value, "long date") + "到" + Format(DTP2.Value, "long date") + vbCrLf 
'End If 
' frmPrinter.RTBox.SelAlignment = 0 
'frmPrinter.RTBox.SelItalic = False 
'frmPrinter.RTBox.SelText = "  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + vbCrLf 
 
Select Case Combo1.Text 
Case "机时收费表" 
  'frmPrinter.RTBox.SelFontSize = 11 
  'frmPrinter.RTBox.SelBold = True 
  'frmPrinter.RTBox.SelText = "  机号    开始时间    结束时间    上机方式  应收金额  实收金额  结帐管理员  上机客户" + vbCrLf 
  'frmPrinter.RTBox.SelBold = False 
  'frmPrinter.RTBox.SelFontSize = 9 
  'frmPrinter.RTBox.SelText = "  ─────────────────────────────────────────────────────────" + vbCrLf 
 Data1.DatabaseName = SystemPath + "dbase.mdb" 
 Data1.Connect = ";pwd=123456" 
 Data1.RecordSource = "select * from sjlszb  where 结束时间>=#" & DTP1.Value & "# and 结束时间<=#" & DTP2.Value & "#" 
 Data1.Refresh 
 Data1.Recordset.MoveLast 
  With Data1.Recordset 
   .MoveFirst 
   Dim zYsh As Double, zSsh As Double 
    
   For i = 0 To .Fields.Count - 1 
     frmPrnBaoBiao.ListView1.ColumnHeaders.Add , , .Fields(i).Name 
   Next i 
   For i = 1 To .RecordCount 
   frmJinDu.ProgressBar1.Value = Int(i * 100 / .RecordCount) 
   DoEvents 
   ' If .Fields("结束时间") > DTP1.Value And .Fields("结束时间") < DTP2.Value And (Combo2.Text = "全部计算机" Or .Fields("机号") = Combo2.ItemData(Combo2.ListIndex)) Then 
     n = n + 1 
     frmPrnBaoBiao.ListView1.ListItems.Add n, , .Fields("ID") 
     'For k = 0 To .RecordCount - 1 
        'frmPrnBaoBiao.ListView1.ListItems.Add i + 1, , .Fields(0) 
         'For j = 1 To .Fields.Count - 1 
         'frmPrnBaoBiao.ListView1.ListItems(n).SubItems(j) = .Fields(j) 
         'Next j 
           frmPrnBaoBiao.ListView1.ColumnHeaders(1).Width = 600 
           frmPrnBaoBiao.ListView1.ColumnHeaders(2).Width = 800 
           frmPrnBaoBiao.ListView1.ColumnHeaders(3).Width = 1600 
           frmPrnBaoBiao.ListView1.ColumnHeaders(4).Width = 1600 
           frmPrnBaoBiao.ListView1.ColumnHeaders(5).Width = 1000 
           frmPrnBaoBiao.ListView1.ColumnHeaders(6).Width = 1000 
           frmPrnBaoBiao.ListView1.ColumnHeaders(7).Width = 1000 
           frmPrnBaoBiao.ListView1.ColumnHeaders(8).Width = 800 
           frmPrnBaoBiao.ListView1.ColumnHeaders(5).Alignment = lvwColumnRight 
           frmPrnBaoBiao.ListView1.ColumnHeaders(6).Alignment = lvwColumnRight 
           frmPrnBaoBiao.ListView1.ColumnHeaders(7).Alignment = lvwColumnRight 
           frmPrnBaoBiao.ListView1.ColumnHeaders(8).Alignment = lvwColumnRight 
          
            
         frmPrnBaoBiao.ListView1.ListItems(n).SubItems(1) = .Fields(1) & "号机" 
         frmPrnBaoBiao.ListView1.ListItems(n).SubItems(2) = Format(.Fields(2), "yy/mm/dd hh:nn") 
         frmPrnBaoBiao.ListView1.ListItems(n).SubItems(3) = Format(.Fields(3), "yy/mm/dd hh:nn") 
             
      If .Fields("上机方式") = "P" Then 
          frmPrnBaoBiao.ListView1.ListItems(n).SubItems(4) = "通宵 " 
      Else 
          frmPrnBaoBiao.ListView1.ListItems(n).SubItems(4) = "正常 " 
      End If 
        frmPrnBaoBiao.ListView1.ListItems(n).SubItems(5) = Format(.Fields(5), "###0.00元") 
        frmPrnBaoBiao.ListView1.ListItems(n).SubItems(6) = Format(.Fields(6), "###0.00元") 
        frmPrnBaoBiao.ListView1.ListItems(n).SubItems(7) = Format(.Fields(7), "0") & "%" 
         For j = 8 To .Fields.Count - 1 
          frmPrnBaoBiao.ListView1.ListItems(n).SubItems(j) = .Fields(j) 
         Next j 
 
 
      
   '   a$ = CStr(.Fields("机号")) & "号机  " 
   '   a$ = Space(10 - Len(a$)) + a$ 
   '   frmPrinter.RTBox.SelText = a$ & Format(.Fields("开始时间"), "  yyyy/mm/dd hh:nn") & _ 
                                  Format(.Fields("结束时间"), "  yyyy/mm/dd hh:nn") 
 
   '   a$ = Format(.Fields("应收款"), "###0.0元") 
   '   b$ = Format(.Fields("实收款"), "###0.0元") 
   '   a$ = Space(13 - Len(a$)) + a$ 
   '   b$ = Space(13 - Len(b$)) + b$ 
   '   e$ = .Fields("结帐人") 
   '   f$ = .Fields("客户姓名") 
   '   e$ = e$ + Space(17 - LenB(StrConv(e$, vbFromUnicode))) 
   ' 
   '   frmPrinter.RTBox.SelText = a$ & b$ & "     " & e$ + f$ + vbCrLf 
      zYsh = zYsh + .Fields("应收款") 
      zSsh = zSsh + .Fields("实收款") 
       
   ' End If 
    .MoveNext 
   Next i 
  ' frmPrinter.RTBox.SelText = "  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + vbCrLf 
  ' frmPrinter.RTBox.SelItalic = True 
  '  frmPrinter.RTBox.SelAlignment = 2 
  '   frmPrinter.RTBox.SelFontSize = 10 
  ' frmPrinter.RTBox.SelText = "   总应收金额:" & Format(zYsh, "###0.0元") & " 总实收金额:" & Format(zSsh, "###0.0元") & "    " & Format(Date, "long date") 
  frmPrnBaoBiao.Text1 = "   总应收金额:" & Format(zYsh, "###0.0元") & " 总实收金额:" & Format(zSsh, "###0.0元") & "    " & Format(Date, "long date") 
  frmPrnBaoBiao.Show 
   
  End With 
Case "商品销售统计表" 
 Dim zShr As Double, zZhc As Double 
  frmPrinter.RTBox.SelFontSize = 12 
  frmPrinter.RTBox.SelBold = True 
  frmPrinter.RTBox.SelText = "    机号    时间       商品编号     商品名称   商品单价   商品数量   总金额" + vbCrLf 
  frmPrinter.RTBox.SelBold = False 
  frmPrinter.RTBox.SelFontSize = 9 
  frmPrinter.RTBox.SelText = "  ─────────────────────────────────────────────────────────" + vbCrLf 
 With frmMain.Data5.Recordset 
    .MoveFirst 
    For i = 1 To .RecordCount 
       frmJinDu.ProgressBar1.Value = Int(i * 100 / .RecordCount) 
       DoEvents 
     
      If .Fields("时间") > DTP1.Value And .Fields("时间") < DTP2.Value And (Combo2.Text = "全部计算机" Or .Fields("机号") = Combo2.ItemData(Combo2.ListIndex)) Then 
           If .Fields("机号") > 0 Then 
             a$ = CStr(.Fields("机号")) + "号机" 
           Else 
             a$ = "零售" 
           End If 
           a$ = Space(10 - Len(a$)) + a$ 
           frmPrinter.RTBox.SelText = a$ + Format(.Fields("时间"), "  yyyy-mm-dd hh:nn") + "       " + .Fields("商品编号") 
           frmMain.Data3.Recordset.MoveFirst 
           For j = 1 To frmMain.Data3.Recordset.RecordCount 
             If frmMain.Data3.Recordset.Fields("商品编号") = .Fields("商品编号") Then 
               b$ = frmMain.Data3.Recordset.Fields("商品名称") 
               cc = frmMain.Data3.Recordset.Fields("零售价格") 
               ee = frmMain.Data3.Recordset.Fields("进货价格") 
             End If 
              
             frmMain.Data3.Recordset.MoveNext 
           Next j 
            b$ = Space(20 - LenB(StrConv(b$, vbFromUnicode))) + b$ 
               
            frmPrinter.RTBox.SelText = b$ + Space(12 - Len(Format(cc, "###0.0元"))) + Format(cc, "###0.0元") 
            frmPrinter.RTBox.SelText = Space(16 - Len(CStr(.Fields("数量")))) + CStr(.Fields("数量")) 
            dd = cc * .Fields("数量") 
            frmPrinter.RTBox.SelText = Space(12 - Len(Format(dd, "###0.0元"))) + Format(dd, "###0.0元") 
            zShr = zShr + dd 
            zZhc = zZhc + ee * .Fields("数量") 
            frmPrinter.RTBox.SelText = vbCrLf 
           
      End If 
      .MoveNext 
    Next i 
      frmPrinter.RTBox.SelText = "  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + vbCrLf 
   frmPrinter.RTBox.SelItalic = True 
    frmPrinter.RTBox.SelAlignment = 2 
     frmPrinter.RTBox.SelFontSize = 10 
   frmPrinter.RTBox.SelText = "   总支出金额:" & Format(zZhc, "###0.0元") & " 总收入金额:" & Format(zShr, "###0.0元") & " 总利润:" & Format(zShr - zZhc, "###0.0元") & "    " & Format(Date, "long date") 
 
 End With 
 frmPrinter.Show 
Case "收入统计表" 
  Dim zJsh As Double, zJshYS As Double, zJshSS As Double, zSPZC As Double, zSPSR As Double 
   
  With frmMain.Data4.Recordset 
   .MoveFirst 
   
   For i = 1 To .RecordCount 
   frmJinDu.ProgressBar1.Value = Int(i * 50 / .RecordCount) 
   DoEvents 
    If .Fields("结束时间") > DTP1.Value And .Fields("结束时间") < DTP2.Value And (Combo2.Text = "全部计算机" Or .Fields("机号") = Combo2.ItemData(Combo2.ListIndex)) Then 
      zJsh = zJsh + DateDiff("n", .Fields("开始时间"), .Fields("结束时间")) 
      zJshYS = zJshYS + .Fields("应收款") 
      zJshSS = zJshSS + .Fields("实收款") 
    End If 
    .MoveNext 
    Next i 
   End With 
   With frmMain.Data5.Recordset 
    .MoveFirst 
    For i = 1 To .RecordCount 
       frmJinDu.ProgressBar1.Value = 50 + Int(i * 50 / .RecordCount) 
       DoEvents 
     
      If .Fields("时间") > DTP1.Value And .Fields("时间") < DTP2.Value And (Combo2.Text = "全部计算机" Or .Fields("机号") = Combo2.ItemData(Combo2.ListIndex)) Then 
             frmMain.Data3.Recordset.MoveFirst 
             For j = 1 To frmMain.Data3.Recordset.RecordCount 
             If frmMain.Data3.Recordset.Fields("商品编号") = .Fields("商品编号") Then 
               zSPZC = zSPZC + frmMain.Data3.Recordset.Fields("进货价格") * .Fields("数量") 
               zSPSR = zSPSR + frmMain.Data3.Recordset.Fields("零售价格") * .Fields("数量") 
             End If 
              
             frmMain.Data3.Recordset.MoveNext 
           Next j 
      End If 
      .MoveNext 
     Next i 
    End With 
    frmPrinter.RTBox.SelFontSize = 12 
    frmPrinter.RTBox.SelText = "      总共上机时间:" & zJsh \ 60 & "小时" & zJsh Mod 60 & "分钟" & vbCrLf 
    frmPrinter.RTBox.SelFontSize = 12 
    frmPrinter.RTBox.SelText = "      总应收金额:  " & Format(zJshYS, "###0.0元") 
    frmPrinter.RTBox.SelText = vbCrLf + "      总实收金额  : " & Format(zJshSS, "###0.0元") 
    frmPrinter.RTBox.SelText = vbCrLf + "        其中      : " 
    frmPrinter.RTBox.SelText = vbCrLf + "         商品零售 : " & Format(zSPSR, "###0.0元") 
    frmPrinter.RTBox.SelText = vbCrLf + "         商品支出 : " & Format(zSPZC, "###0.0元") 
    frmPrinter.RTBox.SelText = vbCrLf + "         商品收入 : " & Format(zSPSR - zSPZC, "###0.0元") + vbCrLf 
    frmPrinter.RTBox.SelFontSize = 9 
    frmPrinter.RTBox.SelText = "  ─────────────────────────────────────────────────────────" + vbCrLf 
    frmPrinter.RTBox.SelFontSize = 14 
    frmPrinter.RTBox.SelBold = True 
    frmPrinter.RTBox.SelText = "         总收入 : " & Format(zJshSS - zSPZC, "###0.0元") + vbCrLf 
    frmPrinter.RTBox.SelFontSize = 9 
      frmPrinter.RTBox.SelText = "  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + vbCrLf 
   frmPrinter.RTBox.SelItalic = True 
   frmPrinter.RTBox.SelBold = False 
    frmPrinter.RTBox.SelAlignment = 2 
     frmPrinter.RTBox.SelFontSize = 10 
   frmPrinter.RTBox.SelText = Format(Date, "long date") 
 frmPrinter.Show 
     
End Select 
 
Unload frmJinDu 
Screen.MousePointer = 0 
'Unload frmPrinter 
Unload Me 
 
End Sub 
 
Private Sub Command2_Click() 
Unload Me 
End Sub 
 
Private Sub Form_Load() 
On Error Resume Next 
With frmMain.Data1.Recordset 
aa = .AbsolutePosition 
.MoveFirst 
For i = 1 To .RecordCount 
 Combo2.AddItem .Fields("名称") 
 Combo2.ItemData(Combo2.NewIndex) = .Fields("机号") 
 .MoveNext 
Next i 
End With 
Combo2.Text = "全部计算机" 
 
End Sub