-
资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:65k
源码类别:
企业管理
开发平台:
Visual Basic
- Attribute VB_Name = "XtsyModule"
- '系统私有模块用来放置一些子系统独有的过程与函数
- Public str_Code As String '存储列内容参数
- Public sParam As String
- Public Const DATA_NUMERIC As Integer = 5 '数字行
- Public Const DATA_STRING As Integer = 0 '字符型
- Public Const DATA_DATE As Integer = 7 '日期型
- Const PRINTSTYLE_ONETITLE = 0 '每页打印表头
- Const PRINTSTYLE_ALLTITLE = 1 '每行打印表头
- Public XT_BillID As String '人事变动存储职工号
- Public str_mark As String '人事变动存储职工变动号
- Public Function DelRsItem(FieldName As String, ChName As String) As Boolean
- '删除人事项目的限制
- Dim Rsc As New ADODB.Recordset
- Dim Sql As String
- Const OpeStatus = "删除"
- With Rsc
- '没有用在公式的内容中
- If .State = 1 Then .Close
- Sql = "SELECT * FROM PM_Formula WHERE charindex('" & FieldName & _
- "',Fcontent)<>0 "
- .Open Sql, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not .EOF Then
- Call Xtxxts("公式内容使用了“" & ChName & "”,不能" & OpeStatus & "!", 0, 1)
- DelRsItem = False
- Exit Function
- End If
- '没有用在公式的限定条件中
- If .State = 1 Then .Close
- Sql = "SELECT * FROM PM_Formula WHERE charindex('" & FieldName & _
- "',FLimit)<>0 "
- .Open Sql, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not .EOF Then
- Call Xtxxts("公式的限定条件使用了“" & ChName & "”,不能" & OpeStatus & "!", 0, 1)
- DelRsItem = False
- Exit Function
- End If
- '没有用在标准表的字段中
- If .State = 1 Then .Close
- Sql = "SELECT * FROM PM_StandTbl WHERE ltrim(rtrim(BzbHxItem))='" & _
- FieldName & "' OR ltrim(rtrim(BzbVxItem))='" & _
- FieldName & "'"
- .Open Sql, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not .EOF Then
- Call Xtxxts("标准表的项目使用了“" & ChName & "”,不能" & OpeStatus & "!", 0, 1)
- DelRsItem = False
- Exit Function
- End If
- '没有用在标准表的限定条件中
- If .State = 1 Then .Close
- Sql = "SELECT * FROM PM_StandTbl WHERE charindex('" & FieldName & _
- "',BzbCond)<>0 "
- .Open Sql, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not .EOF Then
- Call Xtxxts("标准表的限定条件使用了“" & ChName & "”,不能" & OpeStatus & "!", 0, 1)
- DelRsItem = False
- Exit Function
- End If
- '没有用在银行代发的项目中
- If .State = 1 Then .Close
- Sql = "SELECT * FROM PM_BankItem WHERE ltrim(rtrim(DataContent))='" & _
- FieldName & "' "
- .Open Sql, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not .EOF Then
- Call Xtxxts("“" & ChName & "”是银行代发文件项目,不能" & OpeStatus & "!", 0, 1)
- DelRsItem = False
- Exit Function
- End If
- '不是报表显示项目
- If .State = 1 Then .Close
- Sql = "SELECT * FROM PM_ReportItem WHERE ltrim(rtrim(FieldName))='" & FieldName & "'"
- .Open Sql, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not .EOF Then
- Call Xtxxts("“" & ChName & "”是报表显示项目,不能" & OpeStatus & "!", 0, 1)
- DelRsItem = False
- Exit Function
- End If
- '不是工资表引用的人事项目
- If .State = 1 Then .Close
- Sql = "SELECT * FROM Rs_Items WHERE AddMinusItem=1 AND FieldName<>'deptcode'" & _
- " AND FieldName<>'EmpNO' AND FieldName<>'EmpName' AND FieldName<>'EmpSort'" & _
- " and ltrim(rtrim(FieldName))='" & FieldName & "'"
- .Open Sql, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not .EOF Then
- Call Xtxxts("“" & ChName & "”已在工资表中使用,不能" & OpeStatus & "!", 0, 1)
- DelRsItem = False
- Exit Function
- End If
- '在人事表中没有数据
- If .State = 1 Then .Close
- Sql = "select * from Rs_BasicInfo b inner join Rs_ExtendInfo e on b.EmpId=e.Empid " & _
- " where " & FieldName & " is not null and ltrim(rtrim(" & FieldName & "))<>''"
- .Open Sql, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not .EOF Then
- Call Xtxxts("“" & ChName & "”已在人事表中有数据,不能" & OpeStatus & "!", 0, 1)
- DelRsItem = False
- Exit Function
- End If
- End With
- DelRsItem = True
- End Function
- Public Sub Drxtztcs() '读入系统帐套参数
- Dim Ztcsbrec As New ADODB.Recordset
- Dim RecTemp As New ADODB.Recordset
- Dim Sqlstr As String
- With Ztcsbrec
- '金额总位数
- .Open "Select * From Gy_AccInformation Where SystemCode='Cwzz'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- .MoveFirst
- .Find "itemcode='cwjezws'"
- If Not Ztcsbrec.EOF Then
- Xtjezws = Val(Trim(Ztcsbrec.Fields("itemvalue")))
- End If
- '数量总位数
- .MoveFirst
- .Find "itemcode='cwslzws'"
- If Not Ztcsbrec.EOF Then
- Xtslzws = Val(Trim(Ztcsbrec.Fields("itemvalue")))
- End If
- '单价总位数
- .MoveFirst
- .Find "itemcode='cwdjzws'"
- If Not Ztcsbrec.EOF Then
- Xtdjzws = Val(Trim(Ztcsbrec.Fields("itemvalue")))
- End If
- '金额小数位数
- .MoveFirst
- .Find "itemcode='cwjexsws'"
- If Not Ztcsbrec.EOF Then
- Xtjexsws = Val(Trim(Ztcsbrec.Fields("itemvalue")))
- End If
- '数量小数位数
- .MoveFirst
- .Find "itemcode='cwslxsws'"
- If Not Ztcsbrec.EOF Then
- Xtslxsws = Val(Trim(Ztcsbrec.Fields("itemvalue")))
- End If
- '单价小数位数
- .MoveFirst
- .Find "itemcode='cwdjxsws'"
- If Not Ztcsbrec.EOF Then
- Xtdjxsws = Val(Trim(Ztcsbrec.Fields("itemvalue")))
- End If
- .Close
- End With
- End Sub
- Public Function GetDeptHp(bMinLvl As Boolean, sDName As String) As String
- Dim frm As New Hp_Dept_Frm
- With frm
- .bMinLvl = bMinLvl
- .Show 1
- GetDeptHp = .sDept
- sDName = .sDeptName
- End With
- Set frm = Nothing
- End Function
- '单据打印输出
- Public Sub Bill_TextPrint(LrText As Object, Text_code As String, XtReportCode As String, Optional PrintDirect As Boolean = False)
- Dim aDo_Rec As New Recordset
- With DY_Tybbyldy
- '=====================
- Set aDo_Rec = Cw_DataEnvi.DataConnect.Execute("select * from Xt_dybbcs where bbbm='" & XtReportCode & "'")
- .Tydy.PaperSize = aDo_Rec!PaperSize
- .Tydy.Orientation = aDo_Rec!PaperScfx
- .Tydy.MarginLeft = aDo_Rec!bbzbj
- .Tydy.MarginTop = aDo_Rec!bbsbj
- aDo_Rec.Close
- '=====================
- Set aDo_Rec = Cw_DataEnvi.DataConnect.Execute("select * from Xt_text_input where text_group_code='" & Text_code & "' order by text_index")
- '<<<<<<<<
- .Tydy.StartDoc
- '=========
- Do While Not aDo_Rec.EOF '表头数据
- If aDo_Rec!YnPrint = True Then
- .Tydy.CurrentX = aDo_Rec!LabelLeft: .Tydy.CurrentY = aDo_Rec!PrintTop
- .Tydy = Trim(aDo_Rec!Text_Name) & ":"
- .Tydy.CurrentX = aDo_Rec!PrintLeft: .Tydy.CurrentY = aDo_Rec!PrintTop
- .Tydy = LrText(aDo_Rec!text_Index)
- End If
- aDo_Rec.MoveNext
- Loop
- '==========
- .Tydy.EndDoc
- '判断是直接打印还是预览
- If Not PrintDirect Then
- .Show 1 '预览
- Else
- Call DY_DytsFrm.Output_Printer '直接打印输出
- Unload DY_Tybbyldy '卸载打印预览窗体
- Unload DY_DytsFrm '卸载打印选择提示选项
- End If
- End With
- End Sub
- Public Sub Print_Empchange() '人事变动打印
- Dim Max_y As Integer
- Dim tmpRs As New Recordset
- With DY_Tybbyldy.Tydy
- '-----------------
- .X1 = 0: .Y1 = 0: .X2 = 0: .Y2 = 0
- '=====================
- Set tmpRs = Cw_DataEnvi.DataConnect.Execute("select * from Xt_dybbcs where bbbm='" & XtReportCode & "'")
- .PaperSize = tmpRs!PaperSize
- .Orientation = tmpRs!PaperScfx
- .MarginLeft = tmpRs!bbzbj
- .MarginTop = tmpRs!bbsbj
- .MarginBottom = tmpRs!bbxbj
- .MarginRight = tmpRs!bbybj
- .StartDoc
- .CurrentX = "3.5in"
- .FontName = Trim(tmpRs!Bbbtfont)
- .FontSize = Trim(tmpRs!Bbbtsize)
- .FontBold = True
- DY_Tybbyldy.Tydy = "人事变动处理"
- .CurrentX = "1in": .CurrentY = "1.4in"
- .FontSize = Trim(tmpRs!Bbsjqsize)
- .FontName = Trim(tmpRs!Bbsjqfont)
- .FontBold = False
- tmpRs.Close
- Dim r As Integer
- Dim Height_Y As Integer
- Height_Y = 2100
- For r = 0 To Ed_EmpChgFrm.TsLabel.count - 1
- .CurrentX = 1600 + Ed_EmpChgFrm.TsLabel(r).Left
- .CurrentY = Height_Y + Ed_EmpChgFrm.TsLabel(r).Top
- DY_Tybbyldy.Tydy = Ed_EmpChgFrm.TsLabel(r).Caption
- .CurrentX = 1600 + Ed_EmpChgFrm.LrText(r).Left + 100
- .CurrentY = Height_Y + Ed_EmpChgFrm.TsLabel(r).Top
- DY_Tybbyldy.Tydy = Ed_EmpChgFrm.LrText(r).Text
- If .CurrentY > Max_y Then Max_y = .CurrentY
- Next r
- ' 设置照片的位置,程序手动调的
- '----------------
- .EndDoc
- DY_Tybbyldy.Show 1
- End With
- End Sub
- Public Function Item_Info(sys As Integer) '项目查询连接
- 'sys=0,人事系统调用;sys=1,工资系统调用
- Dim tmpRs As New Recordset
- Dim sSql As String
- If sys = 0 Then
- Set tmpRs = Cw_DataEnvi.DataConnect.Execute("select * from Rs_Items WHERE SID='1' ")
- Else
- Set tmpRs = Cw_DataEnvi.DataConnect.Execute("select * from Rs_Items WHERE SID='2' OR Pm='1' ")
- End If
- With tmpRs
- Do While Not .EOF
- If Trim(!CorTable) = "" Then '非编码型的
- If Trim(!TableName) = "Rs_BasicInfo" Then
- sSql = sSql & ",B." & !FieldName
- Else
- sSql = sSql & ",E." & !FieldName
- End If
- Else
- If Trim(tmpRs!CorTable) = "Rs_CorSub" Then '这个字段是编码型的,并且相关项的字段在Rs_CorSub
- If Trim(!TableName) = "Rs_BasicInfo" Then
- sSql = sSql & ",N_" & !FieldName & "=(select ListName from Rs_CorSub c where convert(varchar(18),c.ListId)=B." & !FieldName & ")"
- sSql = sSql & ",B." & !FieldName
- Else
- sSql = sSql & ",N_" & !FieldName & "=(select ListName from Rs_CorSub c where convert(varchar(18),c.ListId)=E." & !FieldName & ")"
- sSql = sSql & ",E." & !FieldName
- End If
- '-----------------
- Else '这个字段是编码型的,但是相关项的字段表不确定的情况
- If Trim(!TableName) = "Rs_BasicInfo" Then
- sSql = sSql & ",N_" & !FieldName & "=(select " & Trim(tmpRs!IndexName) & " from " & Trim(tmpRs!CorTable) & " c where c." & Trim(tmpRs!IndexCode) & "=B." & !FieldName & ")"
- sSql = sSql & ",B." & !FieldName
- Else
- sSql = sSql & ",N_" & !FieldName & "=(select " & Trim(tmpRs!IndexName) & " from " & Trim(tmpRs!CorTable) & " c where c." & Trim(tmpRs!IndexCode) & "=E." & !FieldName & ")"
- sSql = sSql & ",E." & !FieldName
- End If
- End If
- End If
- .MoveNext
- Loop
- sSql = "SELECT " & Mid(sSql, 2, Len(sSql) - 1) & " FROM Rs_ExtendInfo E,Rs_BasicInfo B"
- End With
- Item_Info = sSql
- End Function
- Public Function CFieldValueCopy(Source As CFieldValue, aim As CFieldValue)
- With Source
- aim.FieldIsShow = .FieldIsShow
- aim.FieldLengthFra = .FieldLengthFra
- aim.FieldLengthInt = .FieldLengthInt
- aim.FieldName = .FieldName
- aim.FieldNameC = .FieldNameC
- aim.FieldType = .FieldType
- aim.FieldValueName = .FieldValueName
- aim.FieldWidth = .FieldWidth
- End With
- End Function
- '******************************************************************
- '* 模 块 名 称 :私有模块
- '* 功 能 描 述 :
- '* 程序员姓名 :苗鹏
- '* 最后修改人 :苗鹏
- '* 最后修改时间:2002/01/10
- '* 备 注:
- '******************************************************************
- Public Function GetTableField(sExec As String, sTableName As String, sFieldName As String, s As String) As Integer '分离表名和字段名,s为分隔符
- On Error GoTo ErrCtrl
- Dim i As Integer
- For i = 1 To Len(sExec)
- If Mid(sExec, i, 1) = s Then
- sTableName = Left(sExec, i - 1)
- sFieldName = Right(sExec, Len(sExec) - i)
- Exit For
- End If
- Next i
- If i <= Len(sExec) Then
- GetTableField = 1
- Else
- GetTableField = 0
- End If
- Exit Function
- ErrCtrl:
- GetTableField = -1
- End Function
- Public Function InitView(tv As TreeView, Optional sSql As String = " 1=1 ") '初始化字段树
- On Error GoTo ErrCtrl
- Dim rs As New ADODB.Recordset
- Dim s As String
- Dim nodX As Node
- If sSql = "" Then
- sSql = " 1=1 "
- End If
- tv.Nodes.Clear
- tv.Enabled = False
- Set nodX = tv.Nodes.Add(, , "R", "备选项目")
- '读取表
- s = "SELECT DISTINCT TableName AS TableFrom FROM Rs_Items WHERE SID<10 AND " & sSql
- Set rs = Cw_DataEnvi.DataConnect.Execute(s)
- With rs
- If .EOF() Then
- Exit Function
- End If
- Do While Not .EOF()
- Set nodX = tv.Nodes.Add("R", tvwChild, UCase(Trim(!TableFrom)), GetTableNameC(Trim(!TableFrom)))
- nodX.EnsureVisible
- .MoveNext
- Loop
- .Close
- End With
- '读取字段
- s = "SELECT FieldName AS FieldName,CHName AS FieldNameC,TableName AS TableFrom " & Chr(10) _
- & ",Correlation AS FieldRelation,CorTable AS CorTable ,IndexCode AS TCode,IndexName AS TName,AddMinusItem " & Chr(10) _
- & " FROM Rs_Items WHERE SID<10 AND " & sSql 'TableName is not Null "
- Set rs = Cw_DataEnvi.DataConnect.Execute(s)
- With rs
- If .EOF() Then
- Exit Function
- End If
- Do While Not .EOF()
- '末级节点的Tag值为此字段的英文全名
- If !AddMinusItem = 1 And Trim(sSql) = Trim("1=1") Then
- '如果是选入工资表的字段,添加工资表节点
- Set nodX = tv.Nodes.Add(UCase("PM_PayRoll"), tvwChild, UCase("PM_PayRoll") & "." & UCase(Trim(!FieldName)), UCase(Trim(!FieldNameC)))
- If Trim(!CorTable & "") <> "" And Trim(!TCode & "") <> "" And Trim(!TName & "") <> "" Then
- nodX.Tag = Trim(!FieldRelation & "") & "@" & Trim(!CorTable & "") & "@" & Trim(!TCode & "") & "@" & Trim(!TName & "")
- End If
- End If
- Set nodX = tv.Nodes.Add(UCase(Trim(!TableFrom)), tvwChild, UCase(Trim(!TableFrom) & "." & Trim(!FieldName)), UCase(Trim(!FieldNameC)))
- If Trim(!CorTable & "") <> "" And Trim(!TCode & "") <> "" And Trim(!TName & "") <> "" Then
- nodX.Tag = Trim(!FieldRelation & "") & "@" & Trim(!CorTable & "") & "@" & Trim(!TCode & "") & "@" & Trim(!TName & "")
- End If
- .MoveNext
- Loop
- .Close
- End With
- '添加会计年,会计期间,工资类别到工资表节点
- If IsNodeExist("PM_PayRoll", tv) Then
- Set nodX = tv.Nodes.Add(UCase("PM_PayRoll"), tvwChild, UCase("PM_PayRoll.KjYear"), "会计年")
- Set nodX = tv.Nodes.Add(UCase("PM_PayRoll"), tvwChild, UCase("PM_PayRoll.Period"), "会计月")
- Set nodX = tv.Nodes.Add(UCase("PM_PayRoll"), tvwChild, UCase("PM_PayRoll.SortID"), "工资类别")
- nodX.Tag = "0@PM_Sort@SortID@SortName"
- End If
- '添加会计年,会计期间到考勤表节点
- If IsNodeExist("PM_AttendRecord", tv) Then
- Set nodX = tv.Nodes.Add(UCase("PM_AttendRecord"), tvwChild, UCase("PM_AttendRecord.KjYear"), "会计年")
- Set nodX = tv.Nodes.Add(UCase("PM_AttendRecord"), tvwChild, UCase("PM_AttendRecord.Period"), "会计月")
- End If
- Set rs = Nothing
- tv.Enabled = True
- Exit Function
- ErrCtrl:
- If rs.State = 1 Then
- rs.Close
- End If
- Set rs = Nothing
- tv.Enabled = True
- Dim smsg As String
- Dim smsgSys As String
- smsg = GetError(Err.Number)
- smsgSys = Err.Number & Err.Description & "!"
- MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
- End Function
- Public Function GetFieldHelp(sExp As String, sID As String, sTable As String, sCode As String, sName As String) '读取字段帮助信息
- Dim i As Integer
- Dim j As Integer
- Dim k As Integer
- Dim s(3) As String
- If sExp = "" Then
- Exit Function
- End If
- j = 1
- k = 0
- '取ID,关联表,编码,名称
- Do While i <= Len(sExp)
- For i = j To Len(sExp)
- If Mid(sExp, i, 1) = "@" Then
- s(k) = Mid(sExp, j, i - j)
- j = i + 1
- k = k + 1
- Exit For
- End If
- Next i
- If i > Len(sExp) Then
- sName = Mid(sExp, j, i - j)
- End If
- Loop
- sID = s(0)
- sTable = s(1)
- sCode = s(2)
- End Function
- Public Function GetError(iNum As Long) As String '返回错误描述
- Dim msg As String
- Select Case iNum
- Case -2147217873
- msg = "违反唯一性或者编码已经使用!"
- Case -2147217913
- msg = "录入了错误的日期格式,正确格式为 2001-09-12" & Chr(10) _
- & "或者录入了错误的数字格式,正确格式为 123456789.12"
- Case -2147217900
- msg = "语法错误!"
- Case Else
- msg = ""
- End Select
- GetError = msg
- End Function
- Public Function ReplByPos(sExepress As String, sReplace As String, Optional iStart As Integer = 0, Optional iEnd As Integer = 0) As String '把sExepress的第iStart字起到iEnd结束的字符替换成sReplace
- Dim i As Integer
- Dim j As Integer
- Dim sLeft As String
- Dim sRight As String
- If iStart > Len(sExepress) Then
- MsgBox "开始位置超出字符长度", vbOKOnly + vbCritical
- Exit Function
- End If
- If iStart > iEnd Then
- MsgBox "开始位置超出结束位置", vbOKOnly + vbCritical
- Exit Function
- End If
- sLeft = Left(sExepress, iStart - 1)
- sRight = Right(sExepress, Len(sExepress) - iEnd + 1)
- ReplByPos = sLeft & sReplace & sRight
- End Function
- Public Function IsItemExist(sName As String, coll As Collection, Optional iType As Integer = 0) As Integer 'coll中是否包涵sName的项目
- 'itype=0 不区分大小写 1 区分大小写
- '返回sName的位置或-1
- Dim i As Integer
- With coll
- If .count = 0 Then
- IsItemExist = -1
- Exit Function
- End If
- If iType = 0 Then
- For i = 1 To .count
- If UCase(sName) = UCase(.Item(i)) Then
- Exit For
- End If
- Next i
- Else
- For i = 1 To .count
- If sName = .Item(i) Then
- Exit For
- End If
- Next i
- End If
- If i > .count Then
- IsItemExist = -1
- Else
- IsItemExist = i
- End If
- End With
- End Function
- Public Function GetSQLFrom(coll As Collection, sPriTableName As String) As String '根据所提供的表名,连接成From语句
- On Error GoTo ErrCtrl
- Dim s As String
- Dim st As String
- Dim i As Integer
- Dim j As Integer
- Dim k As Integer
- If sPriTableName = "" Then
- MsgBox "请输入主表名!", vbOKOnly + vbInformation
- Exit Function
- End If
- s = ""
- With coll
- If .count = 0 Then
- s = " " & sPriTableName & Chr(10) & " "
- GetSQLFrom = s
- Exit Function
- End If
- '判断主表,因为每个表的连接字段不同,所以要分开处理
- Select Case UCase(sPriTableName)
- Case UCase("PM_PayRoll") '工资表
- s = " PM_PayRoll left outer join PM_AttendRecord " & Chr(10) _
- & " on PM_PayRoll.EmpID=PM_AttendRecord.EmpID AND PM_PayRoll.Period=PM_AttendRecord.Period AND PM_PayRoll.KjYear=PM_AttendRecord.KjYear " & Chr(10) _
- & " Left Outer Join PM_TaxData " & Chr(10) _
- & " on PM_PayRoll.EmpID=PM_TaxData.EmpID AND PM_PayRoll.Period=PM_TaxData.Period AND PM_PayRoll.KjYear=PM_TaxData.KjYear AND PM_PayRoll.SortID=PM_TaxData.SortID " & Chr(10)
- Case UCase("PM_AttendRecord") '考勤表
- i = IsItemExist("PM_PayRoll", coll)
- If i <> -1 Then
- s = " PM_AttendRecord left outer join PM_PayRoll " & Chr(10) _
- & " on PM_PayRoll.EmpID=PM_AttendRecord.EmpID AND PM_PayRoll.Period=PM_AttendRecord.Period AND PM_PayRoll.KjYear=PM_AttendRecord.KjYear " & Chr(10) _
- & " Left Outer Join PM_TaxData " & Chr(10) _
- & " on PM_AttendRecord.EmpID=PM_TaxData.EmpID AND PM_AttendRecord.Period=PM_TaxData.Period AND PM_AttendRecord.KjYear=PM_TaxData.KjYear " & Chr(10)
- Else
- s = " PM_AttendRecord " & Chr(10)
- End If
- Case UCase("PM_TaxData") '所得税表
- i = IsItemExist("PM_PayRoll", coll)
- If i <> -1 Then
- s = " PM_TaxData left outer join PM_AttendRecord " & Chr(10) _
- & " on PM_TaxData.EmpID=PM_AttendRecord.EmpID AND PM_TaxData.Period=PM_AttendRecord.Period AND PM_TaxData.KjYear=PM_AttendRecord.KjYear " & Chr(10) _
- & " Left Outer Join PM_PayRoll " & Chr(10) _
- & " on PM_PayRoll.EmpID=PM_TaxData.EmpID AND PM_PayRoll.Period=PM_TaxData.Period AND PM_PayRoll.KjYear=PM_TaxData.KjYear AND PM_PayRoll.SortID=PM_TaxData.SortID " & Chr(10)
- Else
- s = "PM_TaxData"
- End If
- Case Else
- s = sPriTableName
- End Select
- '连接剩下的表
- For k = 1 To .count
- If UCase(sPriTableName) <> UCase(.Item(k)) And _
- Trim(UCase(.Item(k))) <> "" And _
- Trim(UCase(.Item(k))) <> UCase("PM_PayRoll") And _
- Trim(UCase(.Item(k))) <> UCase("PM_AttendRecord") And _
- Trim(UCase(.Item(k))) <> UCase("PM_TaxData") Then
- s = s & " left outer join " & Trim(.Item(k)) & " on " & Trim(.Item(k)) & ".EmpID=" & sPriTableName & ".EmpID " & Chr(10)
- End If
- Next k
- End With
- GetSQLFrom = s
- Exit Function
- ErrCtrl:
- Dim smsg As String
- Dim smsgSys As String
- smsg = GetError(Err.Number)
- smsgSys = Err.Number & Err.Description & "!"
- MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
- End Function
- Public Function AddTableFrom(coll As Collection, sName As String) '添加用户查询必须的表
- On Error GoTo ErrCtrl
- Dim i As Integer
- '如果没有定义查询条件,简单添加表名
- '如果表名集合第一项为“”,则删除第一项
- With coll
- If coll.count = 0 Then
- .Add UCase(sName)
- Exit Function
- End If
- If Trim(.Item(1)) = "" Then
- .Remove (1)
- End If
- For i = 1 To .count
- If UCase(.Item(i)) = UCase(sName) Then
- Exit For
- End If
- Next
- If i > .count Then
- .Add UCase(sName)
- End If
- End With
- Exit Function
- ErrCtrl:
- Dim smsg As String
- Dim smsgSys As String
- smsg = GetError(Err.Number)
- smsgSys = Err.Number & Err.Description & "!"
- MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
- End Function
- Public Function IsNodeExist(skey As String, tv As TreeView) As Boolean '测试树是否包含Key为skey的节点
- On Error GoTo ErrCtrl
- Dim i As Integer
- With tv
- For i = 1 To .Nodes.count
- If UCase(.Nodes(i).Key) = UCase(skey) Then
- IsNodeExist = True
- Exit Function
- End If
- Next
- End With
- IsNodeExist = False
- Exit Function
- ErrCtrl:
- Dim smsg As String
- Dim smsgSys As String
- smsg = GetError(Err.Number)
- smsgSys = Err.Number & Err.Description & "!"
- MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
- End Function
- Public Function FillValue2TV(sCond As String, tv As TreeView) '填充字段的可能值,sCond 的格式为 数字@表名@编码@名称
- On Error GoTo ErrCtrl
- '如果没有条件,退出
- tv.Nodes.Clear
- If Trim(sCond) = "" Then
- Exit Function
- End If
- Dim sID As String
- Dim sTable As String
- Dim sCode As String
- Dim sName As String
- Dim rs As New ADODB.Recordset
- Dim s As String
- tv.Nodes.Clear
- '取得字段帮助
- GetFieldHelp sCond, sID, sTable, sCode, sName
- ' 填充值
- With tv
- If UCase(sTable) = UCase("GY_Department") Then
- '如果是部门帮助,调用填充部门帮助
- FillDept2TV "RsPmFlag", tv, Cw_DataEnvi.DataConnect
- Else
- '判断字段帮助
- If Trim(sID) = "" Or Trim(sTable) = "" Or Trim(sCode) = "" Or Trim(sName) = "" Then
- MsgBox "字段帮助出现错误!", vbOKOnly + vbCritical
- GoTo ErrCtrl
- End If
- If Trim(sID) = "0" Then
- s = "SELECT " & sCode & " AS TCode, " & sName & " AS TName FROM " & sTable
- Else
- s = "SELECT " & sCode & " AS TCode, " & sName & " AS TName FROM " & sTable & " WHERE SortID='" & sID & "'"
- End If
- Set rs = Cw_DataEnvi.DataConnect.Execute(s)
- If Not rs.EOF() Then
- .Nodes.Add , , "R", "备选值"
- Do While Not rs.EOF()
- .Nodes.Add "R", tvwChild, "R" & Trim(rs!TCode), Trim(rs!TName)
- rs.MoveNext
- Loop
- rs.Close
- End If
- Set rs = Nothing
- End If
- End With
- Exit Function
- ErrCtrl:
- If rs.State = 1 Then
- rs.Close
- End If
- Set rs = Nothing
- Dim smsg As String
- Dim smsgSys As String
- smsg = GetError(Err.Number)
- smsgSys = Err.Number & Err.Description & "!"
- MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
- End Function
- Public Function FillDept2TV(sSysCode As String, tv As TreeView, cn As Connection) '填充部门树
- On Error GoTo ErrCtrl
- Dim s As String
- Dim rs As New ADODB.Recordset
- Dim nod As Node
- '初始化树
- tv.Enabled = False
- tv.Nodes.Clear
- tv.Nodes.Add , , "R", "部门"
- s = "SELECT DeptCode,DeptName ,ParentCode FROM GY_Department WHERE " & sSysCode & "=1 order by CodeLevel"
- Set rs = Cw_DataEnvi.DataConnect.Execute(s)
- With rs
- Do While Not .EOF()
- Set nod = tv.Nodes.Add("R" & Trim(!ParentCode & ""), tvwChild, "R" & Trim(!DeptCode & ""), Trim(!DeptName & ""))
- nod.Tag = Trim(!DeptCode & "")
- '展开第一行
- If Trim(!ParentCode & "") = "" Then
- nod.EnsureVisible
- End If
- .MoveNext
- Loop
- .Close
- End With
- Set rs = Nothing
- Set nod = Nothing
- tv.Enabled = True
- Exit Function
- ErrCtrl:
- If rs.State = 1 Then
- rs.Close
- End If
- Set nod = Nothing
- Set rs = Nothing
- tv.Enabled = True
- Dim smsg As String
- Dim smsgSys As String
- smsg = GetError(Err.Number)
- smsgSys = Err.Number & Err.Description & "!"
- MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
- End Function
- Public Function GetTableNameC(sTableName As String) As String '设置表的汉语名称
- Dim s As String
- Select Case UCase(sTableName)
- Case UCase("PM_PayRoll")
- s = "工资"
- Case UCase("Rs_BasicInfo")
- s = "基本"
- Case UCase("Rs_ExtendInfo")
- s = "扩展"
- Case UCase("PM_AttendRecord")
- s = "考勤"
- Case Else
- MsgBox "不存在此表!", vbOKOnly + vbCritical
- End Select
- GetTableNameC = s
- End Function
- Public Function GetCol(sFields() As CFieldValue, iNoCol As Integer, iNameCol As Integer, Optional iBeginCol As Integer = 0) As Integer '查找工号列和姓名列
- '成功找到工号或者姓名返回1,没有找到返回0,错误返回-1
- On Error GoTo ErrCtrl
- Dim i As Integer
- iNoCol = -1
- iNameCol = -1
- GetCol = -1
- For i = LBound(sFields) To UBound(sFields)
- If Len(sFields(i).FieldName) >= 5 Then
- If UCase(Right(sFields(i).FieldName, 5)) = UCase("EmpNo") Then
- iNoCol = i + iBeginCol
- Else
- If Len(sFields(i).FieldName) >= 7 Then
- If UCase(Right(sFields(i).FieldName, 7)) = UCase("EmpName") Then
- iNameCol = i + iBeginCol
- End If
- End If
- End If
- End If
- If iNameCol >= 0 And iNoCol >= 0 Then
- Exit For
- End If
- Next i
- If iNameCol >= 0 Or iNoCol >= 0 Then
- GetCol = 1
- Else
- GetCol = 0
- End If
- Exit Function
- ErrCtrl:
- GetCol = -1
- End Function
- Public Function LenByte(s As String) As Long '计算字符串的字节数
- '返回字符串长度
- Dim i As Long
- Dim CH As String
- LenByte = 0
- s = Trim(s)
- For i = 1 To Len(s)
- CH = Mid(s, i, 1)
- If Asc(CH) >= 0 And Asc(CH) <= 255 Then
- LenByte = LenByte + 1
- ElseIf Asc(CH) < 0 Then '汉字
- LenByte = LenByte + 2
- End If
- Next
- End Function
- Public Function PrintGrid(vs As vsFlexGrid, iVsBeginCol As Integer, iVsSumEndCol As Integer, sRCode As String, frmSetup As DY_Dyymsz, sSubTitle As String, Optional bPrint As Boolean = False) '打印网格
- On Error GoTo ErrCtrl
- Dim i As Long
- Dim j As Long
- Dim k As Long
- Dim m As Long
- Dim n As Long
- Dim s As String
- Dim bNext As Boolean '临时变量
- Dim bSumRow As Boolean '是否是合计行
- Dim iStartCol As Long '打印数据开始列
- Dim rs As New ADODB.Recordset
- '--------------------------------------------------控制信息-------------------------------------------------
- Dim iPrintStyle As Integer '打印方式 0每页输出一个表头 1每行输出一个表头
- Dim iSumPerPage As Integer '1每页输出合计
- Dim iSplitPage As Integer '1分页打印
- Dim sRTitle As String '标题
- Dim iShowAllCols As Integer '1 显示所有可见网格列
- s = "SELECT * FROM PM_ReportSort WHERE RCode='" & sRCode & "'"
- Set rs = Cw_DataEnvi.DataConnect.Execute(s)
- With rs
- If Not .EOF() Then
- iPrintStyle = !PrintStyle
- iSumPerPage = !SumPerPage
- iSplitPage = !SplitPage
- iShowAllCols = !ShowAllCols
- sRTitle = Trim(!RTitle)
- Else
- MsgBox "当前报表已被删除,无法读取格式!", vbOKOnly + vbCritical
- Exit Function
- End If
- rs.Close
- End With
- Set rs = Nothing
- '--------------------------------------------------控制信息完成-------------------------------------------------
- '--------------------------------------------------打印参数-------------------------------------------------
- '设置打印参数
- If Not SetupPage(frmSetup, DY_Tybbyldy) Then
- MsgBox "打印设置失败!", vbOKOnly + vbCritical
- Exit Function
- End If
- '读取打印设置
- Dim sDataFontName As String '数据字体名称
- Dim sTitleFontName As String '表头字体名称
- Dim iDataFontSize As Long '数据字体大小
- Dim iTitleFontSize As Long '表头字体大小
- Dim iRowsPerPage As Long '每行显示数据行数
- Dim bLimitRowPerPage As Boolean '是否每页限制行数
- Dim iLimitRowsPerPage As Long '每页限制行数
- Dim iClientHeight As Long '页面可用高度
- Dim iPageLeft As Long '左边界
- Dim iClientWidth As Long '页面可用宽度
- Dim iPageTop As Long '上边界
- Dim iTitleFontHeight As Long '标题高度
- Dim iDataFontHeight As Long '数据高度
- With frmSetup
- sTitleFontName = .Btztlabel.Caption
- sDataFontName = .SjztLabel.Caption
- iTitleFontSize = Val(.Btzhlabel.Caption)
- iDataFontSize = Val(.Sjzhlabel.Caption)
- bLimitRowPerPage = .ZdhsCheck.Value
- iLimitRowsPerPage = Val(.BbhsText)
- End With
- With DY_Tybbyldy.Tydy
- .StartDoc
- .FontName = sTitleFontName
- .FontSize = iTitleFontSize
- .CalcText = "测试"
- iTitleFontHeight = .TextHei
- .FontName = sDataFontName
- .FontSize = iDataFontSize
- .CalcText = "测试"
- iDataFontHeight = .TextHei
- .EndDoc
- .KillDoc
- iPageHeight = .PageHeight
- iClientHeight = .PageHeight - .MarginBottom - .MarginTop
- iPageTop = .MarginTop
- iClientWidth = .PageWidth - .MarginLeft - .MarginRight
- iPageLeft = .MarginLeft
- End With
- '--------------------------------------------------打印参数完成-------------------------------------------------
- '--------------------------------------------------读取数据信息-------------------------------------------------
- '定义打印开始列
- If iShowAllCols = 1 Then
- iStartCol = iVsBeginCol
- Else
- iStartCol = iVsSumEndCol + 1
- End If
- '读取有效数据
- Dim sData() As String '网格表体数据
- Dim sTitle() As String '表头数据
- Dim iPages() As Long '打印分页信息,第i页结束行在sData()中的位置是iPages(i)
- Dim iTitleRows() As String '打印的表头行值
- Dim iDataRows() As String '打印的数据行值
- Dim iColsPerPage() As Long '每行在页面上的折行信息 第i行的结束列对应sData()中的iColsPerPage(i)列
- Dim iCols() As Long '需要打印的列值
- Dim iColWidth() As Long '需要打印的列款
- Dim iColType() As Long '需要打印的列数据类型
- Dim iColFormat() As String '需要打印的列格式
- With vs
- '读取有效列
- ReDim iCols(0)
- iCols(0) = 0
- ReDim iColWidth(0)
- iColWidth(0) = 0
- ReDim iColType(0)
- iColType(0) = 0
- ReDim iColFormat(0)
- iColFormat(0) = ""
- For i = 0 To .Cols - 1
- If Not .ColHidden(i) Then
- ReDim Preserve iCols(UBound(iCols) + 1)
- iCols(UBound(iCols)) = i
- ReDim Preserve iColWidth(UBound(iColWidth) + 1)
- If .ColWidth(i) >= iClientWidth Then
- MsgBox "纸张宽度太小不能输出报表,请重新设置!", vbOKOnly + vbCritical
- Exit Function
- End If
- iColWidth(UBound(iColWidth)) = .ColWidth(i)
- ReDim Preserve iColType(UBound(iColType) + 1)
- iColType(UBound(iColType)) = Val(.TextMatrix(0, i))
- ReDim Preserve iColFormat(UBound(iColFormat) + 1)
- iColFormat(UBound(iColFormat)) = .ColFormat(i)
- End If
- Next i
- If UBound(iCols) = 0 Then
- Exit Function
- End If
- '读取有效表头行
- ReDim iTitleRows(0)
- iTitleRows(0) = 0
- For i = 0 To .FixedRows - 1
- If .RowHidden(i) = False Then
- ReDim Preserve iTitleRows(UBound(iTitleRows) + 1)
- iTitleRows(UBound(iTitleRows)) = i
- End If
- Next i
- If UBound(iTitleRows) = 0 Then
- Exit Function
- End If
- '读取有效数据行
- ReDim iDataRows(0)
- iDataRows(0) = 0
- For i = .FixedRows To .Rows - 1
- If .RowHidden(i) = False Then
- ReDim Preserve iDataRows(UBound(iDataRows) + 1)
- iDataRows(UBound(iDataRows)) = i
- End If
- Next i
- If UBound(iDataRows) = 0 Then
- Exit Function
- End If
- '读取表头数据
- ReDim sTitle(UBound(iTitleRows) - 1, UBound(iCols) - 1)
- For i = LBound(iTitleRows) + 1 To UBound(iTitleRows)
- For j = LBound(iCols) + 1 To UBound(iCols)
- sTitle(i - LBound(iTitleRows) - 1, j - LBound(iCols) - 1) = .TextMatrix(iTitleRows(i), iCols(j))
- Next j
- Next i
- '读取表体数据
- ReDim sData(UBound(iDataRows) - 1, UBound(iCols) - 1)
- For i = LBound(iDataRows) + 1 To UBound(iDataRows)
- For j = LBound(iCols) + 1 To UBound(iCols)
- sData(i - LBound(iDataRows) - 1, j - LBound(iCols) - 1) = .TextMatrix(iDataRows(i), iCols(j))
- Next j
- Next i
- '--------------------------------------------------读取数据信息完成-------------------------------------------------
- '--------------------------------------------------计算打印信息-------------------------------------------------
- '计算数据行折行信息
- ReDim iColsPerPage(0)
- iColsPerPage(0) = iStartCol
- Dim iWidth As Long
- iWidth = 0
- For i = LBound(iColWidth) + 1 + iStartCol To UBound(iColWidth)
- iWidth = iWidth + iColWidth(i)
- If iWidth > iClientWidth Then
- iWidth = 0
- i = i - 1
- ReDim Preserve iColsPerPage(UBound(iColsPerPage) + 1)
- iColsPerPage(UBound(iColsPerPage)) = i
- End If
- Next i
- If iWidth <> 0 Then
- ReDim Preserve iColsPerPage(UBound(iColsPerPage) + 1)
- iColsPerPage(UBound(iColsPerPage)) = UBound(sData, 2) + 1
- End If
- '计算每页可以打印的行数
- If iSumPerPage = 1 Then
- i = 1
- Else
- i = 0
- End If
- j = UBound(sTitle) + 2
- If iPrintStyle = PRINTSTYLE_ONETITLE Then
- iRowsPerPage = (iClientHeight - iTitleFontHeight - iDataFontHeight - 1000) (UBound(iColsPerPage) * (iDataFontHeight + 100)) - i
- Else
- j = UBound(sTitle) + 2
- iRowsPerPage = (iClientHeight - iTitleFontHeight - iDataFontHeight - 1000) (UBound(iColsPerPage) * j * (iDataFontHeight + 250)) - i
- End If
- If bLimitRowPerPage = True Then
- If iRowsPerPage > iLimitRowsPerPage Then
- iRowsPerPage = iLimitRowsPerPage
- End If
- End If
- '计算分页信息
- ReDim iPages(0)
- iPages(0) = -1
- If iVsSumEndCol = -1 Or iSplitPage = 0 Then '如果没有分页情况,只需判断本页最多能够打印的行数
- For i = LBound(sData) To UBound(sData)
- If i Mod iRowsPerPage = iRowsPerPage - 1 Then
- ReDim Preserve iPages(UBound(iPages) + 1)
- iPages(UBound(iPages)) = i
- End If
- Next i
- Else
- '如果有分页情况,则首先判断是否是分页行,然后循环判断下边的行
- '如果是合计行则加入本页(在数据行数小于可打印行数的情况下)
- For i = LBound(sData) To UBound(sData) '数据行数达到最大行
- If (i - iPages(UBound(iPages))) Mod iRowsPerPage = 0 And i <> 0 Then
- ReDim Preserve iPages(UBound(iPages) + 1)
- iPages(UBound(iPages)) = i
- If Len(sData(i, iVsSumEndCol)) >= 3 Then
- s = Right(sData(i, iVsSumEndCol), 3)
- Else
- s = ""
- End If
- If s = "合计:" Or s = "小计:" Then
- bSumRow = True
- End If
- Else '合计分页
- If Len(sData(i, iVsSumEndCol)) >= 3 Then
- s = Right(sData(i, iVsSumEndCol), 3)
- Else
- s = ""
- End If
- If s = "合计:" Or s = "小计:" Or bSumRow = True Then
- bNext = False
- bSumRow = False
- If iVsSumEndCol = 0 Then
- ReDim Preserve iPages(UBound(iPages) + 1)
- iPages(UBound(iPages)) = i
- Else
- For j = iVsSumEndCol To iVsBeginCol + 1 Step -1
- If Len(sData(i + 1, j - 1)) >= 3 Then
- s = Right(sData(i + 1, j - 1), 3)
- Else
- s = ""
- End If
- If s = "合计:" Or s = "小计:" Then
- bNext = True
- i = i + 1
- '如果当前行达到最大行,分页
- If (i - iPages(UBound(iPages))) Mod iRowsPerPage = 0 Then
- ReDim Preserve iPages(UBound(iPages) + 1)
- iPages(UBound(iPages)) = i
- bNext = False
- End If
- End If
- Next j
- '如果到了第0列,分页
- If j = iVsBeginCol Then
- ReDim Preserve iPages(UBound(iPages) + 1)
- iPages(UBound(iPages)) = i
- End If
- End If
- '因为如果bNext=true 则数据行多移动了一行,减去
- If bNext = True Then
- i = i - 1
- End If
- '判断起始列的合计情况
- bNext = False
- Do While True
- If i < UBound(sData) Then
- If Len(sData(i + 1, iVsBeginCol)) >= 3 Then
- s = Right(sData(i + 1, iVsBeginCol), 3)
- Else
- s = ""
- End If
- If s = "小计:" Or s = "合计:" Then
- i = i + 1
- bNext = True
- Else
- Exit Do
- End If
- Else
- Exit Do
- End If
- Loop
- If bNext = True Then
- ReDim Preserve iPages(UBound(iPages) + 1)
- iPages(UBound(iPages)) = i
- End If
- End If
- End If
- Next i
- End If
- '剩下的行也要占一页
- If iPages(UBound(iPages)) <> UBound(sData) Then
- ReDim Preserve iPages(UBound(iPages) + 1)
- iPages(UBound(iPages)) = UBound(sData)
- End If
- End With
- ' 如果某页的行数为0则删除列,上面的分页程序繁琐,有时候会造成某页的数据行为0
- ' 的情况,在此进行处理,有必要重新考虑分页的程序结构???
- Dim iPagesB() As Long
- ReDim iPagesB(0)
- iPagesB(0) = iPages(0)
- For i = 1 To UBound(iPages)
- If iPages(i) <> iPages(i - 1) Then
- ReDim Preserve iPagesB(UBound(iPagesB) + 1)
- iPagesB(UBound(iPagesB)) = iPages(i)
- End If
- Next i
- ReDim iPages(UBound(iPagesB))
- iPages = iPagesB
- '合计每行的数据形成本页合计
- Dim sTotal() As String
- ReDim sTotal(0, 0)
- If iSumPerPage = 1 Then
- If UBound(iPages) >= 1 Then
- ReDim sTotal(UBound(iPages) - 1, UBound(sData, 2))
- For i = 0 To UBound(sTotal) '行
- For j = LBound(iCols) + 1 To UBound(iCols) '列
- If iColType(j) = DATA_NUMERIC Then
- For n = iPages(i) + 1 To iPages(i + 1)
- bNext = False
- '合计行的信息不加入本页合计
- For m = iVsBeginCol To IIf(iVsSumEndCol = -1, 0, iVsSumEndCol)
- If Len(sData(n, m)) >= 3 Then
- s = Right(sData(n, m), 3)
- Else
- s = ""
- End If
- If s = "合计:" Or s = "小计:" Then
- bNext = True
- Exit For
- End If
- Next m
- If bNext = False Then
- sTotal(i, j - 1) = Val(sTotal(i, j - 1)) + Val(Replace(sData(n, j - 1), ",", ""))
- End If
- Next n
- End If
- Next j
- Next i
- End If
- End If
- '格式化合计信息
- bNext = False
- If iShowAllCols = 0 Then
- For i = LBound(sData) To UBound(sData)
- If bNext = True Then
- Exit For
- End If
- For j = iVsSumEndCol To LBound(sData, 2) Step -1
- If Len(sData(i, j)) >= 3 Then
- s = Right(sData(i, j), 3)
- Else
- s = ""
- End If
- If s = "小计:" Then
- If i - 1 >= 0 Then
- sData(i, iVsSumEndCol + 1) = Replace(sData(i - 1, j), s, "") & s
- Else
- bNext = True
- Exit For
- End If
- End If
- If sData(i, j) = "合计:" Then
- sData(i, iVsSumEndCol + 1) = "合计:"
- End If
- Next j
- Next i
- End If
- If bNext = True Then
- For i = LBound(sData) To UBound(sData)
- For j = iVsSumEndCol To LBound(sData, 2) Step -1
- If sData(i, j) <> "" Then
- If sData(i, j) = "合计:" Then
- sData(i, iVsSumEndCol + 1) = sData(i, j)
- Else
- sData(i, iVsSumEndCol + 1) = Replace(sData(i, j), "小计:", "") & "小计:"
- End If
- Exit For
- End If
- Next j
- Next i
- End If
- '--------------------------------------------------计算打印信息完毕-------------------------------------------------
- '--------------------------------------------------打印数据-------------------------------------------------
- '输送数据
- Dim dy As Long
- dy = 0
- With DY_Tybbyldy.Tydy
- .StartDoc
- For i = LBound(iPages) + 1 To UBound(iPages)
- .FontName = sTitleFontName
- .FontSize = iTitleFontSize
- .CalcText = sRTitle
- .CurrentX = (iClientWidth - .TextWid) / 2 + iPageLeft
- .CurrentY = iPageTop
- DY_Tybbyldy.Tydy = sRTitle
- .CurrentX = (iClientWidth - .TextWid) / 2 + iPageLeft - 500
- .CurrentY = .CurrentY + 100
- .CalcText = sRTitle
- .DrawLine .CurrentX, .CurrentY, (iClientWidth + .TextWid) / 2 + iPageLeft + 500, .CurrentY
- .CurrentY = .CurrentY + 200
- .CurrentX = .MarginLeft
- .FontName = sDataFontName
- .FontSize = iDataFontSize
- dy = .CurrentY
- '打印分组信息
- If iSplitPage = 1 And iVsSumEndCol <> -1 Then
- If Len(sData(iPages(i - 1) + 1, iVsSumEndCol)) >= 3 Then
- If Right(sData(iPages(i - 1) + 1, iVsSumEndCol), 3) = "小计:" Then
- If iPages(i - 1) >= 0 Then
- DY_Tybbyldy.Tydy = sTitle(UBound(sTitle), iVsSumEndCol) & ":" & sData(iPages(i - 1) + 1 - 1, iVsSumEndCol) & Space(10) & sSubTitle
- End If
- Else
- DY_Tybbyldy.Tydy = sTitle(UBound(sTitle), iVsSumEndCol) & ":" & sData(iPages(i - 1) + 1, iVsSumEndCol) & Space(10) & sSubTitle
- End If
- Else
- DY_Tybbyldy.Tydy = sTitle(UBound(sTitle), iVsSumEndCol) & ":" & sData(iPages(i - 1) + 1, iVsSumEndCol) & Space(10) & sSubTitle
- End If
- Else
- DY_Tybbyldy.Tydy = sSubTitle
- End If
- .CurrentX = .PageWidth - .MarginRight - .TextWidth("第100页 共100页 ")
- .CurrentY = dy
- DY_Tybbyldy.Tydy = "第" & i & "页 共" & UBound(iPages) & "页 "
- If iPrintStyle = PRINTSTYLE_ONETITLE Then '只输出一个表头
- For j = LBound(iColsPerPage) + 1 To UBound(iColsPerPage)
- .CurrentX = .MarginLeft
- .CurrentY = .CurrentY + 100
- .StartTable
- '设置表格属性
- .TableCell(tcRows) = iPages(i) - iPages(i - 1) + UBound(sTitle) + 1
- .TableCell(tcCols) = iColsPerPage(j) - iColsPerPage(j - 1)
- For m = 1 To .TableCell(tcRows) '行高
- .TableCell(tcRowHeight, m) = iDataFontHeight + 100
- Next m
- For m = 1 To .TableCell(tcCols) '列宽
- .TableCell(tcColWidth, , m) = iColWidth(m + iColsPerPage(j - 1))
- Next m
- '填充表头
- For m = 1 To UBound(sTitle) + 1
- For k = 1 To .TableCell(tcCols)
- .TableCell(tcAlign, m, k) = 6
- .TableCell(tcText, m, k) = Trim(sTitle(m - 1, k + iColsPerPage(j - 1) - 1))
- .CalcText = .TableCell(tcText, m, k)
- If (.TableCell(tcColWidth, , k) - .TextWid - 100) > 0 Then
- .TableCell(tcText, m, k) = Space((.TableCell(tcColWidth, , k) - .TextWid - 100) / .TextWidth("测试")) & .TableCell(tcText, m, k)
- End If
- Next k
- Next m
- '填充数据
- For m = UBound(sTitle) + 1 + 1 To .TableCell(tcRows)
- For k = 1 To .TableCell(tcCols)
- If iColType(k + iColsPerPage(j - 1)) = DATA_NUMERIC Then
- .TableCell(tcAlign, m, k) = 8 'RightMiddle
- Else
- .TableCell(tcAlign, m, k) = 6 'LeftMiddle
- End If
- If Len(sData(m + iPages(i - 1) - 1, k + iColsPerPage(j - 1) - 1)) >= 3 Then
- If Right(sData(m + iPages(i - 1) - 1, k + iColsPerPage(j - 1) - 1), 3) <> "小计:" And _
- Right(sData(m + iPages(i - 1) - 1, k + iColsPerPage(j - 1) - 1), 3) <> "合计:" Then
- s = sData(m + iPages(i - 1) - 1, k + iColsPerPage(j - 1) - 1)
- End If
- End If
- If Trim(iColFormat(k + iColsPerPage(j - 1))) = "" Then
- .TableCell(tcText, m, k) = sData(m + iPages(i - 1) - 1, k + iColsPerPage(j - 1) - 1)
- Else
- .TableCell(tcText, m, k) = Format(sData(m + iPages(i - 1) - 1, k + iColsPerPage(j - 1) - 1), iColFormat(k + iColsPerPage(j - 1)))
- End If
- Next k
- Next m
- '填充合计信息
- If iSumPerPage = 1 And UBound(sTotal) > 0 Then
- .TableCell(tcRows) = .TableCell(tcRows) + 1
- .TableCell(tcRowHeight, .TableCell(tcRows)) = iDataFontHeight + 100
- For k = 1 To .TableCell(tcCols)
- If iColType(k + iColsPerPage(j - 1)) = DATA_NUMERIC Then
- .TableCell(tcAlign, .TableCell(tcRows), k) = 8 'RightMiddle
- Else
- .TableCell(tcAlign, .TableCell(tcRows), k) = 6 'LeftMiddle
- End If
- .TableCell(tcText, .TableCell(tcRows), k) = Format(sTotal(i - 1, k + iColsPerPage(j - 1) - 1), iColFormat(k + iColsPerPage(j - 1)))
- Next k
- If j = 1 Then
- .TableCell(tcText, .TableCell(tcRows), 1) = "本页小计:"
- End If
- End If
- .EndTable
- Next j
- Else '每行数据输出表头
- For n = iPages(i - 1) + 1 To iPages(i) 'n为数据行
- For j = LBound(iColsPerPage) + 1 To UBound(iColsPerPage) 'j为一个数据行分的断
- .CurrentX = .MarginLeft
- .CurrentY = .CurrentY + 100
- .StartTable
- '设置表格属性
- .TableCell(tcRows) = UBound(sTitle) + 1 + 1
- .TableCell(tcCols) = iColsPerPage(j) - iColsPerPage(j - 1)
- For m = 1 To .TableCell(tcRows) '行高
- .TableCell(tcRowHeight, m) = iDataFontHeight + 100
- Next m
- For m = 1 To .TableCell(tcCols) '列宽
- .TableCell(tcColWidth, , m) = iColWidth(m + iColsPerPage(j - 1))
- Next m
- '填充表头
- For m = 1 To UBound(sTitle) + 1
- For k = 1 To .TableCell(tcCols)
- .TableCell(tcAlign, m, k) = 6
- .TableCell(tcText, m, k) = Trim(sTitle(m - 1, k + iColsPerPage(j - 1) - 1))
- .CalcText = .TableCell(tcText, m, k)
- If (.TableCell(tcColWidth, , k) - .TextWid - 100) > 0 Then
- .TableCell(tcText, m, k) = Space((.TableCell(tcColWidth, , k) - .TextWid - 100) / .TextWidth("测试")) & .TableCell(tcText, m, k)
- End If
- Next k
- Next m
- '填充数据
- For k = 1 To .TableCell(tcCols)
- If iColType(k + iColsPerPage(j - 1)) = DATA_NUMERIC Then
- .TableCell(tcAlign, m, k) = 8 'RightMiddle
- Else
- .TableCell(tcAlign, m, k) = 6 'LeftMiddle
- End If
- If Trim(iColFormat(k + iColsPerPage(j - 1) - 1)) = "" Then
- .TableCell(tcText, .TableCell(tcRows), k) = sData(n, k + iColsPerPage(j - 1) - 1)
- Else
- .TableCell(tcText, .TableCell(tcRows), k) = Format(sData(n, k + iColsPerPage(j - 1) - 1), iColFormat(k + iColsPerPage(j - 1) - 1))
- End If
- Next k
- .EndTable
- Next j
- '如果不是本页的最后一行并且后边没有本业合计,添加分隔线
- If n <> iPages(i) Or iSumPerPage = 1 Then
- .CurrentY = .CurrentY + 200
- .CurrentX = .MarginLeft
- .PenStyle = psDash
- .DrawLine .CurrentX, .CurrentY, .PageWidth - .MarginRight, .CurrentY
- .PenStyle = psSolid
- End If
- Next n
- '添加本页合计信息
- If iSumPerPage = 1 Then
- For j = LBound(iColsPerPage) + 1 To UBound(iColsPerPage) 'j为一个数据行分的断
- .CurrentX = .MarginLeft
- .CurrentY = .CurrentY + 100
- .StartTable
- '设置表格属性
- .TableCell(tcRows) = UBound(sTitle) + 1 + 1
- .TableCell(tcCols) = iColsPerPage(j) - iColsPerPage(j - 1)
- For m = 1 To .TableCell(tcRows) '行高
- .TableCell(tcRowHeight, m) = iDataFontHeight + 100
- Next m
- For m = 1 To .TableCell(tcCols) '列宽
- .TableCell(tcColWidth, , m) = iColWidth(m + iColsPerPage(j - 1))
- Next m
- '填充表头
- For m = 1 To UBound(sTitle) + 1
- For k = 1 To .TableCell(tcCols)
- .TableCell(tcAlign, m, k) = 6
- .TableCell(tcText, m, k) = Trim(sTitle(m - 1, k + iColsPerPage(j - 1) - 1))
- .CalcText = .TableCell(tcText, m, k)
- If (.TableCell(tcColWidth, , k) - .TextWid - 100) > 0 Then
- .TableCell(tcText, m, k) = Space((.TableCell(tcColWidth, , k) - .TextWid - 100) / .TextWidth("测试")) & .TableCell(tcText, m, k)
- End If
- Next k
- Next m
- '填充数据
- For k = 1 To .TableCell(tcCols)
- If iColType(k + iColsPerPage(j - 1)) = DATA_NUMERIC Then
- .TableCell(tcAlign, m, k) = 8 'RightMiddle
- Else
- .TableCell(tcAlign, m, k) = 6 'LeftMiddle
- End If
- .TableCell(tcText, .TableCell(tcRows), k) = Format(sTotal(i - 1, k + iColsPerPage(j - 1) - 1), iColFormat(k + iColsPerPage(j - 1)))
- Next k
- If j = LBound(iColsPerPage) + 1 Then
- .TableCell(tcText, .TableCell(tcRows), 1) = "本页小计:"
- End If
- .EndTable
- Next j
- End If
- End If
- If i <> UBound(iPages) Then
- .NewPage
- End If
- Next i
- .EndDoc
- DY_Tybbyldy.PageHScroll.Max = .Pagecount
- DY_Tybbyldy.PageHScroll.Min = 1
- DY_Tybbyldy.PageHScroll.Value = 1
- End With
- If bPrint = False Then
- DY_Tybbyldy.Show 1
- Else
- DY_Tybbyldy.Tydy.PrintDoc
- End If
- Exit Function
- ErrCtrl:
- If rs.State = 1 Then
- rs.Close
- End If
- Set rs = Nothing
- End Function
- Public Function SetupPage(frmSetup As DY_Dyymsz, frmPrint As DY_Tybbyldy) As Boolean '打印设置
- Dim Tsxx As String
- Dim Papername(1 To 70) As String
- Papername(1) = "Letter, 8 1/2 x 11 英寸"
- Papername(2) = "Letter Small, 8