?? 系統(tǒng)_基本函數(shù)模塊.bas
字號:
Public Function Fun_Jezh(Jesj As Double) As String
Dim Name1$, Name2$, Mje1$, Name$
Dim len_mje1%, k%, Ws%, j%, ws1%, m%
Dim BZ As Boolean
Name1 = "壹貳叁肆伍陸柒捌玖"
Name2 = "分角元拾佰仟萬拾佰仟億拾佰仟"
Mje1 = Trim(Format(Jesj, "###.00"))
len_mje1 = Len(Mje1)
If len_mje1 > 16 Or Jesj < 0.01 Or IsNull(Jesj) Then
Fun_Jezh = ""
Exit Function
End If
'//取無小數(shù)的字符串
Mje1 = Left(Mje1, len_mje1 - 3) + Right(Mje1, 2)
len_mje1 = len_mje1 - 1
k = len_mje1 * 2 - 1
Ws = Int(Mid(Mje1, 1, 1)) * 2 - 1
If len_mje1 = 3 And Ws < 0 Then '//如果金額<1 name=''
Name = ""
Else
If Ws > 0 Then
Name = MidB(Name1, Ws, 2) + MidB(Name2, k, 2) '//如果金額>=1,轉(zhuǎn)換金額
End If
End If
j = 2
k = k - 2
BZ = True
xh1:
Do While j <= len_mje1 And BZ
ws1 = Int(Mid(Mje1, j, 1)) * 2 - 1
If ws1 > 0 Then
Name = Name + MidB(Name1, ws1, 2) + MidB(Name2, k, 2)
j = j + 1
k = k - 2
GoTo xh1
End If
m = 0
xh2:
Do While ws1 < 0
If len_mje1 >= 11 Then
If k < 21 Then
m = m + 1
End If
End If
If k = 5 Or (k = 13 And m <= 3) Or k = 21 Then
Name = Name + MidB(Name2, k, 2)
End If
If k = 1 Then
Name = Name + "整"
BZ = False
Exit Do
End If
j = j + 1
k = k - 2
ws1 = Int(Mid(Mje1, j, 1)) * 2 - 1
If ws1 < 0 Then
GoTo xh2
Else
If len_mje1 = 3 Then
Name = Name + "零"
Else
Name = Name + "零"
End If
End If
Loop
Loop
'去掉元和角之間零(1230.32)
wz1 = InStr(1, Name, "元")
wz2 = InStr(1, Name, "角")
If wz1 <> 0 And wz2 <> 0 Then
wz3 = InStr(wz1, Name, "零")
If wz3 <> 0 Then
Name = Mid(Name, 1, wz3 - 1) + Mid(Name, wz3 + 1, Len(Name))
End If
End If
Fun_Jezh = Name
End Function
Public Function FillImageCombo(Combote As ImageCombo, ComboCode As String, AddType As Integer) '填充列表框(ImageCombo)并定位
'函數(shù)參數(shù):列表框(ImageCombo),ComboCode列表框分組編碼
'AddType 項(xiàng)目填充類型(0-填充索引+內(nèi)容,無空記錄 1-僅填充內(nèi)容,無空記錄 2-填充索引+內(nèi)容,有空記錄 3-僅填充內(nèi)容,有空記錄)
Dim Rec_Combo As ADODB.Recordset '填充屬性
Dim Rec_FillText As ADODB.Recordset '填充內(nèi)容
Dim ci As ComboItem
Dim jsqte As Integer '臨時計數(shù)器
Combote.ComboItems.Clear
jsqte = 1
'填充列表框內(nèi)容
Set Rec_Combo = Cw_DataEnvi.DataConnect.Execute("Select * From Xt_ImageCombo Where combo_code='" + Trim(ComboCode) + "'")
With Rec_Combo
Combote.Locked = True
If AddType = 2 Or AddType = 3 Then
Set ci = Combote.ComboItems.Add(, "@")
jsqte = jsqte + 1
End If
Set Rec_FillText = Cw_DataEnvi.DataConnect.Execute(Trim(.Fields("Sql_String")))
Do While Not Rec_FillText.EOF
Select Case AddType
Case 0, 2 '填充索引+內(nèi)容
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")))))
Case 1, 3 '僅填充記錄內(nèi)容
Set ci = Combote.ComboItems.Add(, "@" + Trim(Rec_FillText.Fields(Trim(.Fields("ItemKey")))), Trim(Rec_FillText.Fields(Trim(.Fields("ItemText")))))
End Select
jsqte = jsqte + 1
Rec_FillText.MoveNext
Loop
If Combote.ComboItems.Count <> 0 Then
Combote.ComboItems.Item(1).Selected = True
End If
End With
End Function
Public Function GetComboKey(Combote As ImageCombo, KeyOrName As Integer) As String '取得用戶選中列表框項(xiàng)目Key值或內(nèi)容
'函數(shù)參數(shù):列表框(ImageCombo),KeyOrName 0--取項(xiàng)目Key值 1--取選項(xiàng)內(nèi)容值
Dim jsqte As Integer '臨時計數(shù)器
If KeyOrName = 0 Then
'去掉首位@
For jsqte = 1 To Combote.ComboItems.Count
If Combote.ComboItems(jsqte).Text = Combote.Text Then
Exit For
End If
Next jsqte
If Combote.ComboItems.Count > 0 Then
GetComboKey = Trim(Mid(Combote.ComboItems(jsqte).Key, 2, Len(Combote.ComboItems(jsqte).Key)))
End If
Else
GetComboKey = Trim(Combote.Text)
End If
End Function
Public Sub Sub_CodeScheme(ItemCodeTe As String, Int_CodeLev As Integer, Int_CodeScheme() As Integer) '生成相應(yīng)各級編碼長度到數(shù)組中(編碼方案)
'函數(shù)參數(shù):ItemCodeTe 編碼方案代碼,Int_CodeLev 返回編碼最大級數(shù),Int_CodeScheme() 返回各級編碼長度
'ForExample:會計科目編碼:322222 結(jié)果:Int_CodeLev=6 Int_CodeScheme()=3 5 7 9 11 13
Dim Rec_CodeScheme As New ADODB.Recordset '編碼方案動態(tài)集
Set Rec_CodeScheme = Cw_DataEnvi.DataConnect.Execute("Select CodeScheme From Gy_CodeScheme Where ItemCode='" & Trim(ItemCodeTe) & "'")
With Rec_CodeScheme
If Not .EOF Then
Int_CodeLev = Len(Trim(.Fields("CodeScheme")))
ReDim Int_CodeScheme(Int_CodeLev)
lenjsq = 0
For jsqte = 1 To Int_CodeLev
lenjsq = lenjsq + Mid(Trim(.Fields("CodeScheme")), jsqte, 1)
Int_CodeScheme(jsqte) = lenjsq
Next jsqte
End If
.Close
End With
End Sub
Public Sub Sub_SetOperStatus(Str_OperStatus As String) '顯示系統(tǒng)操作狀態(tài)
If Trim(Str_OperStatus) <> "" Then
XT_Main.StatusBar1.Panels("OperStatus") = Str_OperStatus
Else
XT_Main.StatusBar1.Panels("OperStatus") = "就緒"
End If
End Sub
Public Sub Sub_ReadBillInfo(BillCode As String, Frm_Bill As Form, Var_Bill() As Variant) '讀入單據(jù)整體設(shè)計信息(錄入)
'參數(shù)說明:BillCode 單據(jù)編碼(索引號) ,Frm_Bill 單據(jù)窗體 , VarBill 用來返回單據(jù)設(shè)計信息
Dim RecTemp As New ADODB.Recordset '臨時使用動態(tài)集
ReDim Var_Bill(1 To 5) '返回單據(jù)設(shè)計信息
Set RecTemp = Cw_DataEnvi.DataConnect.Execute("Select * From xt_BillDesign Where BillCode='" & Trim(BillCode) & "'")
With RecTemp
If Not .EOF Then
Frm_Bill.Height = .Fields("FormHeight") '設(shè)置窗體高度
Frm_Bill.Width = .Fields("FormWidth") '設(shè)置窗體寬度
Var_Bill(1) = Trim(.Fields("BillName")) '單據(jù)描述
Frm_Bill.Caption = Var_Bill(1) '單據(jù)描述賦予窗體Caption
Var_Bill(2) = Trim(.Fields("BillTitle")) '單據(jù)標(biāo)題
Var_Bill(3) = Trim(.Fields("Text_Group_Code")) '單據(jù)所使用文本框組索引號
Var_Bill(4) = Trim(.Fields("Grid_Code")) '單據(jù)所使用網(wǎng)格組索引號
Var_Bill(5) = Trim(.Fields("Print_Code")) '單據(jù)所使用打印參數(shù)索引號
End If
End With
End Sub
Public Sub Sub_DPReadBillInfo(BillCode As String, Frm_Bill As Form, Var_Bill() As Variant) '讀入單據(jù)整體設(shè)計信息(打印)
'參數(shù)說明:BillCode 單據(jù)編碼(索引號) Frm_Bill 單據(jù)窗體 VarBill 用來返回單據(jù)設(shè)計信息
Dim RecTemp As New ADODB.Recordset
ReDim Var_Bill(1 To 3)
Set RecTemp = Cw_DataEnvi.DataConnect.Execute("Select * From xt_BillDesign Where BillCode='" & Trim(BillCode) & "'")
With RecTemp
If Not .EOF Then
Frm_Bill.Pict.Height = .Fields("FormHeight") - 375 '設(shè)置窗體高度
Frm_Bill.Pict.Width = .Fields("FormWidth") '設(shè)置窗體寬度
Frm_Bill.Lab_Title = Trim(.Fields("BillName")) '單據(jù)標(biāo)題
Var_Bill(1) = Trim(.Fields("BillName")) '單據(jù)描述
Frm_Bill.Caption = Frm_Bill.Tag & "/" & Var_Bill(1) '單據(jù)描述賦予窗體Caption
Var_Bill(2) = Trim(.Fields("Text_Group_Code")) '單據(jù)所使用文本框組索引號
Var_Bill(3) = Trim(.Fields("Grid_Code")) '單據(jù)所使用網(wǎng)格組索引號
End If
End With
End Sub
Public Sub DPBcwggs(Bcgsgrid As vsFlexGrid, Wggsdm As String) '保存網(wǎng)格格式(包括網(wǎng)格列寬,網(wǎng)格列順序)
'過程參數(shù):保存格式網(wǎng)格對象,網(wǎng)格格式代碼(網(wǎng)格參數(shù))
Dim Tsxx As String
Dim RecTemp As New ADODB.Recordset
Dim Qslzte As Integer
Cw_DataEnvi.DataConnect.BeginTrans
On Error GoTo Swcwcl
If RecTemp.State = 1 Then RecTemp.Close
RecTemp.Open "select * from xt_grid where Grid_Code='" + Trim(Wggsdm) + "' order by ColId", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
With RecTemp
If Not .EOF Then
Qslzte = .Fields("BeginCol")
.MoveNext
End If
Do While Not .EOF
For jsqte = Qslzte To Bcgsgrid.Cols - 1
If Bcgsgrid.FixedRows = 1 Then
If Trim(.Fields("ColTitle1")) = Trim(Bcgsgrid.TextMatrix(0, jsqte)) Then
Exit For
End If
Else
If Trim(.Fields("ColTitle1")) = Trim(Bcgsgrid.TextMatrix(0, jsqte)) And Trim(.Fields("ColTitle2")) = Trim(Bcgsgrid.TextMatrix(1, jsqte)) Then
Exit For
End If
End If
Next jsqte
If jsqte <= Bcgsgrid.Cols - 1 Then
.Fields("ColId") = jsqte - Qslzte + 1
.Fields("ColWidth") = Bcgsgrid.ColWidth(jsqte)
.Update
Else
GoTo Swcwcl
End If
.MoveNext
Loop
End With
Cw_DataEnvi.DataConnect.CommitTrans
Tsxx = "表格格式保存完畢!"
Call Xtxxts(Tsxx, 0, 4)
Exit Sub
Swcwcl:
Cw_DataEnvi.DataConnect.RollbackTrans
Tsxx = "存盤過程中出現(xiàn)未知錯誤,程序自動恢復(fù)保存前狀態(tài)!"
Call Xtxxts(Tsxx, 0, 1)
Exit Sub
End Sub
'===================以下為系統(tǒng)權(quán)限控制與上機(jī)日志控制函數(shù)======================'
Public Function Security_Log(gnsy As String, UserCode As String, Optional LogTF As Integer = 3, Optional State As Boolean = True) As Boolean '權(quán)限判斷和日志
'Gnsy 功能索引 UserCode 用戶編碼
'LogTF (1、判斷權(quán)限,寫日志)、(2、只寫日志)、(3、只判斷權(quán)限)
'State 狀態(tài) (True 進(jìn)入 false 完成)
'返回Security_Log=true表示有權(quán)限,Security_Log=false表示沒有有權(quán)限
Dim Tsxx As String '系統(tǒng)信息提示
On Error Resume Next
Dim aDo_userGroup As New Recordset
Dim aDo_gnbm As New Recordset: Dim Ssql As String
Set aDo_gnbm = Cw_DataEnvi.DataConnect.Execute("select * from Xt_xtgnb where gnsy='" & Trim(gnsy) & "'")
If LogTF = 1 Or LogTF = 3 Then
Set aDo_userGroup = Cw_DataEnvi.DataConnect.Execute("select * from Gy_Czygl where czybm='" & Trim(UserCode) & "'")
If Mid(aDo_userGroup!AuthorityID, aDo_gnbm!Id, 1) = "1" Then
Security_Log = True
Else
Security_Log = False
End If
aDo_userGroup.Close
Set aDo_userGroup = Nothing
If Security_Log = False Then
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))
Do While Not aDo_userGroup.EOF
If Mid(aDo_userGroup!AuthorityID, aDo_gnbm!Id, 1) = "1" Then
Security_Log = True
Exit Do
Else
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -