📄 c_common.vb
字号:
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Imports SW = System.Web
'****************************************************************
' OptimaxOwner
' Copyright (c) 2006 OptimaxOwner.
'****************************************************************
'****************************************************************
'ファイル名 : C_common.vb
'項目名称 : WebApp
'機能概要 : 共通処理
'作成者 : Zhangl
'確認者 : WeiZY
'編集日付 : 2006.11.26
'修正者 :
'修正日付 :
'修正内容概要 :
'****************************************************************
Public Class C_Common
#Region "定数定義"
'色データのフラグ
Private Const COLOR_PREFIX As String = "#"
Private Const INTID As String = "1"
Private Const WEBACCESS As String = "WebAccessConnectionString"
Private Const MAO As String = ":"
Private Const XIE As String = "/"
Private Const ZERO As String = "0"
Private Const CONNECTSTRNOTEXIT As String = "データバース接続定義がありません。"
Private Const WEBACCESSHEAD As String = "WebAccess操作"
'page group
#End Region
'*******************************************
'機能概要 :色データ取得
'引数の説明 :strColor 色の名
'返却値の説明 :色データ
'機能詳細 :色の名から、色のデータを取得する。
'作成日/作成者 :2006.11.26 ZhangL
'*******************************************
Public Shared Function fGetColor(ByVal strColor As String) As System.Drawing.Color
'データ取得
Dim colorRet As System.Drawing.Color = System.Drawing.Color.FromName(strColor)
If Not colorRet.IsKnownColor Then
'有効データではない場合
colorRet = System.Drawing.Color.FromName(COLOR_PREFIX & strColor)
End If
'戻る
Return colorRet
End Function
'*******************************************
'機能概要 :適当な色の名前取得
'引数の説明 :strColor 色の名
'返却値の説明 :色データ
'機能詳細 :色の名から、適当な色の名前を取得する。
'作成日/作成者 :2006.11.26 ZhangL
'*******************************************
Public Shared Function fGetColorName(ByVal strColor As String) As String
'戻り値
Dim strRet As String = strColor
'データ取得
Dim colorRet As System.Drawing.Color = System.Drawing.Color.FromName(strRet)
If Not colorRet.IsKnownColor Then
'有効データではない場合
strRet = COLOR_PREFIX & strColor
End If
'戻る
Return strRet
End Function
#Region "共通関数"
'********************************************
'機能概要 :transform Date into string as "YYYYMMDD"
'引数の説明 :strDate
'返却値の説明 :処理後のstrChanged
'機能詳細 :strChanged
'作成日/作成者 :2006.11.26 ZhangL
'********************************************
Public Shared Function fDateChange(ByVal strDate As Date) As String 'change the type of Date into string
Dim strChanged As String = ""
If (strDate.Month.ToString.Length = 1) Then
If (strDate.Day.ToString.Length = 1) Then 'the month with one digit number
strChanged = strDate.Year.ToString & "0" & strDate.Month.ToString & "0" & strDate.Day.ToString
Else : strChanged = strDate.Year.ToString & "0" & strDate.Month.ToString & strDate.Day.ToString
End If
ElseIf (strDate.Month.ToString.Length = 2) Then 'the month with two digits number
If (strDate.Day.ToString.Length = 1) Then 'the day with one digits number
strChanged = strDate.Year.ToString & strDate.Month.ToString & "0" & strDate.Day.ToString
Else : strChanged = strDate.Year.ToString & strDate.Month.ToString & strDate.Day.ToString
End If
End If
Return strChanged
End Function
'********************************************
'機能概要 :transform Date into string as "YYYYMMDD"
'引数の説明 :strDate
'返却値の説明 :処理後のstrChanged
'機能詳細 :strChanged
'作成日/作成者 :2006.11.26 ZhangL
'********************************************
Public Shared Function fChangetoDate(ByVal strDate As String) As String 'change the type of Date into string
Dim strChanged As String = ""
strDate.Substring(0, 4)
strDate.Substring(4, 2)
strDate.Substring(6, 2)
strChanged = strDate.Substring(4, 2) & "/" & strDate.Substring(6, 2) & "/" & strDate.Substring(0, 4)
Dim datetemp As Date = FormatDateTime(strChanged)
Return datetemp
End Function
'********************************************
'機能概要 :transform DB data into 分数
'引数の説明 :intTime:second from DB
' intTimeDiff:日替り時刻
' intScheduleUnit: スケジュール最小単位
'返却値の説明 :処理後のintTime,時刻の分数
'機能詳細 :transform
'作成日/作成者 :2006.11.26 ZhangL
'********************************************
Public Shared Function fGetValueFromDB(ByVal intTime As Integer, ByVal intTimeDiff As Integer, ByVal intScheduleUnit As Integer) As Integer
Return Int(intTime / 60) + intTimeDiff * intScheduleUnit
End Function
'********************************************
'機能概要 :transform Hour Minute into second
'引数の説明 :intHour:
' intMinute:
' intTimeDiff:日替り時刻
' intScheduleUnit:スケジュール最小単位
'返却値の説明 :処理後のintTime,(unit minute)
'機能詳細 :transform
'作成日/作成者 :2006.11.26 ZhangL
'********************************************
Public Shared Function fGetValueFromHourMinu(ByVal intHour As Integer, _
ByVal intMinute As Integer, _
ByVal intTimeDiff As Integer, _
ByVal intScheduleUnit As Integer, _
Optional ByVal intSecond As Integer = 0) As Integer
'update by li 2006.10.24
Return Int(intHour * 60 * 60 + intMinute * 60 + intSecond) - intTimeDiff * intScheduleUnit * 60
End Function
'********************************************
'機能概要 :transform intTime
'引数の説明 :intTime:second from DB
' intScheduleUnit:スケジュール最小単位
'返却値の説明 :処理後のintTime,(unit:Schedule Unit )
'機能詳細 :transform
'作成日/作成者 :2006.11.26 ZhangL
'********************************************
Public Shared Function fChangeToUnit(ByVal intTime As Integer, _
ByVal intScheduleUnit As Integer, _
Optional ByVal blnEnd As Boolean = False) As Integer
Dim intAdd As Integer = 0
If blnEnd Then
If intTime Mod (60 * intScheduleUnit) <> 0 Then
intAdd = 1
End If
End If
Return Int(intTime / (60 * intScheduleUnit)) + intAdd
End Function
'********************************************
'機能概要 :Check then input Data
'引数の説明 :strInput : the string get from TextBox
' intInteger_Length :整数桁数
' intInteger_Length :少数桁数
' intMax_Value :最大値
' intMin_Value :最小値
'返却値の説明 :boolean : true the input is right.else wrong
'機能詳細 :transform the input in right formot,and return whether the data is valueable
'作成日/作成者 :2006.11.29 wanghx
'********************************************
Public Shared Function fCheckFormatData(ByRef strInput As String, _
ByRef intInteger_Length As Integer, _
ByRef intDecimal_Length As Integer, _
ByRef intMax_Value As Integer, _
ByRef intMin_Value As Integer) As Boolean
Dim intLength As Integer = 0
Dim intDecLength As Integer = 0
If IsNumeric(strInput) = False Then 'if the input is can't change to number
Return False
End If
intLength = strInput.IndexOf(".") 'there have demical pot,get the Integer_Length
If intLength = -1 Then 'if the input is integer ,get the Integer_Length
intLength = strInput.Length
Else
intDecLength = strInput.Length - strInput.LastIndexOf(".") - 1
End If
If intLength > intInteger_Length Then 'the input number's Integer_Length > needed intInteger_Length ,return false
Return False
End If
If intDecLength > intDecimal_Length Then 'the input number's Integer_Length > needed intInteger_Length ,return false
Return False
End If
If Not (intMin_Value <= Val(strInput) And Val(strInput) <= intMax_Value) Then
Return False
End If
'format the input
If intDecimal_Length > 0 Then
strInput = Format(Val(strInput), "0." & StrDup(intDecimal_Length, "0"))
Else
strInput = Format(Val(strInput), "0")
End If
Return True
End Function
'********************************************
'機能概要 :Check then input Data
'引数の説明 :strInput : the string get from TextBox
' intInteger_Length :整数桁数
' intInteger_Length :少数桁数
'返却値の説明 :boolean : true the input is right.else wrong
'機能詳細 :transform the input in right formot,and return whether the data is valueable
'作成日/作成者 :2006.11.29 wanghx
'********************************************
Public Shared Function fCheck_ChangeData(ByRef strInput As String, _
ByRef intInteger_Length As Integer, _
ByRef intDecimal_Length As Integer) As Boolean
Dim intLength As Integer = 0
Dim intDecLength As Integer = 0
If IsNumeric(strInput) = False Then 'if the input is can't change to number
Return False
End If
intLength = strInput.IndexOf(".") 'there have demical pot,get the Integer_Length
If intLength = -1 Then 'if the input is integer ,get the Integer_Length
intLength = strInput.Length
Else
intDecLength = strInput.Length - strInput.LastIndexOf(".") - 1
End If
If intLength > intInteger_Length Then 'the input number's Integer_Length > needed intInteger_Length ,return false
Return False
End If
If intDecLength > intDecimal_Length Then 'the input number's Integer_Length > needed intInteger_Length ,return false
Return False
End If
'format the input
If intDecimal_Length > 0 Then
strInput = Format(Val(strInput), "0." & StrDup(intDecimal_Length, "0"))
Else
strInput = Format(Val(strInput), "0")
End If
Return True
End Function
'********************************************
'機能概要 :format the output data
'引数の説明 :strInput : the string get from dtabase
' intInteger_Length :少数桁数
'返却値の説明 :boolean : true the input is right.else wrong
'機能詳細 :transform the data in right formot,and return the data
'作成日/作成者 :2006.11.29 wanghx
'********************************************
Public Shared Function fChangeShowData(ByVal strFromDB As String, ByVal intDecimal_Length As Integer) As String
If IsNumeric(strFromDB) = False Then 'if the input is can't change to number
Return strFromDB
End If
'format the output
If intDecimal_Length > 0 Then
strFromDB = Format(Val(strFromDB), "0." & StrDup(intDecimal_Length, "0"))
Else
strFromDB = Format(Val(strFromDB), "0")
End If
Return strFromDB
End Function
#End Region
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -