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

📄 thismonthsumform.frm

📁 简易员工管理系统,自己做的
💻 FRM
字号:
VERSION 5.00
Begin VB.Form ThisMonthSumForm 
   Caption         =   "当月工资总表"
   ClientHeight    =   6720
   ClientLeft      =   615
   ClientTop       =   1440
   ClientWidth     =   12360
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   6720
   ScaleWidth      =   12360
   Begin VB.CommandButton cmdCancel 
      Caption         =   "取消"
      Height          =   495
      Left            =   9840
      TabIndex        =   3
      Top             =   1680
      Width           =   1455
   End
   Begin VB.CommandButton cmdGenerate 
      Caption         =   "生成报表"
      Height          =   495
      Left            =   9840
      TabIndex        =   2
      Top             =   240
      Width           =   1455
   End
   Begin VB.CommandButton cmdPrint 
      Caption         =   "打印报表"
      Height          =   495
      Left            =   9840
      TabIndex        =   1
      Top             =   960
      Width           =   1455
   End
   Begin VB.OLE OLE1 
      Height          =   6135
      Left            =   240
      SizeMode        =   3  'Zoom
      TabIndex        =   0
      Top             =   120
      Width           =   9135
   End
End
Attribute VB_Name = "ThisMonthSumForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mMonth As String
Dim SQL As String, mSheet As Worksheet

Private Sub cmdCancel_Click()
    Me.Hide
End Sub

'生成报表
Private Sub cmdGenerate_Click()
    '打开错误处理陷阱
    Dim intErrFileNo As Integer  '自由文件号
    Dim sheet As Worksheet
    On Error GoTo ErrGoto
    '----------------------------------------------------
    '打开Excel
    Set gX = GetObject("", "Excel.Application")
    
    '打开月表
    SQL = "SELECT * FROM " & mMonth
    OpenRS (SQL)
    gRst.MoveFirst
    Dim i As Integer
    i = 0
    gX.Workbooks.Close
    gX.Workbooks.Add
    gX.Visible = True
    Set sheet = gX.ActiveSheet
    i = i + 1
    '添加信息
    sheet.Cells(i, 1) = mMonth
    i = i + 1
    sheet.Cells(i, 1) = "职工ID"
    sheet.Cells(i, 2) = "工资取毕"
    sheet.Cells(i, 3) = "工资"
    While Not gRst.EOF
        i = i + 1
        sheet.Cells(i, 1) = gRst("职工ID")
        sheet.Cells(i, 2) = IIf(gRst("工资取毕"), "是", "否")
        sheet.Cells(i, 3) = gRst("工资")
        gRst.MoveNext
    Wend
    CloseRS
    
    Set mSheet = sheet
    
    '存储文件
    gX.ActiveWorkbook.SaveAs App.Path & "\" & mMonth & "总表.xls"
    OLE1.CreateEmbed App.Path & "\" & mMonth & "总表.xls"
   '----------------------------------------------------
   Exit Sub
   '-----------------------------
ErrGoto:
   '把错误信息保存在文件里
   intErrFileNo = FreeFile()
   Open "YFSystem.ini" For Append As intErrFileNo
     Print #intErrFileNo, Chr(34) + Format(Now, "YYYY-MM-DD HH:MM:SS") + Chr(34), Chr(34) + "信息" + Chr(34), Chr(34) + Err.Description + Chr(34), Chr(34) + "cmdGenerate_Click(ThisMonthSalaryForm)" + Chr(34), Chr(34) + App.Title + Chr(34)
   Close #intErrFileNo
End Sub

Private Sub cmdPrint_Click()
    mSheet.PrintOut
End Sub

Private Sub Form_Load()
    mMonth = Format(Date - 30, "YYYYMM")
End Sub

⌨️ 快捷键说明

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