上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:74k
源码类别:

企业管理

开发平台:

Visual Basic

  1. Attribute VB_Name = "XtjbModule"
  2. '系统基本模块(主要用来放置公用函数及模块)
  3.                 
  4. '系统信息
  5. Public XtMenuList As String    '系统菜单功能编码
  6. '系统日期
  7. Public Xtkjqjgs As Integer     '用户设定会计期间个数
  8. Public Xtyear As Integer       '用户进入系统选择年度
  9. Public Xtmm As Integer         '用户进入系统选择会计期间
  10. Public Xtrq As Date            '系统日期
  11. Public Xtrlbz As String        '系统日历标志
  12. '系统往返参数值
  13. Public Xtcdcs As String        '系统传递参数值(专门用来传递帮助信息)
  14. Public Xtcdcsfz As String      '系统传递参数值(辅助信息)
  15. Public Xtfhcs As String        '系统返回参数值(专门用来传递帮助信息)
  16. Public Xtfhcsfz As String      '系统返回参数值(辅助信息)
  17. '系统通用编码参照代码
  18. Public Xtbmczdm As String      '系统通用编码参照代码
  19. '(系统等待调用窗体)
  20. Public XtCxgnsm As String      '调用程序功能说明
  21. Public Xtczy As String         '系统使用操作员
  22. Public Xtczybm As String       '系统操作员编码
  23. Public Xtztbm As String        '系统帐套编码
  24. Public Xtdwm As String         '系统打开帐套单位
  25. '帐套基本参数
  26. Public Xtjezws As Integer      '金额总位数
  27. Public Xtslzws As Integer      '数量总位数
  28. Public Xtdjzws As Integer      '单价总位数
  29. Public Xtjexsws As Integer     '金额小数位数
  30. Public Xtslxsws As Integer     '数量小数位数
  31. Public Xtdjxsws As Integer     '单价小数位数
  32. Public XtSCurrCode As String   '本位币编码
  33. Public XtSCurrName As String   '本位币名称
  34. '其它全局变量
  35. Public Unload_TF As Boolean    '窗体是否卸载
  36. Public P_RecordCount As Integer '记录条数
  37. Public YesNo_str As String
  38. Public SsqlHelp As String
  39. Public P_Code As String: Public P_Name As String  '编码、名称
  40. Public AddExit_TF As Boolean '添加或编辑状态
  41. Public P_Ssql As String  'Sql 语句
  42. '系统传递单据ID
  43. Public XT_BillID As Long
  44. '引用API函数
  45. Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  46. Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  47. '======================以下为打印文本内容格式输出控制过程函数======================='
  48. Public Function Fun_FormatOutPut(InputText As String, OutPutLen As Integer) As String               '文本内容按一定标准格式输出(主要用于打印使用)
  49.   
  50.     '参数说明:InputText 需要格式化的文本内容 OutPutLen 输出文本占用长度(包括加空格)
  51.     Fun_FormatOutPut = Trim(InputText) + Space(OutPutLen - Strcdcs(Trim(InputText), OutPutLen))
  52.   
  53. End Function
  54. Public Function Strcdcs(Lrcsstr As String, Lrzdcd As Integer) As Integer                            '测量并限制字符串长度(汉字与字符区分)
  55.    
  56.     '参数说明:Lrcsstr 需要测量和限制输出的字符串 Lrzdcd 限制输出长度
  57.   
  58.     lrtextlong = Len(Trim(Lrcsstr))
  59.     lrcscd = 0
  60.     For Jsqte = 1 To lrtextlong
  61.         lrcszf = Mid(Lrcsstr, Jsqte, 1)
  62.         lrzzcd = lrcscd
  63.         If Asc(lrcszf) >= 0 And Asc(lrcszf) <= 255 Then
  64.             lrcscd = lrcscd + 1
  65.         Else
  66.             lrcscd = lrcscd + 2
  67.         End If
  68.         If lrcscd > Lrzdcd Then
  69.             lrstrjqcd = Jsqte - 1
  70.             Lrcsstr = Mid(Lrcsstr, 1, lrstrjqcd)
  71.             Strcdcs = lrzzcd
  72.             Exit Function
  73.         Else
  74.             Strcdcs = lrcscd
  75.         End If
  76.     Next Jsqte
  77. End Function
  78. '======================以下为文本录入内容格式输入控制过程函数======================='
  79. Public Sub Lrfzszxz(Sjwb As TextBox, lrzfasc As Integer)              '文本框录入整数值(负)限制
  80.    
  81.     '输入参数:sjwb 录入限制文本框 lrzfasc 用户录入字符Ascii码值
  82.     If Not ((lrzfasc >= Asc("0") And lrzfasc <= Asc("9")) Or lrzfasc = vbKeyBack Or (Chr(lrzfasc) = "-" And Sjwb.SelStart = 0)) Then
  83.         lrzfasc = 0
  84.     End If
  85. End Sub
  86. Public Sub Lrzszxz(lrzfasc As Integer)                                '文本框录入整数值(正)限制
  87.     '输入参数:lrzfasc 用户录入字符Ascii码值
  88.     If Not ((lrzfasc >= Asc("0") And lrzfasc <= Asc("9")) Or lrzfasc = vbKeyBack) Then
  89.         lrzfasc = 0
  90.     End If
  91. End Sub
  92. Public Sub Lrszzfxz(lrzfasc As Integer)                               '文本框录入数字及字符限制
  93.     
  94.     '输入参数:lrzfasc 用户录入字符Ascii码值
  95.     If Not ((lrzfasc >= Asc("0") And lrzfasc <= Asc("9")) Or (lrzfasc >= Asc("a") And lrzfasc <= Asc("z")) Or (lrzfasc >= Asc("A") And lrzfasc <= Asc("Z")) Or lrzfasc = vbKeyBack) Then
  96.         lrzfasc = 0
  97.     End If
  98. End Sub
  99. Public Sub Lrfhzxz(lrzfasc As Integer)                                '文本框录入非汉字限制
  100.     
  101.     '输入参数:lrzfasc 用户录入字符Ascii码值
  102.     If Not ((lrzfasc >= 0 And lrzfasc <= 255) Or lrzfasc = vbKeyBack) Then
  103.         lrzfasc = 0
  104.     End If
  105. End Sub
  106. Public Sub Lrrqxz(lrzfasc As Integer)                                 '文本框录入日期限制
  107.     
  108.     '输入参数:lrzfasc 用户录入字符Ascii码值
  109.     If Not ((lrzfasc >= Asc("0") And lrzfasc <= Asc("9")) Or Chr(lrzfasc) = "-" Or lrzfasc = vbKeyBack) Then
  110.         lrzfasc = 0
  111.     End If
  112.     
  113. End Sub
  114. Public Sub Lrxszxz(Sjwb As TextBox, lrzfasc As Integer)               '文本框录入带有小数位及正负号数值字段
  115.   
  116.     If Not ((Chr(lrzfasc) >= "0" And Chr(lrzfasc) <= "9") Or (Chr(lrzfasc) = "." And InStr(1, Sjwb.Text, ".") = 0) Or lrzfasc = vbKeyBack Or (Chr(lrzfasc) = "-" And Sjwb.SelStart = 0)) Then
  117.         lrzfasc = 0
  118.     End If
  119. End Sub
  120. Public Sub Lrxzszxz(Sjwb As TextBox, lrzfasc As Integer)              '文本框录入带有小数位正>=0数值字段
  121.     
  122.     If Not ((Chr(lrzfasc) >= "0" And Chr(lrzfasc) <= "9") Or (Chr(lrzfasc) = "." And InStr(1, Sjwb.Text, ".") = 0) Or lrzfasc = vbKeyBack) Then
  123.         lrzfasc = 0
  124.     End If
  125. End Sub
  126. Public Sub Sjgskz(Sjwb As TextBox, zsws As Integer, xsws As Integer)  '保证数值录入字段录入格式
  127.     '输入参数:sjwb 录入限制文本框 zsws 数值录入限制整数位数 xsws 数值录入限制小数位数
  128.    
  129.    Dim bccrd%
  130.    Dim Ws, Zswstr, Xswstr As String
  131.    Dim B_fu As Boolean
  132.    Dim sjzws As Integer
  133.    bccrd = Sjwb.SelStart
  134.    B_fu = False
  135.    
  136.     Ws = InStr(1, Sjwb, "-")
  137.     If Ws > 0 Then Sjwb = Mid(Sjwb, Ws)
  138.    If Left(Sjwb, 1) = "-" Then
  139.       B_fu = True
  140.       zsws = zsws - 1
  141.       Zswstr = Mid(Sjwb, 2)
  142.    Else
  143.       Zswstr = Mid(Sjwb, 1)
  144.    End If
  145.    
  146.    Ws = InStr(1, Zswstr, ".")                   '整数位数+1
  147.    
  148.     If Ws > 0 Then
  149.         If zsws > Ws - 1 Then
  150.             Zswstr = Mid(Zswstr, 1, Ws - 1) + Mid(Zswstr, Ws, xsws + 1)
  151.         Else
  152.             Zswstr = Mid(Zswstr, 1, zsws) + Mid(Zswstr, Ws, xsws + 1)
  153.             Ws = InStr(1, Zswstr, ".")                   '整数位数+1
  154.         End If
  155.         Ws = Len(Zswstr) - Ws                   '小数位数
  156.         If Left(Zswstr, 1) = "." Then
  157.             bccrd = bccrd + 1
  158.             Zswstr = "0" & Zswstr
  159.         End If
  160.         If Ws < xsws Then
  161.            Zswstr = Format(Zswstr, "#0." + String(Ws, "0"))
  162.         Else
  163.            Zswstr = Format(Zswstr, "#0." + String(xsws, "0"))
  164.         End If
  165.    Else
  166.       Zswstr = Mid(Zswstr, 1, zsws)
  167.       Zswstr = Format(Zswstr)
  168.    End If
  169.    
  170.    If B_fu Then Zswstr = "-" & Zswstr
  171.    Sjwb = Zswstr
  172.    Sjwb.SelStart = bccrd
  173. End Sub
  174. Public Sub InputFieldLimit(Ydtextte As TextBox, Zdsjlxte As Integer, KeyAsciite As Integer)     '录入字段事中控制程序
  175.     '函数参数:录入限制文本框,字段数据类型,录入字符
  176.     Select Case Zdsjlxte
  177.         Case 1                                  '1-录入(Ascii0-255)
  178.             Call Lrfhzxz(KeyAsciite)
  179.         Case 2
  180.             Call Lrszzfxz(KeyAsciite)             '2-录入(0-9,a-z,A-Z)
  181.         Case 3
  182.             Call Lrfzszxz(Ydtextte, KeyAsciite)   '3-录入整数值(正负)
  183.         Case 4
  184.             Call Lrzszxz(KeyAsciite)              '4-录入整数值(正)
  185.         Case 5, 8, 9
  186.             Call Lrxszxz(Ydtextte, KeyAsciite)    '5-录入小数值(正负) 8-金额型(正负) 9-数量型(正负)
  187.         Case 6, 10, 11, 12
  188.             Call Lrxzszxz(Ydtextte, KeyAsciite)   '6-录入小数值(正) 10-单价型 11-金额型(正) 12-数量型(正)
  189.         Case 7
  190.             Call Lrrqxz(KeyAsciite)               '7-录入日期
  191.     End Select
  192. End Sub
  193. Public Sub TextChangeLimit(Ydtextte As TextBox, Zdsjlxte As Integer)      '文本框字段录入控制(事后、防止用户采用粘贴录入)
  194.     '函数参数:录入限制文本框,字段数据类型
  195.     
  196.     Dim Str_JudgeStr As String      '判断字符
  197.     Dim Jsqte As Integer            '临时使用计数器
  198.     Dim Str_Result As String        '结果字符串
  199.     Dim KeyAsciite As Integer
  200.     
  201.     Str_Result = ""
  202.     
  203.     For Jsqte = 1 To Len(Trim(Ydtextte.Text))
  204.         Str_JudgeStr = Mid(Trim(Ydtextte.Text), Jsqte, 1)
  205.         KeyAsciite = Asc(Str_JudgeStr)
  206.     
  207.         If Str_JudgeStr = "'" Then
  208.            Str_JudgeStr = ""
  209.         End If
  210.         
  211.         Select Case Zdsjlxte
  212.             Case 1                                           '1-录入(Ascii0-255)
  213.                 Call Lrfhzxz(KeyAsciite)
  214.                 If KeyAsciite = 0 Then
  215.                    Str_JudgeStr = ""
  216.                 End If
  217.             Case 2
  218.                 Call Lrszzfxz(KeyAsciite)                    '2-录入(0-9,a-z,A-Z)
  219.                 If KeyAsciite = 0 Then
  220.                    Str_JudgeStr = ""
  221.                 End If
  222.             Case 4, 6, 10, 11, 12
  223.                 If Str_JudgeStr = "-" Then                   '录入数值(正)
  224.                    Str_JudgeStr = ""
  225.                 End If
  226.         End Select
  227.         Str_Result = Str_Result + Str_JudgeStr
  228.      Next Jsqte
  229.      
  230.      If Str_Result <> Trim(Ydtextte.Text) Then
  231.         Ydtextte.Text = Str_Result
  232.         Ydtextte.SelStart = Len(Ydtextte.Text)
  233.      End If
  234. End Sub
  235. '==============================================================================='
  236. Public Function Xtxxts(xttsxx As String, xttslb As Integer, Tbtslb As Integer)          '系统信息提示
  237.     
  238.     msgtitle = "百利/ERP5.0-质量系统"
  239.     Select Case xttslb
  240.         Case 0    '确定
  241.             Xtxxts = MsgBox(xttsxx, Tbtslb * 16, msgtitle)
  242.         Case 1    'YES/NO
  243.            Xtxxts = MsgBox(xttsxx, vbYesNo + Tbtslb * 16, msgtitle)
  244.         Case 2    '确定/取消
  245.            Xtxxts = MsgBox(xttsxx, vbOKCancel + Tbtslb * 16, msgtitle)
  246.         Case Else
  247.            Xtxxts = "9"
  248.     End Select
  249. End Function
  250. Public Function Kjjdzy(Zyjdzs As Integer) As Boolean                                    '控件焦点转移(针对回车键)
  251.     
  252.     Kjjdzy = False
  253.     
  254.     On Error GoTo Cwcl
  255.     
  256.     If Screen.ActiveControl.TabIndex <= Zyjdzs - 1 Then
  257.         Kjjdzy = True
  258.         SendKeys "{tab}"
  259.     End If
  260.     Exit Function
  261. Cwcl:
  262.     Resume Next         '有些对象不支持TabIndex属性
  263. End Function
  264. Public Sub Pbwxzf(Zfc As Integer)                                                       '录入时屏蔽"'"
  265.     
  266.     If Chr(Zfc) = "'" Then
  267.         Zfc = 0
  268.     End If
  269. End Sub
  270. '======================以下为对网格操作基本函数========================'
  271. Public Sub BzWgcsh(Xsgrid As vsFlexGrid, Wgdmte As String, GridInf() As Variant, GridBoolean() As Boolean, GridInt() As Integer, GridStr() As String)          '标准网格初始化模块
  272.   
  273.     '过程参数为:Xsgrid 生成网格对象名称,Wgdmte 网格参数编码,GridInf()返回网格设置信息(返回整体信息)
  274.     'GridBoolean() 网格列属性(返回布尔型信息),GridInt() 网格列属性(返回整型信息),GridStr() 网格列属性(返回字符型信息)
  275.       
  276.     Dim wglbt() As String                      '网格显示列标题
  277.     Dim Wgxsls As Long                         '网格显示(主操作)列数
  278.     Dim gdls As Long                           '网格固定列数
  279.     Dim Gdhs As Long                           '网格固定行数(标题行数)
  280.     Dim Gdhgd As Double                        '网格固定行高度
  281.     Dim wglkd() As Double                      '每列默认字符个数
  282.     Dim wglzz() As Integer                     '网格列组织形式
  283.     Dim zdxsgs() As String                     '数值字段显示格式
  284.     Dim Sfhide() As Boolean                    '网格列是否隐藏
  285.     Dim Sfhxz As Boolean                       '网格列是否行选中
  286.     Dim Qslz As Long                           '网格隐藏(非操作显示)列数
  287.     Dim Sjhgd As Double                        '网格数据行高度
  288.     Dim Wglsfkydpx As Integer                  '网格列是否可移动及排序
  289.     Dim wgxsrec As New ADODB.Recordset         '网格显示动态集
  290.     
  291.     ReDim GridInf(1 To 7)                      '整个网格设置信息
  292.     Set wgxsrec = Cw_DataEnvi.DataConnect.Execute("SELECT * FROM xt_grid WHERE Grid_Code ='" + Wgdmte + "' ORDER BY ColId")
  293.     With wgxsrec
  294.         If .EOF And .BOF Then
  295.             Exit Sub
  296.         Else
  297.             .MoveFirst
  298.         End If
  299.    
  300.         '如果网格为单据则设置网格大小、位置
  301.         If .Fields("GridType") = 1 Then
  302.             Xsgrid.Height = .Fields("GridHeight") '网格高度
  303.             Xsgrid.Width = .Fields("Gridwidth")   '网格宽度
  304.             Xsgrid.Top = .Fields("GridTop")       '网格上边距
  305.             Xsgrid.Left = .Fields("GridLeft")     '网格左边距
  306.         End If
  307.    
  308.         Qslz = .Fields("BeginCol")                '网格隐藏(非操作显示)列数
  309.         Sjhgd = .Fields("DataRowHeight")          '网格数据行高度
  310.    
  311.         GridInf(1) = Qslz                         '起始列值
  312.         GridInf(2) = Sjhgd                        '数据行高度
  313.         GridInf(3) = .Fields("KeepDataRows")      '屏幕保持数据行数
  314.         GridInf(4) = .Fields("AssistantRows")     '辅助项网格行数(例如:合计行)
  315.         If .Fields("SaveHelpWidth_Flag") Then     '是否保留帮助宽度(字段提供帮助时,是否为按钮保留空间)
  316.             GridInf(5) = True
  317.         Else
  318.             GridInf(5) = False
  319.         End If
  320.         If .Fields("DeleteRowAsk_Flag") Then      '删除有效记录行是否提示
  321.             GridInf(6) = True
  322.         Else
  323.             GridInf(6) = False
  324.         End If
  325.         If .Fields("ShowSumGrid_Flag") Then       '是否显示合计网格
  326.             GridInf(7) = True
  327.         Else
  328.             GridInf(7) = False
  329.         End If
  330.       
  331.         Wgxsls = .RecordCount - 1                 '网格显示(主操作)列数(原.Fields("wgxsls"))
  332.         gdls = .Fields("FixCols")                 '网格固定列数
  333.         Gdhs = .Fields("FixRows")                 '网格固定行数(标题行数)
  334.         Gdhgd = .Fields("FixRowHeight")           '网格固定行高度
  335.         Wglsfkydpx = .Fields("explorerbar")       '网格列是否可移动及排序
  336.    
  337.         If .Fields("SelectRow_Flag") Then         '是否行选中
  338.             Sfhxz = True
  339.         End If
  340.    
  341.         ReDim wglbt(Gdhs - 1, Wgxsls + Qslz - 1)  '网格显示列标题
  342.         ReDim wglkd(Qslz + Wgxsls - 1)            '每列默认字符个数
  343.         ReDim zdxsgs(Qslz + Wgxsls - 1)           '数值字段标志
  344.         ReDim wglzz(Qslz + Wgxsls - 1)            '网格列组织形式
  345.         ReDim Sfhide(Qslz + Wgxsls - 1)           '网格列是否显示
  346.         ReDim GridBoolean(Qslz + Wgxsls - 1, 1 To 6)   '网格列属性(布尔型)
  347.         ReDim GridStr(Qslz + Wgxsls - 1, 1 To 20)      '网格列信息(字符型)
  348.         ReDim GridInt(Qslz + Wgxsls - 1, 1 To 7)       '网格列信息(整型)
  349.    
  350.         .MoveNext
  351.         Jsqte = 0
  352.         
  353.         Do While Not .EOF
  354.             wglkd(Qslz + Jsqte) = .Fields("ColWidth")                  '网格列宽度限制
  355.             If Not IsNull(.Fields("ColTitle1")) Then
  356.                 wglbt(0, Qslz + Jsqte) = Trim(.Fields("ColTitle1"))      '网格列标题1
  357.             End If
  358.             If Not IsNull(.Fields("ColTitle2")) And Gdhs >= 2 Then     '网格列标题2
  359.                 wglbt(1, Qslz + Jsqte) = Trim(.Fields("ColTitle2"))
  360.             End If
  361.             If Not IsNull(.Fields("ColTitle3")) And Gdhs >= 3 Then     '网格列标题3
  362.                 wglbt(2, Qslz + Jsqte) = Trim(.Fields("ColTitle3"))
  363.             End If
  364.             If .Fields("ColFormat") Then                               '字段显示格式(千分符)
  365.                 If .Fields("Text_Int_Length") <> 0 Then
  366.                     zdxsgs(Qslz + Jsqte) = "#,##0." + String(.Fields("Text_deci_Length"), "0")
  367.                 Else
  368.                     zdxsgs(Qslz + Jsqte) = "#,##0.00"
  369.                 End If
  370.                 Select Case .Fields("Text_Data_Type")
  371.                     Case 8, 11  '金额
  372.                         zdxsgs(Qslz + Jsqte) = "#,##0." + String(Xtjexsws, "0")
  373.                     Case 9, 12  '数量
  374.                         zdxsgs(Qslz + Jsqte) = "#,##0." + String(Xtslxsws, "0")
  375.                     Case 10     '单价
  376.                         zdxsgs(Qslz + Jsqte) = "#,##0." + String(Xtdjxsws, "0")
  377.                 End Select
  378.             Else
  379.                 If .Fields("Text_Int_Length") <> 0 Then
  380.                     zdxsgs(Qslz + Jsqte) = "##0." + String(.Fields("Text_deci_Length"), "0")
  381.                 End If
  382.             End If
  383.             wglzz(Qslz + Jsqte) = .Fields("ColAlignment")              '网格列组织形式
  384.             
  385.             If .Fields("ColHidden") Then                               '网格列是否隐藏
  386.                 Sfhide(Qslz + Jsqte) = True
  387.             End If
  388.             If .Fields("Edit_Flag") Then                               '网格列是否可编辑
  389.                 GridBoolean(Qslz + Jsqte, 1) = True
  390.             End If
  391.             If .Fields("Help_Flag") Then                               '网格列是否提供帮助
  392.                 GridBoolean(Qslz + Jsqte, 2) = True
  393.             End If
  394.             If .Fields("Combo_Flag") Then                              '网格列是否列表框录入
  395.                 GridBoolean(Qslz + Jsqte, 3) = True
  396.             End If
  397.             If .Fields("ColSum_Flag") Then                             '网格列是否合计
  398.                 GridBoolean(Qslz + Jsqte, 4) = True
  399.             End If
  400.             If .Fields("Zero_Empty_Flag") Then                         '网格内容为零是否清空
  401.                 GridBoolean(Qslz + Jsqte, 5) = True
  402.             End If
  403.             If .Fields("BooleanFlag") Then                             '网格列是否为布尔型
  404.                 GridBoolean(Qslz + Jsqte, 6) = True
  405.             End If
  406.             If Not IsNull(.Fields("Text_Data_Type")) Then              '字段数据类型
  407.                 GridInt(Qslz + Jsqte, 1) = .Fields("Text_Data_Type")
  408.             End If
  409.             If Not IsNull(.Fields("Text_Length")) Then                 '字段录入长度
  410.                 GridInt(Qslz + Jsqte, 2) = .Fields("Text_Length")
  411.             End If
  412.             If Not IsNull(.Fields("Text_Int_Length")) Then             '字段整数位长度
  413.                 GridInt(Qslz + Jsqte, 3) = .Fields("Text_Int_Length")
  414.             End If
  415.             If Not IsNull(.Fields("Text_Deci_Length")) Then            '字段小数位长度
  416.                 GridInt(Qslz + Jsqte, 4) = .Fields("Text_Deci_Length")
  417.             End If
  418.             If Not IsNull(.Fields("NotAllowEmpty_Type")) Then          '字段不允许为空或为零
  419.                 GridInt(Qslz + Jsqte, 5) = .Fields("NotAllowEmpty_Type")
  420.             End If
  421.             If Not IsNull(.Fields("Help_Type")) Then                   '帮助类型
  422.                 GridInt(Qslz + Jsqte, 6) = .Fields("Help_Type")
  423.             End If
  424.             If Not IsNull(.Fields("HelpReturnValue")) Then             '帮助返回值(0-显示返回编码 1-显示返回名称)
  425.                 GridInt(Qslz + Jsqte, 7) = .Fields("HelpReturnValue")
  426.             End If
  427.             GridStr(Qslz + Jsqte, 1) = Trim(.Fields("ColIndex") & "")    '网格列索引值
  428.             GridStr(Qslz + Jsqte, 2) = Trim(.Fields("EmptyMessage") & "") '字段为空提示信息
  429.             GridStr(Qslz + Jsqte, 3) = Trim(.Fields("Help_Code") & "")    '通用帮助编码
  430.             GridStr(Qslz + Jsqte, 4) = Trim(.Fields("FieldsName") & "")   '连接字段(通用帮助)
  431.             GridStr(Qslz + Jsqte, 5) = Trim(.Fields("Combo_Code") & "")   '列表框编码
  432.     
  433.             .MoveNext
  434.             Jsqte = Jsqte + 1
  435.         Loop
  436.     End With
  437.    
  438.     '网格列组织形式
  439.    
  440.     With Xsgrid
  441.         .BackColorFixed = &H8000000F                                     '固定行背景色
  442.         .Rows = Gdhs
  443.         .FixedRows = Gdhs                                                '固定行数
  444.         .Cols = Qslz + Wgxsls
  445.         .FixedCols = gdls                                                '固定列数
  446.         .AllowUserResizing = flexResizeBoth
  447.         .MergeCells = flexMergeFixedOnly                                 '合并单元形式
  448.         If Sfhxz Then
  449.             .SelectionMode = flexSelectionByRow
  450.         Else
  451.             .FocusRect = flexFocusHeavy
  452.             .ForeColorSel = &H80000008
  453.             .BackColorSel = &H80000005
  454.         End If
  455.         .ExplorerBar = Wglsfkydpx                                        '网格列是否可移动及排序
  456.         .ScrollTips = True
  457.         .WordWrap = True
  458.      
  459.         '填 充 网 格 标 题
  460.         For Rowjsq = 0 To .FixedRows - 1
  461.             .MergeRow(Rowjsq) = True
  462.             .RowHeight(Rowjsq) = Gdhgd
  463.             For Coljsq = Qslzte To .Cols - 1
  464.                 .TextMatrix(Rowjsq, Coljsq) = wglbt(Rowjsq, Coljsq)
  465.                 Next Coljsq
  466.         Next Rowjsq
  467.      
  468.        '数 据 网 格 高 度
  469.        For Rowjsq = .FixedRows To .Rows - 1
  470.            .RowHeight(Rowjsq) = Sjhgd
  471.        Next Rowjsq
  472.        '定 义 录 入 字 段 属 性
  473.        For Coljsq = 0 To .Cols - 1
  474.            If Coljsq < Qslz Or Sfhide(Coljsq) Then
  475.                .ColHidden(Coljsq) = True
  476.            Else
  477.                .ColHidden(Coljsq) = False
  478.            End If
  479.            .MergeCol(Coljsq) = True
  480.            .ColWidth(Coljsq) = wglkd(Coljsq)
  481.            .ColAlignment(Coljsq) = wglzz(Coljsq)
  482.            If Len(zdxsgs(Coljsq)) <> 0 Then
  483.                .ColFormat(Coljsq) = zdxsgs(Coljsq)
  484.            End If
  485.            If GridBoolean(Coljsq, 6) Then
  486.                .ColDataType(Coljsq) = flexDTBoolean
  487.            End If
  488.            .FixedAlignment(Coljsq) = 4
  489.        Next Coljsq
  490.    End With
  491. End Sub
  492. Public Sub Bcwggs(Bcgsgrid As vsFlexGrid, Wggsdm As String, GridStr() As String)            '保存网格格式(包括网格列宽,网格列顺序)
  493.   
  494.     '过程参数:Bcgsgrid 保存格式网格对象,Wggsdm 网格格式代码(网格参数),GridStr() 从中取网格列索引信息
  495.   
  496.     Dim RecTemp As New ADODB.Recordset               '临时使用动态集
  497.     Dim Qslzte As Integer                            '起始列值
  498.     Dim Tsxx As String                               '系统信息提示
  499.   
  500.     Cw_DataEnvi.DataConnect.BeginTrans
  501.     On Error GoTo Swcwcl
  502.     If RecTemp.State = 1 Then RecTemp.Close
  503.     RecTemp.Open "select * from xt_grid where Grid_Code='" + Trim(Wggsdm) + "' order by ColId", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  504.     With RecTemp
  505.         If Not .EOF Then
  506.             Qslzte = .Fields("BeginCol")
  507.             .MoveNext
  508.         End If
  509.     
  510.         Do While Not .EOF
  511.             For Jsqte = Qslzte To Bcgsgrid.Cols - 1
  512.                 If Trim(.Fields("ColIndex")) = Trim(GridStr(Jsqte, 1)) Then
  513.                     Exit For
  514.                 End If
  515.             Next Jsqte
  516.             If Jsqte <= Bcgsgrid.Cols - 1 Then
  517.                 .Fields("ColId") = Jsqte - Qslzte + 1
  518.                 .Fields("ColWidth") = Bcgsgrid.ColWidth(Jsqte)
  519.                 .Update
  520.             End If
  521.             .MoveNext
  522.         Loop
  523.     End With
  524.   
  525.     Cw_DataEnvi.DataConnect.CommitTrans
  526.   
  527.     Tsxx = "表格格式保存完毕!"
  528.     Call Xtxxts(Tsxx, 0, 4)
  529.     Exit Sub
  530. Swcwcl:
  531.     Cw_DataEnvi.DataConnect.RollbackTrans
  532.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  533.     Call Xtxxts(Tsxx, 0, 1)
  534.     Exit Sub
  535. End Sub
  536. Public Sub Hfmrgs(Bcgsgrid As vsFlexGrid, Wggsdm As String, GridStr() As String)            '恢复网格默认列宽
  537.     
  538.     '过程参数:保存格式网格对象,网格格式代码(网格参数),GridStr() 从中取网格列索引信息
  539.     Dim RecTemp As New ADODB.Recordset   '临时使用动态集
  540.     Dim Qslzte As Integer                '起始列值
  541.     Dim Tsxx As String                   '系统提示信息
  542.   
  543.     Cw_DataEnvi.DataConnect.BeginTrans
  544.     If RecTemp.State = 1 Then RecTemp.Close
  545.     RecTemp.Open "select * from xt_grid where Grid_Code='" + Trim(Wggsdm) + "' order by ColId", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  546.     
  547.     On Error GoTo Swcwcl
  548.   
  549.     With RecTemp
  550.         If Not .EOF Then
  551.             Qslzte = .Fields("BeginCol")
  552.             .MoveNext
  553.         End If
  554.         Do While Not .EOF
  555.             For Jsqte = Qslzte To Bcgsgrid.Cols - 1
  556.                 If Trim(.Fields("ColIndex")) = Trim(GridStr(Jsqte, 1)) Then
  557.                     Exit For
  558.                 End If
  559.             Next Jsqte
  560.             If Jsqte <= Bcgsgrid.Cols - 1 Then
  561.                 Bcgsgrid.ColWidth(Jsqte) = .Fields("DefaultColWidth")
  562.                 .Fields("ColWidth") = .Fields("DefaultColWidth") + 0
  563.                 .Update
  564.             End If
  565.             .MoveNext
  566.         Loop
  567.     End With
  568.     Cw_DataEnvi.DataConnect.CommitTrans
  569.     Exit Sub
  570. Swcwcl:
  571.     Cw_DataEnvi.DataConnect.RollbackTrans
  572.     Tsxx = "恢复过程中出现未知错误,程序自动恢复保存前状态!"
  573.     Call Xtxxts(Tsxx, 0, 1)
  574.     Exit Sub
  575. End Sub
  576. Public Sub Szxsxm(SzgsGrid As vsFlexGrid, Wggsdm As String)        '设置网格显示项目
  577.    
  578.     '过程参数:调整显示项目网格对象,网格格式代码(网格参数)
  579.     Xtcdcs = Wggsdm
  580.     XT_BgxsxmszFrm.Show 1                '调整网格显示项目
  581.     Call Cxxswg(SzgsGrid, Wggsdm)        '重新定义网格显示
  582. End Sub
  583. Public Sub Cxxswg(Bcgsgrid As vsFlexGrid, Wggsdm As String)        '根据用户定义显示项目重新显示网格
  584.   
  585.     '过程参数:调整显示项目网格对象,网格格式代码(网格参数)
  586.   
  587.     Dim RecTemp As New ADODB.Recordset   '查询数据表动态集
  588.     Dim Qslzte As Integer
  589.     Dim Tsxx As String
  590.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute("select * from xt_grid where Grid_Code='" + Trim(Wggsdm) + "' order by ColId")
  591.     With RecTemp
  592.         If Not .EOF Then
  593.             Qslzte = .Fields("BeginCol")
  594.             .MoveNext
  595.         End If
  596.         Do While Not .EOF
  597.             For Jsqte = Qslzte To Bcgsgrid.Cols - 1
  598.                 If Bcgsgrid.FixedRows = 1 Then
  599.                     If Trim(.Fields("ColTitle1")) = Trim(Bcgsgrid.TextMatrix(0, Jsqte)) Then
  600.                         Exit For
  601.                     End If
  602.                 Else
  603.                     If Trim(.Fields("ColTitle1")) = Trim(Bcgsgrid.TextMatrix(0, Jsqte)) And Trim(.Fields("ColTitle2")) = Trim(Bcgsgrid.TextMatrix(1, Jsqte)) Then
  604.                         Exit For
  605.                     End If
  606.                 End If
  607.             Next Jsqte
  608.             If Jsqte <= Bcgsgrid.Cols - 1 Then
  609.                 If .Fields("ColHidden") Then
  610.                     Bcgsgrid.ColHidden(Jsqte) = True
  611.                 Else
  612.                     Bcgsgrid.ColHidden(Jsqte) = False
  613.                 End If
  614.             End If
  615.             .MoveNext
  616.         Loop
  617.     End With
  618. End Sub
  619. Public Function Sydz(Zdbmte As String, GridStr() As String, Szzls As Integer) As Integer   '网格索引对照表(用来对照网格物理与逻辑顺序关系)
  620.     
  621.     '函数参数:索引编码,网格列属性(字符型),网格列最大数组下标值
  622.     Sydz = 0
  623.     For Jsqte = 0 To Szzls
  624.         If Trim(GridStr(Jsqte, 1)) = Zdbmte Then
  625.             Sydz = Jsqte
  626.             Exit Function
  627.         End If
  628.     Next Jsqte
  629. End Function
  630. Public Function FnBln_RefreshArray(int_StartCol As Long, int_FinishCol As Long, GridStr() As String, GridInf()) As Boolean     '网格列交换后数组做相应变换函数
  631.   
  632.     '功能: 实现网格的列移动
  633.     '说明:本函数是在模式工程的基础上创建的,请确认你的窗体中的网格是通过
  634.     '     BzWgcsh(CxbbGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr()) 函数来定义的
  635.     '参数:int_StartCol——网格开始移动列
  636.     '参数:int_FinishCol——网格移动结束列
  637.     '参数:GridStr()——网格的信息数组
  638.     '思路:对于要移动的网格来说,所有的信息都保存在几个系统数组中,其中GridStr()数组保存着逻辑定位和
  639.     '      物理定位之间的转换关系,使我们可以通过逻辑值找到物理值,由于我们通常通过逻辑值来定位网格的
  640.     '      物理列(sydz(zdbmte as String,GridStr() as String,szzls as Integer)函数),所以我们只需要
  641.     '      改变GridStr()数组中物理列和逻辑列之间的对应关系,从而达到改变列的目的。
  642.     '扩展:虽然本程序只是针对数据显示网格而作,但是此程序给大家提供了一个思路,通过交换GridBoolean()、
  643.     '      GridInt()、网格列标题wglbt()等数组,就可以实现输入的列移动
  644.   
  645.     On Error GoTo Err_Ctrl
  646.  
  647.     Dim int_temp As Integer
  648.     Dim Str_Temp() As String '用来保存移动开始列的GridStr()信息
  649.     Dim i, j As Long
  650.   
  651.     '如果结束列小于用户定义网格开始列,则结束列=用户定义网格开始列
  652.     '因为开始列以前的列都是隐藏列,由于要把当前开始移动列移动到隐藏列上
  653.     '所以控件自动把隐藏列变为显示列,这样在刷新数据时,会把隐藏列上的数据
  654.     '显示出来,并且,由于开始列以前的隐藏列在XT_Grid中,不对应逻辑值,所以在保存
  655.     '网格格式时会出错
  656.     If int_StartCol > int_FinishCol Then
  657.         If int_FinishCol < GridInf(1) Then int_FinishCol = GridInf(1)
  658.     Else
  659.         If Col < GridInf(1) Then Col = GridInf(1)
  660.     End If
  661.   
  662.     '保存移动开始列的GridStr()信息
  663.     ReDim Str_Temp(0, UBound(GridStr, 2))
  664.     For j = 1 To UBound(GridStr, 2)
  665.         Str_Temp(0, j) = GridStr(int_StartCol, j)
  666.     Next
  667.     
  668.     '[[在此加入你的代码,保存当前开始移动列的其他信息]]
  669.     '依次移动各列的信息
  670.     If int_StartCol < int_FinishCol Then
  671.         For i = int_StartCol To int_FinishCol - 1
  672.             For j = 1 To UBound(GridStr, 2)
  673.                 GridStr(i, j) = GridStr(i + 1, j)
  674.             Next j
  675.         Next i
  676.     Else
  677.         For i = int_StartCol To int_FinishCol + 1 Step -1
  678.             For j = 1 To UBound(GridStr, 2)
  679.                 GridStr(i, j) = GridStr(i - 1, j)
  680.             Next j
  681.         Next i
  682.     End If
  683.     
  684.     '[[在此加入你的代码,依照上面的代码格式,移动列的其他信息]]
  685.     '恢复开始移动列的信息到结束列上
  686.     For j = 1 To UBound(GridStr, 2)
  687.         GridStr(int_FinishCol, j) = Str_Temp(0, j)
  688.     Next j
  689.   
  690.     '[[在此加入你的代码,恢复开始移动列的其他信息到结束列上]]
  691.     FnBln_RefreshArray = True
  692.     Exit Function
  693. Err_Ctrl:
  694.     FnBln_RefreshArray = False
  695. End Function
  696. '========================以上为网格操作基本函数==============================='
  697. Public Sub Drwbkxx(Wbklrbmte As String, Textvar() As Variant, Textboolean() As Boolean, Textint() As Integer, Textstr() As String)   '读入文本框录入信息
  698.    
  699.     '过程参数:输入参数 Wbklrbmte 文本框录入信息组索引号
  700.     '         输出参数 Textvar() Textboolean() Textint() Textstr 文本框信息
  701.    
  702.     Dim Wbklrbrec As ADODB.Recordset      '文本框录入表动态集
  703.     Dim Zdszxb As Integer                 '最大数组下标
  704.     Dim text_indexte As Integer           '文本框索引值
  705.    
  706.     ReDim Textvar(1 To 1)
  707.     Set Wbklrbrec = Cw_DataEnvi.DataConnect.Execute("SELECT * FROM Xt_text_input WHERE Text_Group_Code ='" + Wbklrbmte + "' ORDER BY Text_index")
  708.     With Wbklrbrec
  709.         If Not (.BOF And .EOF) Then
  710.             .MoveLast
  711.             Zdszxb = .Fields("text_index")
  712.             Textvar(1) = Zdszxb
  713.             ReDim Textboolean(0 To Zdszxb, 1 To 5)
  714.             ReDim Textint(0 To Zdszxb, 1 To 14)
  715.             ReDim Textstr(0 To Zdszxb, 1 To 7)
  716.             .MoveFirst
  717.         Else
  718.             Exit Sub
  719.         End If
  720.         Do While Not .EOF
  721.             text_indexte = .Fields("text_index")
  722.             
  723.             If .Fields("help_flag") Then                                 '是否提供帮助
  724.                 Textboolean(text_indexte, 1) = True
  725.             End If
  726.             If .Fields("Help_ManuFlag") Then                             '手工设置帮助按钮
  727.                 Textboolean(text_indexte, 3) = True
  728.             End If
  729.             If .Fields("Visible") Then                                   '文本框是否显示
  730.                 Textboolean(text_indexte, 4) = True
  731.             End If
  732.             If .Fields("Enabled") Then                                   '文本框是否可编辑
  733.                 Textboolean(text_indexte, 5) = True
  734.             End If
  735.       
  736.             If Not IsNull(.Fields("text_data_type")) Then                '字段数据类型
  737.                 Textint(text_indexte, 1) = .Fields("text_data_type")
  738.             End If
  739.             If Not IsNull(.Fields("help_type")) Then                     '帮助类型
  740.                 Textint(text_indexte, 2) = .Fields("help_type")
  741.             End If
  742.             If Not IsNull(.Fields("show_code_name")) Then                '帮助返回值显示类型
  743.                 Textint(text_indexte, 3) = .Fields("show_code_name")
  744.             End If
  745.             If Not IsNull(.Fields("judge_type")) Then                    '有效性判断类型
  746.                 Textint(text_indexte, 4) = .Fields("judge_type")
  747.             End If
  748.             If Not IsNull(.Fields("text_length")) Then                   '字段录入长度
  749.                 Textint(text_indexte, 5) = .Fields("text_length")
  750.             End If
  751.             If Not IsNull(.Fields("text_int_length")) Then               '数值字段整数位长度
  752.                 Textint(text_indexte, 6) = .Fields("text_int_length")
  753.             End If
  754.             If Not IsNull(.Fields("text_deci_length")) Then              '数值字段小数位长度
  755.                 Textint(text_indexte, 7) = .Fields("text_deci_length")
  756.             End If
  757.             If Not IsNull(.Fields("NotAllowEmpty_Type")) Then            '字段不允许为空或为零
  758.                 Textint(text_indexte, 8) = .Fields("NotAllowEmpty_Type")
  759.             End If
  760.             If Not IsNull(.Fields("Judge_Time")) Then                    '文本框有效性判断时刻
  761.                 Textint(text_indexte, 9) = .Fields("Judge_Time")
  762.             End If
  763.             If Not IsNull(.Fields("TextHeight")) Then                    '文本框高度
  764.                 Textint(text_indexte, 10) = .Fields("TextHeight")
  765.             End If
  766.             If Not IsNull(.Fields("TextWidth")) Then                     '文本框宽度
  767.                 Textint(text_indexte, 11) = .Fields("TextWidth")
  768.             End If
  769.             If Not IsNull(.Fields("TextTop")) Then                       '文本框距离顶端高度
  770.                 Textint(text_indexte, 12) = .Fields("TextTop")
  771.             End If
  772.             If Not IsNull(.Fields("TextLeft")) Then                      '文本框左端距离
  773.                 Textint(text_indexte, 13) = .Fields("TextLeft")
  774.             End If
  775.             If Not IsNull(.Fields("TabIndex")) Then                      '文本框焦点顺序
  776.                 Textint(text_indexte, 14) = .Fields("TabIndex")
  777.             End If
  778.          
  779.             Textstr(text_indexte, 1) = Trim(.Fields("text_index") & "")       '文本框对应索引值
  780.             Textstr(text_indexte, 2) = Trim(.Fields("text_field_code") & "")  '文本框对应编码字段
  781.             Textstr(text_indexte, 3) = Trim(.Fields("text_field_name") & "")  '文本框对应名称字段
  782.             Textstr(text_indexte, 4) = Trim(.Fields("help_code") & "")        '通用帮助编码
  783.             Textstr(text_indexte, 5) = Trim(.Fields("judge_base") & "")       '字段有效性判断依据
  784.             Textstr(text_indexte, 6) = Trim(.Fields("error_message") & "")    '字段录入错误提示信息
  785.             Textstr(text_indexte, 7) = Trim(.Fields("text_name") & "")        '文本框名称
  786.                
  787.             .MoveNext
  788.         Loop
  789.     End With
  790. End Sub
  791. Public Function Mmjm(Srmm As String) As String                                              '密码加密对照模块
  792.    
  793.     Dim Zfcte As Integer
  794.     Mmjm = ""
  795.     For Jsqte = 1 To Len(Srmm)
  796.         Zfcte = Asc(Mid(Srmm, Jsqte, 1)) + Asc(Mid(Srmm, Len(Srmm) - Jsqte + 1, 1)) + Len(Srmm) + Jsqte
  797.         Mmjm = Mmjm + Trim(Str(Zfcte))
  798.     Next Jsqte
  799. End Function
  800. Public Sub F1bz()                                                                           '发送F1键
  801.     SendKeys "{F1}"
  802. End Sub
  803. Public Sub Textyx(Textte As TextBox)                                                        '文本框有效
  804.     
  805.     Textte.Enabled = True
  806.     Textte.BackColor = &H80000005
  807. End Sub
  808. Public Sub Textwx(Textte As TextBox)                                                        '文本框无效
  809.    
  810.     Textte.Enabled = False
  811.     Textte.BackColor = &HC0C0C0
  812. End Sub
  813. Public Sub Drbmhelp(bzlx As Integer, Helpbm As String, Scdwnr As String)                    '调入编码参照窗体
  814.     
  815.     '函数参数:帮助类型(0-通用型 1-日期型 2-特殊型),帮助编码,首次定位内容
  816.     Dim XT_TybmczFrmte As New XT_TybmczFrm
  817.     
  818.     On Error GoTo ErrHandle
  819.     Xtcdcs = Scdwnr
  820.     Xtfhcs = ""
  821.     Xtfhcsfz = ""
  822.     Select Case bzlx
  823.         Case 0
  824.             Xtbmczdm = Trim(Helpbm)
  825.             XT_TybmczFrmte.Show 1
  826.             Xtbmczdm = ""
  827.         Case 1
  828.             XT_calendar.Show 1
  829.         Case 2
  830.             Select Case Helpbm
  831.             
  832.             End Select
  833.     End Select
  834.     
  835. ErrHandle:
  836. End Sub
  837. Public Sub Drbmbj(Helpbm As String)                                                         '调入编码参照编辑窗体
  838.     
  839.     Select Case Helpbm
  840.         'Case "gy_dept"             '部门编辑
  841.         'JC_BmszFrm.Show 1
  842.    End Select
  843. End Sub
  844. '===================以下为固定项列表框处理函数========================'
  845. Public Function FillCombo(Combote As ComboBox, Lbkbmte As String, Dwnr As String, AddType As Integer) As String   '填充列表框并定位
  846.     '函数参数:列表框,列表框分组编码,定位内容,填充类型(0-无空记录  1-有空记录(1个空格) )
  847.     Dim Lbknrrec As ADODB.Recordset
  848.   
  849.     '填充列表框内容
  850.     Set Lbknrrec = Cw_DataEnvi.DataConnect.Execute("select * from xt_combolist where combo_code='" + Trim(Lbkbmte) + "' order by item_index")
  851.     Combote.Clear
  852.     If AddType = 1 Then
  853.         Combote.AddItem " "
  854.     End If
  855.     With Lbknrrec
  856.         Do While Not .EOF
  857.             Combote.AddItem Trim(.Fields("item_content"))
  858.             .MoveNext
  859.         Loop
  860.     End With
  861.     
  862.     '定位列表框内容
  863.     With Combote
  864.         For Jsqte = .ListCount - 1 To 0 Step -1
  865.             If Dwnr = Trim(.List(Jsqte)) Then
  866.                 Exit For
  867.             End If
  868.         Next Jsqte
  869.         If Jsqte <> -1 Then
  870.             Combote.Text = .List(Jsqte)
  871.         Else
  872.             If .ListCount <> 0 Then
  873.                 .Text = .List(0)
  874.             End If
  875.         End If
  876.     End With
  877. End Function
  878. Public Function Fun_GetIndex(ComboCodeTe As String, FindText As String) As String                         '查找列表框内容对应索引号
  879.     '函数参数:列表框分组编码,定位内容
  880.     Dim Lbknrrec As ADODB.Recordset
  881.   
  882.     Fun_GetIndex = ""
  883.   
  884.     '填充列表框内容
  885.     Set Lbknrrec = Cw_DataEnvi.DataConnect.Execute("select Item_Index from xt_combolist where combo_code='" & Trim(ComboCodeTe) & "' And Item_Content='" & Trim(FindText) & "'")
  886.   
  887.     With Lbknrrec
  888.         If Not .EOF Then
  889.             Fun_GetIndex = Trim(.Fields("Item_Index"))
  890.         End If
  891.     End With
  892. End Function
  893. Public Function Fun_GetContent(ComboCodeTe As String, FindIndex As String) As String                      '查找列表框索引号对应内容
  894.     '函数参数:列表框分组编码,定位内容
  895.     Dim Lbknrrec As ADODB.Recordset
  896.   
  897.     Fun_GetContent = ""
  898.   
  899.     '填充列表框内容
  900.     Set Lbknrrec = Cw_DataEnvi.DataConnect.Execute("select Item_Content from xt_combolist where combo_code='" & Trim(ComboCodeTe) & "' And Item_Index='" & Trim(FindIndex) & "'")
  901.   
  902.     With Lbknrrec
  903.         If Not .EOF Then
  904.             Fun_GetContent = Trim(.Fields("Item_Content"))
  905.         End If
  906.     End With
  907. End Function
  908. '==========================以上为列表框处理基本函数=========================='
  909. Public Function XtWaitMess(Str_IndexSub)                               '系统功能调用等待提示
  910.     
  911.     '函数参数:系统功能模块索引号
  912.     Xtcdcs = Str_IndexSub
  913.     XT_FrmWaitMess.Show 1
  914. End Function
  915. Public Function Sub_FillPeriod(Combote As ComboBox, Year As Integer, Period As Integer)            '列表框填充会计期间
  916.     '过程参数;填充列表框,会计年度,默认会计期间
  917.     Dim Jsqte As Integer
  918.     With Combote
  919.         .Clear
  920.         For Jsqte = 1 To 12
  921.             .AddItem Mid(Trim(Str(10000 + Xtyear)), 2, 4) + "." + Mid(Trim(Str(100 + Jsqte)), 2, 2)
  922.         Next Jsqte
  923.      
  924.         .Text = Mid(Trim(Str(10000 + Xtyear)), 2, 4) + "." + Mid(Trim(Str(100 + Period)), 2, 2)
  925.     End With
  926. End Function
  927. '//* 功能: 金额小写转换为大写  调用参数:jesj...人民币小写金额
  928. '//* 返回变量: name..人民币大写金额
  929. Public Function Fun_Jezh(Jesj As Double) As String
  930.     
  931.     Dim Name1$, Name2$, Mje1$, Name$
  932.     Dim len_mje1%, k%, Ws%, j%, ws1%, m%
  933.     Dim Bz As Boolean
  934.     Name1 = "壹贰叁肆伍陆柒捌玖"
  935.     Name2 = "分角元拾佰仟万拾佰仟亿拾佰仟"
  936.     Mje1 = Trim(Format(Jesj, "###.00"))
  937.     len_mje1 = Len(Mje1)
  938.     If len_mje1 > 16 Or Jesj < 0.01 Or IsNull(Jesj) Then
  939.         Fun_Jezh = ""
  940.         Exit Function
  941.     End If
  942.     '//取无小数的字符串
  943.     Mje1 = Left(Mje1, len_mje1 - 3) + Right(Mje1, 2)
  944.     len_mje1 = len_mje1 - 1
  945.     k = len_mje1 * 2 - 1
  946.     Ws = Int(Mid(Mje1, 1, 1)) * 2 - 1
  947.     If len_mje1 = 3 And Ws < 0 Then     '//如果金额<1 name=''
  948.         Name = ""
  949.     Else
  950.         If Ws > 0 Then
  951.             Name = MidB(Name1, Ws, 2) + MidB(Name2, k, 2) '//如果金额>=1,转换金额
  952.         End If
  953.     End If
  954.     j = 2
  955.     k = k - 2
  956.     Bz = True
  957. xh1:
  958.     Do While j <= len_mje1 And Bz
  959.         ws1 = Int(Mid(Mje1, j, 1)) * 2 - 1
  960.         If ws1 > 0 Then
  961.             Name = Name + MidB(Name1, ws1, 2) + MidB(Name2, k, 2)
  962.             j = j + 1
  963.             k = k - 2
  964.             GoTo xh1
  965.         End If
  966.         m = 0
  967. xh2:
  968.         Do While ws1 < 0
  969.             If len_mje1 >= 11 Then
  970.                 If k < 21 Then
  971.                     m = m + 1
  972.                 End If
  973.             End If
  974.             If k = 5 Or (k = 13 And m <= 3) Or k = 21 Then
  975.                 Name = Name + MidB(Name2, k, 2)
  976.             End If
  977.             If k = 1 Then
  978.                 Name = Name + "整"
  979.                 Bz = False
  980.                 Exit Do
  981.             End If
  982.             j = j + 1
  983.             k = k - 2
  984.             ws1 = Int(Mid(Mje1, j, 1)) * 2 - 1
  985.             If ws1 < 0 Then
  986.                 GoTo xh2
  987.             Else
  988.                 If len_mje1 = 3 Then
  989.                     Name = Name + "零"
  990.                 Else
  991.                     Name = Name + "零"
  992.                 End If
  993.             End If
  994.         Loop
  995.     Loop
  996.     '去掉元和角之间零(1230.32)
  997.     wz1 = InStr(1, Name, "元")
  998.     wz2 = InStr(1, Name, "角")
  999.     If wz1 <> 0 And wz2 <> 0 Then
  1000.         wz3 = InStr(wz1, Name, "零")
  1001.         If wz3 <> 0 Then
  1002.             Name = Mid(Name, 1, wz3 - 1) + Mid(Name, wz3 + 1, Len(Name))
  1003.         End If
  1004.     End If
  1005.     Fun_Jezh = Name
  1006. End Function
  1007. Public Function FillImageCombo(Combote As ImageCombo, ComboCode As String, AddType As Integer) '填充列表框(ImageCombo)并定位
  1008.     '函数参数:列表框(ImageCombo),ComboCode列表框分组编码
  1009.     'AddType 项目填充类型(0-填充索引+内容,无空记录 1-仅填充内容,无空记录 2-填充索引+内容,有空记录 3-仅填充内容,有空记录)
  1010.     Dim Rec_Combo As ADODB.Recordset              '填充属性
  1011.     Dim Rec_FillText As ADODB.Recordset           '填充内容
  1012.     Dim ci As ComboItem
  1013.     Dim Jsqte As Integer                          '临时计数器
  1014.   
  1015.     Combote.ComboItems.Clear
  1016.     Jsqte = 1
  1017.   
  1018.     '填充列表框内容
  1019.     Set Rec_Combo = Cw_DataEnvi.DataConnect.Execute("Select * From Xt_ImageCombo Where combo_code='" + Trim(ComboCode) + "'")
  1020.     With Rec_Combo
  1021.         Combote.Locked = True
  1022.         If AddType = 2 Or AddType = 3 Then
  1023.             Set ci = Combote.ComboItems.Add(, "@")
  1024.             Jsqte = Jsqte + 1
  1025.         End If
  1026.         
  1027.         Set Rec_FillText = Cw_DataEnvi.DataConnect.Execute(Trim(.Fields("Sql_String")))
  1028.         
  1029.         Do While Not Rec_FillText.EOF
  1030.             Select Case AddType
  1031.                 Case 0, 2                              '填充索引+内容
  1032.                     Set ci = Combote.ComboItems.Add(, "@" + Trim(Rec_FillText.Fields(Trim(.Fields("ItemKey")))), Trim(Rec_FillText.Fields(Trim(.Fields("ItemKey")))) + " " + Trim(Rec_FillText.Fields(Trim(.Fields("ItemText")))))
  1033.                 Case 1, 3                              '仅填充记录内容
  1034.                     Set ci = Combote.ComboItems.Add(, "@" + Trim(Rec_FillText.Fields(Trim(.Fields("ItemKey")))), Trim(Rec_FillText.Fields(Trim(.Fields("ItemText")))))
  1035.             End Select
  1036.             Jsqte = Jsqte + 1
  1037.             Rec_FillText.MoveNext
  1038.         Loop
  1039.         If Combote.ComboItems.Count <> 0 Then
  1040.             Combote.ComboItems.Item(1).Selected = True
  1041.         End If
  1042.     End With
  1043. End Function
  1044. Public Function GetComboKey(Combote As ImageCombo, KeyOrName As Integer) As String      '取得用户选中列表框项目Key值或内容
  1045.   
  1046.     '函数参数:列表框(ImageCombo),KeyOrName 0--取项目Key值 1--取选项内容值
  1047.     Dim Jsqte As Integer        '临时计数器
  1048.   
  1049.     If KeyOrName = 0 Then
  1050.         '去掉首位@
  1051.         For Jsqte = 1 To Combote.ComboItems.Count
  1052.             If Combote.ComboItems(Jsqte).Text = Combote.Text Then
  1053.                 Exit For
  1054.             End If
  1055.         Next Jsqte
  1056.         
  1057.         If Combote.ComboItems.Count > 0 Then
  1058.             GetComboKey = Trim(Mid(Combote.ComboItems(Jsqte).Key, 2, Len(Combote.ComboItems(Jsqte).Key)))
  1059.         End If
  1060.     Else
  1061.         GetComboKey = Trim(Combote.Text)
  1062.     End If
  1063.  
  1064. End Function
  1065. Public Sub Sub_CodeScheme(ItemCodeTe As String, Int_CodeLev As Integer, Int_CodeScheme() As Integer)     '生成相应各级编码长度到数组中(编码方案)
  1066.     '函数参数:ItemCodeTe 编码方案代码,Int_CodeLev 返回编码最大级数,Int_CodeScheme() 返回各级编码长度
  1067.     'ForExample:会计科目编码:322222  结果:Int_CodeLev=6 Int_CodeScheme()=3 5 7 9 11 13
  1068.     
  1069.     Dim Rec_CodeScheme As New ADODB.Recordset   '编码方案动态集
  1070.     Set Rec_CodeScheme = Cw_DataEnvi.DataConnect.Execute("Select CodeScheme From Gy_CodeScheme Where ItemCode='" & Trim(ItemCodeTe) & "'")
  1071.     With Rec_CodeScheme
  1072.         If Not .EOF Then
  1073.             Int_CodeLev = Len(Trim(.Fields("CodeScheme")))
  1074.             ReDim Int_CodeScheme(Int_CodeLev)
  1075.             lenjsq = 0
  1076.             For Jsqte = 1 To Int_CodeLev
  1077.                 lenjsq = lenjsq + Mid(Trim(.Fields("CodeScheme")), Jsqte, 1)
  1078.                 Int_CodeScheme(Jsqte) = lenjsq
  1079.             Next Jsqte
  1080.         End If
  1081.         .Close
  1082.     End With
  1083. End Sub
  1084. Public Sub Sub_SetOperStatus(Str_OperStatus As String)                                                   '显示系统操作状态
  1085.     
  1086.     If Trim(Str_OperStatus) <> "" Then
  1087.         XT_Main.StatusBar1.Panels("OperStatus") = Str_OperStatus
  1088.     Else
  1089.         XT_Main.StatusBar1.Panels("OperStatus") = "就绪"
  1090.     End If
  1091. End Sub
  1092. Public Sub Sub_ReadBillInfo(BillCode As String, Frm_Bill As Form, Var_Bill() As Variant)                 '读入单据整体设计信息(录入)
  1093.     
  1094.     '参数说明:BillCode 单据编码(索引号) ,Frm_Bill 单据窗体 , VarBill 用来返回单据设计信息
  1095.     Dim RecTemp As New ADODB.Recordset                             '临时使用动态集
  1096.     ReDim Var_Bill(1 To 5)                                         '返回单据设计信息
  1097.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute("Select * From xt_BillDesign Where BillCode='" & Trim(BillCode) & "'")
  1098.     With RecTemp
  1099.         If Not .EOF Then
  1100.             Frm_Bill.Height = .Fields("FormHeight")                   '设置窗体高度
  1101.             Frm_Bill.Width = .Fields("FormWidth")                     '设置窗体宽度
  1102.             Var_Bill(1) = Trim(.Fields("BillName"))                   '单据描述
  1103.             Frm_Bill.Caption = Var_Bill(1)                            '单据描述赋予窗体Caption
  1104.             Var_Bill(2) = Trim(.Fields("BillTitle"))                  '单据标题
  1105.             Var_Bill(3) = Trim(.Fields("Text_Group_Code"))            '单据所使用文本框组索引号
  1106.             Var_Bill(4) = Trim(.Fields("Grid_Code"))                  '单据所使用网格组索引号
  1107.             Var_Bill(5) = Trim(.Fields("Print_Code"))                 '单据所使用打印参数索引号
  1108.         End If
  1109.     End With
  1110. End Sub
  1111. Public Sub Sub_DPReadBillInfo(BillCode As String, Frm_Bill As Form, Var_Bill() As Variant)               '读入单据整体设计信息(打印)
  1112.     
  1113.     '参数说明:BillCode  单据编码(索引号)  Frm_Bill 单据窗体  VarBill 用来返回单据设计信息
  1114.     Dim RecTemp As New ADODB.Recordset
  1115.     ReDim Var_Bill(1 To 3)
  1116.   
  1117.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute("Select * From xt_BillDesign Where BillCode='" & Trim(BillCode) & "'")
  1118.   
  1119.     With RecTemp
  1120.         If Not .EOF Then
  1121.             Frm_Bill.Pict.Height = .Fields("FormHeight") - 375                  '设置窗体高度
  1122.             Frm_Bill.Pict.Width = .Fields("FormWidth")                          '设置窗体宽度
  1123.             Frm_Bill.Lab_Title = Trim(.Fields("BillName"))                      '单据标题
  1124.             Var_Bill(1) = Trim(.Fields("BillName"))                             '单据描述
  1125.             Frm_Bill.Caption = Var_Bill(1)                                      '单据描述赋予窗体Caption
  1126.             Var_Bill(2) = Trim(.Fields("Text_Group_Code"))                      '单据所使用文本框组索引号
  1127.             Var_Bill(3) = Trim(.Fields("Grid_Code"))                            '单据所使用网格组索引号
  1128.         End If
  1129.     End With
  1130. End Sub
  1131. Public Sub DPBcwggs(Bcgsgrid As vsFlexGrid, Wggsdm As String)             '保存网格格式(包括网格列宽,网格列顺序)
  1132.     
  1133.     '过程参数:保存格式网格对象,网格格式代码(网格参数)
  1134.     Dim Tsxx As String
  1135.     Dim RecTemp As New ADODB.Recordset
  1136.     Dim Qslzte As Integer
  1137.     Cw_DataEnvi.DataConnect.BeginTrans
  1138.     On Error GoTo Swcwcl
  1139.     If RecTemp.State = 1 Then RecTemp.Close
  1140.     RecTemp.Open "select * from xt_grid where Grid_Code='" + Trim(Wggsdm) + "' order by ColId", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1141.     With RecTemp
  1142.         If Not .EOF Then
  1143.             Qslzte = .Fields("BeginCol")
  1144.             .MoveNext
  1145.         End If
  1146.         Do While Not .EOF
  1147.             For Jsqte = Qslzte To Bcgsgrid.Cols - 1
  1148.                 If Bcgsgrid.FixedRows = 1 Then
  1149.                     If Trim(.Fields("ColTitle1")) = Trim(Bcgsgrid.TextMatrix(0, Jsqte)) Then
  1150.                         Exit For
  1151.                     End If
  1152.                 Else
  1153.                     If Trim(.Fields("ColTitle1")) = Trim(Bcgsgrid.TextMatrix(0, Jsqte)) And Trim(.Fields("ColTitle2")) = Trim(Bcgsgrid.TextMatrix(1, Jsqte)) Then
  1154.                         Exit For
  1155.                     End If
  1156.                 End If
  1157.             Next Jsqte
  1158.             If Jsqte <= Bcgsgrid.Cols - 1 Then
  1159.                 .Fields("ColId") = Jsqte - Qslzte + 1
  1160.                 .Fields("ColWidth") = Bcgsgrid.ColWidth(Jsqte)
  1161.                 .Update
  1162.             Else
  1163.                 GoTo Swcwcl
  1164.             End If
  1165.             .MoveNext
  1166.         Loop
  1167.     End With
  1168.     Cw_DataEnvi.DataConnect.CommitTrans
  1169.     Tsxx = "表格格式保存完毕!"
  1170.     Call Xtxxts(Tsxx, 0, 4)
  1171.     Exit Sub
  1172. Swcwcl:
  1173.     Cw_DataEnvi.DataConnect.RollbackTrans
  1174.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  1175.     Call Xtxxts(Tsxx, 0, 1)
  1176.     Exit Sub
  1177. End Sub
  1178. '===================以下为系统权限控制与上机日志控制函数======================'
  1179. Public Function Security_Log(gnsy As String, UserCode As String, Optional LogTF As Integer = 3, Optional State As Boolean = True, Optional Msg As Boolean = True) As Boolean   '权限判断和日志
  1180.     'Gnsy 功能索引 UserCode 用户编码
  1181.     'LogTF (1、判断权限,写日志)、(2、只写日志)、(3、只判断权限)
  1182.     'State 状态 (True 进入 false 完成)
  1183.     '返回Security_Log=true表示有权限,Security_Log=false表示没有有权限
  1184.     'Msg   没有权限时是否提示(True 提示    False不提示)
  1185.     Dim Tsxx As String              '系统信息提示
  1186.     
  1187.    On Error Resume Next
  1188.     
  1189.     Dim aDo_userGroup As New Recordset
  1190.     Dim aDo_gnbm As New Recordset: Dim Ssql As String
  1191.     
  1192.     Set aDo_gnbm = Cw_DataEnvi.DataConnect.Execute("select * from Xt_xtgnb where gnsy='" & Trim(gnsy) & "'")
  1193.      
  1194.     If LogTF = 1 Or LogTF = 3 Then
  1195.         Set aDo_userGroup = Cw_DataEnvi.DataConnect.Execute("select * from Gy_Czygl where czybm='" & Trim(UserCode) & "'")
  1196.             
  1197.         If Mid(aDo_userGroup!AuthorityID, aDo_gnbm!Id, 1) = "1" Then
  1198.             Security_Log = True
  1199.         Else
  1200.             Security_Log = False
  1201.         End If
  1202.         aDo_userGroup.Close
  1203.         Set aDo_userGroup = Nothing
  1204.         
  1205.         If Security_Log = False Then
  1206.             Set aDo_userGroup = Cw_DataEnvi.DataConnect.Execute("select * from System_UserGroupInfo a ,System_UserGroup b where a.groupid=b.groupid and a.userid='" & Trim(UserCode) & "'")
  1207.             Do While Not aDo_userGroup.EOF
  1208.                 If Mid(aDo_userGroup!AuthorityID, aDo_gnbm!Id, 1) = "1" Then
  1209.                     Security_Log = True
  1210.                     Exit Do
  1211.                 Else
  1212.                     Security_Log = False
  1213.                 End If
  1214.                 aDo_userGroup.MoveNext
  1215.             Loop
  1216.             aDo_userGroup.Close
  1217.             Set aDo_userGroup = Nothing
  1218.         End If
  1219.         If Security_Log = False Then
  1220.            If Msg = True Then
  1221.                 Tsxx = "没有权限,请与管理员联系!   "
  1222.                 Call Xtxxts(Tsxx, 0, 4)
  1223.            End If
  1224.         End If
  1225.     End If
  1226.     '------------------------------------
  1227.     If (LogTF = 1 And Security_Log = True) Or LogTF = 2 Then
  1228.         If State = True Then
  1229.             Ssql = "insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State)" _
  1230.                 & " values(getdate(),'" & UserCode & "','" & MachineName & "','" & Trim("" & aDo_gnbm!gnms) & "','" & "质量系统" & "','" & NTDomainUserName & "','进入')"
  1231.         Else
  1232.             Ssql = "insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State)" _
  1233.                 & " values(getdate(),'" & UserCode & "','" & MachineName & "','" & Trim("" & aDo_gnbm!gnms) & "','" & "质量系统" & "','" & NTDomainUserName & "','完成')"
  1234.         End If
  1235.         Cw_DataEnvi.DataConnect.Execute Ssql
  1236.     End If
  1237.     aDo_gnbm.Close
  1238.     Set aDo_gnbm = Nothing
  1239.     
  1240. End Function
  1241. Public Function MachineName() As String                                         '取得当前工作站名
  1242.     
  1243.     Dim sBuffer As String * 255
  1244.     If GetComputerName(sBuffer, 255&) <> 0 Then
  1245.         MachineName = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
  1246.     Else
  1247.         MachineName = "(未知)"
  1248.     End If
  1249. End Function
  1250. Public Function NTDomainUserName() As String                                    '取得当前网络用户名
  1251.     
  1252.     Dim strBuffer As String * 255
  1253.     Dim lngBufferLength As Long
  1254.     Dim lngRet As Long
  1255.     Dim strTemp As String
  1256.     lngBufferLength = 255
  1257.     lngRet = GetUserName(strBuffer, lngBufferLength)
  1258.     strTemp = UCase(Trim$(strBuffer))
  1259.     NTDomainUserName = Left$(strTemp, lngBufferLength - 1)
  1260. End Function
  1261. Public Function GetPY(a1 As String) As String                                   '返回拼音码字符串
  1262.     
  1263.     '输入参数:a1 输入字符串
  1264.     Dim Jsqte As Long
  1265.     Dim t1 As String
  1266.     GetPY = ""
  1267.     If Len(Trim(a1)) = 0 Then
  1268.         Exit Function
  1269.     End If
  1270.     For Jsqte = 1 To Len(Trim(a1))
  1271.         t1 = Mid(a1, Jsqte, 1)
  1272.         If Asc(t1) < 0 Then
  1273.             If Asc(t1) < Asc("啊") Then
  1274.                 GetPY = GetPY + t1
  1275.                 GoTo L1
  1276.             End If
  1277.             If Asc(t1) >= Asc("啊") And Asc(t1) < Asc("芭") Then
  1278.                 GetPY = GetPY + "A"
  1279.                 GoTo L1
  1280.             End If
  1281.             If Asc(t1) >= Asc("芭") And Asc(t1) < Asc("擦") Then
  1282.                 GetPY = GetPY + "B"
  1283.                 GoTo L1
  1284.             End If
  1285.             If Asc(t1) >= Asc("擦") And Asc(t1) < Asc("搭") Then
  1286.                 GetPY = GetPY + "C"
  1287.                 GoTo L1
  1288.             End If
  1289.             If Asc(t1) >= Asc("搭") And Asc(t1) < Asc("蛾") Then
  1290.                 GetPY = GetPY + "D"
  1291.                 GoTo L1
  1292.             End If
  1293.             If Asc(t1) >= Asc("蛾") And Asc(t1) < Asc("发") Then
  1294.                 GetPY = GetPY + "E"
  1295.                 GoTo L1
  1296.             End If
  1297.             If Asc(t1) >= Asc("发") And Asc(t1) < Asc("噶") Then
  1298.                 GetPY = GetPY + "F"
  1299.                 GoTo L1
  1300.             End If
  1301.             If Asc(t1) >= Asc("噶") And Asc(t1) < Asc("哈") Then
  1302.                 GetPY = GetPY + "G"
  1303.                 GoTo L1
  1304.             End If
  1305.             If Asc(t1) >= Asc("哈") And Asc(t1) < Asc("击") Then
  1306.                 GetPY = GetPY + "H"
  1307.                 GoTo L1
  1308.             End If
  1309.             If Asc(t1) >= Asc("击") And Asc(t1) < Asc("喀") Then
  1310.                 GetPY = GetPY + "J"
  1311.                 GoTo L1
  1312.             End If
  1313.             If Asc(t1) >= Asc("喀") And Asc(t1) < Asc("垃") Then
  1314.                 GetPY = GetPY + "K"
  1315.                 GoTo L1
  1316.             End If
  1317.             If Asc(t1) >= Asc("垃") And Asc(t1) < Asc("妈") Then
  1318.                 GetPY = GetPY + "L"
  1319.                 GoTo L1
  1320.             End If
  1321.             If Asc(t1) >= Asc("妈") And Asc(t1) < Asc("拿") Then
  1322.                 GetPY = GetPY + "M"
  1323.                 GoTo L1
  1324.             End If
  1325.             If Asc(t1) >= Asc("拿") And Asc(t1) < Asc("哦") Then
  1326.                 GetPY = GetPY + "N"
  1327.                 GoTo L1
  1328.             End If
  1329.             If Asc(t1) >= Asc("哦") And Asc(t1) < Asc("啪") Then
  1330.                 GetPY = GetPY + "O"
  1331.                 GoTo L1
  1332.             End If
  1333.             If Asc(t1) >= Asc("啪") And Asc(t1) < Asc("期") Then
  1334.                 GetPY = GetPY + "P"
  1335.                 GoTo L1
  1336.             End If
  1337.             If Asc(t1) >= Asc("期") And Asc(t1) < Asc("然") Then
  1338.                 GetPY = GetPY + "Q"
  1339.                 GoTo L1
  1340.             End If
  1341.             If Asc(t1) >= Asc("然") And Asc(t1) < Asc("撒") Then
  1342.                 GetPY = GetPY + "R"
  1343.                 GoTo L1
  1344.             End If
  1345.             If Asc(t1) >= Asc("撒") And Asc(t1) < Asc("塌") Then
  1346.                 GetPY = GetPY + "S"
  1347.                 GoTo L1
  1348.             End If
  1349.             If Asc(t1) >= Asc("塌") And Asc(t1) < Asc("挖") Then
  1350.                 GetPY = GetPY + "T"
  1351.                 GoTo L1
  1352.             End If
  1353.             If Asc(t1) >= Asc("挖") And Asc(t1) < Asc("昔") Then
  1354.                 GetPY = GetPY + "W"
  1355.                 GoTo L1
  1356.             End If
  1357.             If Asc(t1) >= Asc("昔") And Asc(t1) < Asc("压") Then
  1358.                 GetPY = GetPY + "X"
  1359.                 GoTo L1
  1360.             End If
  1361.             If Asc(t1) >= Asc("压") And Asc(t1) < Asc("匝") Then
  1362.                 GetPY = GetPY + "Y"
  1363.                 GoTo L1
  1364.             End If
  1365.             If Asc(t1) >= Asc("匝") Then
  1366.                 GetPY = GetPY + "Z"
  1367.                 GoTo L1
  1368.             End If
  1369.         Else
  1370.             If UCase(t1) <= "Z" And UCase(t1) >= "A" Then
  1371.                 GetPY = GetPY + UCase(t1)
  1372.             Else
  1373.                 GetPY = t1
  1374.             End If
  1375.         End If
  1376. L1:
  1377.     Next Jsqte
  1378. End Function
  1379. '<<<<<<<<<<<<<<<<<<<<<
  1380. Public Function Item_Info()  '项目查询连接
  1381.     
  1382.     Dim aDo_Item As New Recordset
  1383.     Dim Ssql As String
  1384.     Set aDo_Item = Cw_DataEnvi.DataConnect.Execute("select * from DEV_item")
  1385.     
  1386.     With aDo_Item
  1387.         Do While Not .EOF
  1388.             If !yncode = 1 And Trim(aDo_Item!TableName) = "CorrelationList" Then
  1389.                 If !YNRoot = 1 Then
  1390.                     Ssql = Ssql & ",N_" & !ItemFieldName & "=(select ListName from DEV_CorrelationList c where convert(varchar(18),c.ListCode)=b." & !ItemFieldName & ")"
  1391.                 Else
  1392.                     Ssql = Ssql & ",N_" & !ItemFieldName & "=(select ListName from DEV_CorrelationList c where convert(varchar(18),c.ListCode)=a." & !ItemFieldName & ")"
  1393.                 End If
  1394.                 '-----------------
  1395.             Else
  1396.                 If !yncode = 1 Then
  1397.                     If !YNRoot = 1 Then
  1398.                         Ssql = Ssql & ",N_" & !ItemFieldName & "=(select " & aDo_Item!CloumnName2 & " from " & aDo_Item!TableName & " c where c." & aDo_Item!CloumnName1 & "=b." & !ItemFieldName & ")"
  1399.                     Else
  1400.                         Ssql = Ssql & ",N_" & !ItemFieldName & "=(select " & aDo_Item!CloumnName2 & " from " & aDo_Item!TableName & " c where c." & aDo_Item!CloumnName1 & "=a." & !ItemFieldName & ")"
  1401.                     End If
  1402.                 End If
  1403.             End If
  1404.             .MoveNext
  1405.         Loop
  1406.         Ssql = "select b.dcode,b.tcode,b.lcode,b.dname,b.manage,b.dxh,b.mader,b.zflag,b.mlevel,b.pdate,b.state,b.dno,b.conno,a.*,N_Lcode=(select isname from DEV_ItemSort c where convert(varchar(18),c.isid)=b.lcode)" & Ssql & " FROM DEV_RootInfo a,DEV_main b"
  1407.     End With
  1408.     Item_Info = Ssql
  1409. End Function
  1410. '====================单据编号格式化==============
  1411. Public Function BillCodeFormat(BillCode As String, Code As String) As String
  1412.     BillCode = Trim(BillCode): Code = Trim(Code)
  1413.     Dim Profix  As String       '前缀
  1414.     Dim Glida As Integer        '流水方式
  1415.     Dim CodeLen As Integer      '代码长度
  1416.     Dim aDo_re As New Recordset
  1417.     Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_BillNumber where BillCode='" & Trim(BillCode) & "'")
  1418.     If aDo_re.RecordCount > 0 Then
  1419.         Profix = aDo_re!Profix
  1420.         Glida = aDo_re!Glida
  1421.         CodeLen = aDo_re!CodeLen
  1422.     Else
  1423.         BillCodeFormat = "": Exit Function
  1424.     End If
  1425.     aDo_re.Close
  1426.     If Len(Code) >= Len(Profix) + CodeLen Then BillCodeFormat = Code: Exit Function
  1427.     If Glida = 0 Then
  1428.        If Len(Code) >= Len(Profix) Then
  1429.           If Profix <> Mid(Code, 1, Len(Profix)) Then
  1430.              BillCodeFormat = Profix & String(CodeLen - Len(Code), "0") & Code
  1431.           Else
  1432.              If Len(Code) = Len(Profix) Then BillCodeFormat = Code: Exit Function
  1433.              BillCodeFormat = Profix & String(CodeLen - Len(Code), "0") & Mid(Code, Len(Profix) + 1, Len(Code))
  1434.           End If
  1435.        Else
  1436.           BillCodeFormat = Profix & String(CodeLen - Len(Code), "0") & Code: Exit Function
  1437.        End If
  1438.     Else
  1439.        If Len(Code) >= Len(Profix) Then
  1440.           If Profix <> Mid(Code, 1, Len(Profix)) Then
  1441.                BillCodeFormat = Profix & Code
  1442.              Else
  1443.                BillCodeFormat = Code
  1444.           End If
  1445.        End If
  1446.     End If
  1447. End Function
  1448. '====================单据ID处理==================
  1449. Public Function CreatBillID(BillCode As String) As Integer
  1450.     '参数说明: BillCode 单据编码
  1451.     Dim BillType As String
  1452.     Dim aDo_re As New Recordset
  1453.     Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_BillNumber where BillCode='" & Trim(BillCode) & "'")
  1454.     If aDo_re.RecordCount > 0 Then
  1455.         CreatBillID = aDo_re!IDNow
  1456.         BillType = aDo_re!BillType
  1457.     End If
  1458.     aDo_re.Close
  1459.     Cw_DataEnvi.DataConnect.Execute "update  Gy_BillNumber set IDNow=IDNow+1 where BillType='" & Trim(BillType) & "'"
  1460. End Function
  1461. '====================单据编码处理==================
  1462. Public Function CreatBillCode(BillCode As String, Optional Add As Boolean = False, Optional KjYear As Integer, Optional Period As Integer, Optional WhCode As String) As String
  1463.     '参数说明: BillCode 单据编码,KjYear 会计年度,Period 会计期间,WhCode 仓库编码,Add 编号是累加(True 加,False,否)
  1464.     Dim BillCodeMode As Integer '编码方式
  1465.     Dim Profix  As String       '前缀
  1466.     Dim Glida As Integer        '流水方式
  1467.     Dim CodeLen As Integer      '代码长度
  1468.     Dim aDo_re As New Recordset
  1469.     Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_BillNumber where BillCode='" & Trim(BillCode) & "'")
  1470.     With aDo_re
  1471.         If .RecordCount > 0 Then
  1472.             BillCodeMode = !BillCodeMode
  1473.             Profix = !Profix
  1474.             Glida = !Glida
  1475.             CodeLen = !CodeLen
  1476.             .Close
  1477.         Else
  1478.             Exit Function
  1479.         End If
  1480.     End With
  1481.     
  1482.     Select Case BillCodeMode
  1483.            Case 0 '单据方式
  1484.               '=============
  1485.               Select Case Glida
  1486.                      Case 0
  1487.                           Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_Maxnum where BillCode='" & Trim(BillCode) & "'")
  1488.                           If aDo_re.RecordCount < 1 Then '当编号记录没有时
  1489.                               Cw_DataEnvi.DataConnect.Execute "insert into Gy_Maxnum(BillCode,NowNumber) VALUES ('" & Trim(BillCode) & "',1)"
  1490.                               CreatBillCode = Trim(Profix) & String(CodeLen - 1, "0") & 1
  1491.                           Else
  1492.                               CreatBillCode = Trim(Profix) & String(CodeLen - Len(aDo_re!NowNumBer), "0") & aDo_re!NowNumBer
  1493.                           End If
  1494.                           If Add = True Then
  1495.                               Cw_DataEnvi.DataConnect.Execute "update Gy_Maxnum set NowNumBer=NowNumBer+1  where BillCode='" & Trim(BillCode) & "'"
  1496.                           End If
  1497.                           Exit Function
  1498.                      Case 1
  1499.                           Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_Maxnum where BillCode='" & Trim(BillCode) & "' and KjYear= " & KjYear)
  1500.                           If aDo_re.RecordCount < 1 Then '当前年记录没有时
  1501.                               Cw_DataEnvi.DataConnect.Execute "insert into Gy_Maxnum(BillCode,Kjyear,NowNumber) VALUES ('" & Trim(BillCode) & "'," & KjYear & ",1)"
  1502.                               CreatBillCode = Trim(Profix) & KjYear & String(CodeLen - 1 - Len(Trim(Str(KjYear))), "0") & "1"
  1503.                           Else
  1504.                               CreatBillCode = Trim(Profix) & KjYear & String(CodeLen - Len(aDo_re!NowNumBer) - Len(Trim(Str(KjYear))), "0") & aDo_re!NowNumBer
  1505.                           End If
  1506.                           If Add = True Then
  1507.                               Cw_DataEnvi.DataConnect.Execute "update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" & Trim(BillCode) & "' and KjYear= " & KjYear
  1508.                           End If
  1509.                           Exit Function
  1510.                      Case 2
  1511.                           Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_Maxnum where BillCode='" & Trim(BillCode) & "' and KjYear= " & KjYear & " and Period=" & Period)
  1512.                           If aDo_re.RecordCount < 1 Then '当前年当前期间记录没有时
  1513.                               Cw_DataEnvi.DataConnect.Execute "insert into Gy_Maxnum(BillCode,Kjyear,Period,NowNumber) VALUES ('" & Trim(BillCode) & "'," & KjYear & "," & Period & ",1)"
  1514.                               CreatBillCode = Trim(Profix) & KjYear & String(2 - Len(Trim(Str(Period))), "0") & Period & String(CodeLen - 1 - Len(Trim(Str(KjYear))) - 2, "0") & "1"
  1515.                           Else
  1516.                               CreatBillCode = Trim(Profix) & KjYear & String(2 - Len(Trim(Str(Period))), "0") & Period & String(CodeLen - Len(aDo_re!NowNumBer) - Len(Trim(Str(KjYear))) - 2, "0") & aDo_re!NowNumBer
  1517.                           End If
  1518.                           If Add = True Then
  1519.                               Cw_DataEnvi.DataConnect.Execute "update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" & Trim(BillCode) & "' and KjYear= " & KjYear & " and Period=" & Period
  1520.                           End If
  1521.                           Exit Function
  1522.               End Select
  1523.               '==============
  1524.           Case 1 '单据+仓库方式
  1525.           
  1526.               '=============
  1527.               Select Case Glida
  1528.                      Case 0
  1529.                           Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_Maxnum where BillCode='" & Trim(BillCode) & "' and WhCode='" & Trim(WhCode) & "'")
  1530.                           If aDo_re.RecordCount < 1 Then '当编号记录没有时
  1531.                               Cw_DataEnvi.DataConnect.Execute "insert into Gy_Maxnum(BillCode,WhCode ,NowNumber) VALUES ('" & Trim(BillCode) & "','" & Trim(WhCode) & "',1)"
  1532.                               CreatBillCode = Trim(Profix) & Trim(WhCode) & String(CodeLen - 1 - Len(Trim(WhCode)), "0") & 1
  1533.                           Else
  1534.                               CreatBillCode = Trim(Profix) & Trim(WhCode) & String(CodeLen - Len(aDo_re!NowNumBer) - Len(Trim(WhCode)), "0") & aDo_re!NowNumBer
  1535.                           End If
  1536.                           If Add = True Then
  1537.                               Cw_DataEnvi.DataConnect.Execute "update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" & Trim(BillCode) & "' and WhCode='" & Trim(WhCode) & "'"
  1538.                           End If
  1539.                           Exit Function
  1540.                      Case 1
  1541.                           Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_Maxnum where BillCode='" & Trim(BillCode) & "' and KjYear= " & KjYear & " and WhCode='" & Trim(WhCode) & "'")
  1542.                           If aDo_re.RecordCount < 1 Then '当前年记录没有时
  1543.                               Cw_DataEnvi.DataConnect.Execute "insert into Gy_Maxnum(BillCode,Kjyear,WhCode,NowNumber) VALUES ('" & Trim(BillCode) & "'," & KjYear & ",'" & Trim(WhCode) & "',1)"
  1544.                               CreatBillCode = Trim(Profix) & Trim(WhCode) & KjYear & String(CodeLen - 1 - Len(Trim(Str(KjYear))) - Len(Trim(WhCode)), "0") & "1"
  1545.                           Else
  1546.                               CreatBillCode = Trim(Profix) & Trim(WhCode) & KjYear & String(CodeLen - Len(aDo_re!NowNumBer) - Len(Trim(Str(KjYear))) - Len(Trim(WhCode)), "0") & aDo_re!NowNumBer
  1547.                           End If
  1548.                           If Add = True Then
  1549.                               Cw_DataEnvi.DataConnect.Execute "update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" & Trim(BillCode) & "' and KjYear= " & KjYear & " and WhCode='" & Trim(WhCode) & "'"
  1550.                           End If
  1551.                           Exit Function
  1552.                      Case 2
  1553.                           Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_Maxnum where BillCode='" & Trim(BillCode) & "' and KjYear= " & KjYear & " and Period=" & Period & " and WhCode='" & Trim(WhCode) & "'")
  1554.                           If aDo_re.RecordCount < 1 Then '当前年当前期间记录没有时
  1555.                               Cw_DataEnvi.DataConnect.Execute "insert into Gy_Maxnum(BillCode,Kjyear,Period,WhCode,NowNumber) VALUES ('" & Trim(BillCode) & "'," & KjYear & "," & Period & ",'" & Trim(WhCode) & "',1)"
  1556.                               CreatBillCode = Trim(Profix) & Trim(WhCode) & KjYear & String(2 - Len(Trim(Str(Period))), "0") & Period & String(CodeLen - 1 - Len(Trim(Str(KjYear))) - 2 - Len(Trim(WhCode)), "0") & "1"
  1557.                           Else
  1558.                               CreatBillCode = Trim(Profix) & Trim(WhCode) & KjYear & String(2 - Len(Trim(Str(Period))), "0") & Period & String(CodeLen - Len(aDo_re!NowNumBer) - Len(Trim(Str(KjYear))) - 2 - Len(Trim(WhCode)), "0") & aDo_re!NowNumBer
  1559.                           End If
  1560.                           If Add = True Then
  1561.                               Cw_DataEnvi.DataConnect.Execute "update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" & Trim(BillCode) & "' and KjYear= " & KjYear & " and Period=" & Period & " and WhCode='" & Trim(WhCode) & "'"
  1562.                           End If
  1563.                           Exit Function
  1564.               End Select
  1565.               '==============
  1566.           
  1567.     End Select
  1568. End Function
  1569. '图形分析
  1570. Public Sub Txfxbb(CxbbGrid As vsFlexGrid, ChartCode As String, ParamArray charttype())               '图形分析模块
  1571.   '过程参数为:分析网格,图形代码,脚标,分析项目数,分析网格起始行值,分析网格终止行值
  1572.   On Error Resume Next
  1573.   
  1574.   Dim aDo_Char As New Recordset
  1575.   Dim Jsqte As Integer
  1576.   Dim i As Integer: Dim r As Integer
  1577.   Dim h As Integer: Dim s As Integer: h = 0: s = 0
  1578.   '---------------------
  1579.   Set aDo_Char = Cw_DataEnvi.DataConnect.Execute("select * from XT_GridChart where Chart_Code='" & ChartCode & "'")
  1580.   If aDo_Char.RecordCount = 0 Then MsgBox "图形基础设置错误! ", 16: Exit Sub
  1581.     '-----------------------------
  1582.   If CxbbGrid.Rows - aDo_Char!grid_Fixedrows < 1 Then
  1583.      Exit Sub
  1584.   End If
  1585.   '---------------------
  1586.   XT_TxItem.ChartCode = ChartCode
  1587.   Set XT_TxItem.Grid = CxbbGrid
  1588.   XT_TxItem.Tag = "F"
  1589.   XT_TxItem.Show 1
  1590.   If XT_TxItem.Tag <> "T" Then Exit Sub
  1591.  
  1592.   '---------------------
  1593.   With XT_TxfxFrm.Txfxchart
  1594.     .Header.Text.Clear
  1595.     .Header.Text.Add aDo_Char!Chart_Titlete
  1596.     .Footer.Text.Clear
  1597.     .RemoveAllSeries
  1598.     .Aspect.View3d = False
  1599.     
  1600.   If XT_TxItem.Check1.Value = 0 Then   '横标统计
  1601.             '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1602.             For r = 0 To XT_TxItem.Item(0).ListCount - 1
  1603.                If XT_TxItem.Item(0).Selected(r) = True Then
  1604.                '---------------
  1605.                       If UBound(charttype()) > 1 Then '显示的图形类型
  1606.                          Select Case charttype(1)
  1607.                                Case 1: .AddSeries scBar
  1608.                                Case 2: .AddSeries scLine: Case 3: .AddSeries scArea
  1609.                                Case 4: .AddSeries scHorizBar: Case 5: .AddSeries scPoint
  1610.                                Case 6: .AddSeries scFastLine: Case 7: .AddSeries scFastLine
  1611.                          End Select
  1612.                       Else
  1613.                         .AddSeries scBar
  1614.                       End If
  1615.                       '------------------'读取数据
  1616.                       .Series(s).Marks.Style = smsValue
  1617.                       XT_TxItem.Item(0).ListIndex = r: .Series(s).Title = XT_TxItem.Item(0).Text
  1618.                       For Jsqte = aDo_Char!grid_Fixedrows To Val(CxbbGrid.Rows - 1)
  1619.                          If XT_TxItem.Item(1).Selected(Jsqte - aDo_Char!grid_Fixedrows) = True Then
  1620.                           .Series(s).ValueFormat = "#,##0.####"
  1621.                           .Series(s).Add Val(CxbbGrid.TextMatrix(Jsqte, XT_TxItem.Item(0).ItemData(r))), CxbbGrid.TextMatrix(Jsqte, aDo_Char!grid_FixedCols - 1), clTeeColor
  1622.                           If XT_TxItem.Check2.Value = 0 Then
  1623.                             .Series(s).Marks.Visible = False
  1624.                           End If
  1625.                          End If
  1626.                       Next Jsqte
  1627.                       s = s + 1
  1628.                 '---------------
  1629.                 End If
  1630.             Next r
  1631.           '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1632.     Else
  1633.           '竖表统计
  1634.           '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1635.                For r = 0 To XT_TxItem.Item(1).ListCount - 1
  1636.                If XT_TxItem.Item(1).Selected(r) = True Then
  1637.                '---------------
  1638.                       If UBound(charttype()) > 1 Then '显示的图形类型
  1639.                          Select Case charttype(1)
  1640.                                Case 1: .AddSeries scBar
  1641.                                Case 2: .AddSeries scLine: Case 3: .AddSeries scArea
  1642.                                Case 4: .AddSeries scHorizBar: Case 5: .AddSeries scPoint
  1643.                                Case 6: .AddSeries scFastLine: Case 7: .AddSeries scFastLine
  1644.                          End Select
  1645.                       Else
  1646.                         .AddSeries scBar
  1647.                       End If
  1648.                       '------------------'读取数据
  1649.                       .Series(s).Marks.Style = smsValue
  1650.                       .Series(s).Title = CxbbGrid.TextMatrix(r + aDo_Char!grid_Fixedrows, aDo_Char!grid_FixedCols - 1)
  1651.                 
  1652.                       For Jsqte = aDo_Char!grid_FixedCols To CxbbGrid.Cols - 1
  1653.                           If XT_TxItem.Item(0).Selected(Jsqte - aDo_Char!grid_FixedCols) = True Then
  1654.                              .Series(s).ValueFormat = "#,##0.####"
  1655.                              .Series(s).Add Val(CxbbGrid.TextMatrix(XT_TxItem.Item(1).ItemData(r), Jsqte)), CxbbGrid.TextMatrix(aDo_Char!grid_Fixedrows - 1, Jsqte), clTeeColor
  1656.                              If XT_TxItem.Check2.Value = 0 Then
  1657.                                .Series(s).Marks.Visible = False
  1658.                              End If
  1659.                           End If
  1660.                       Next Jsqte
  1661.                       s = s + 1
  1662.                 '---------------
  1663.                 End If
  1664.             Next r
  1665.             '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1666.           
  1667.     End If
  1668.     
  1669.     
  1670.   End With
  1671.   '
  1672.   XT_TxfxFrm.Txcode = ChartCode
  1673.   Set XT_TxfxFrm.bbGrid = CxbbGrid
  1674.   XT_TxfxFrm.Hide
  1675.   XT_TxfxFrm.Show 1
  1676.   
  1677. End Sub