Files
Karodeung/Epole/Common.vb
2019-05-03 22:28:16 +09:00

268 lines
9.9 KiB
VB.net

Imports System.Net
Imports System.Net.Dns
Module Common
Enum ESorted
No = 1
YES = 2
NULL = 0
End Enum
Enum E_AuthType
Admin = 1
Normal = 0
Demo = -9
End Enum
Structure S_AuthInfo
Dim Type As E_AuthType '//인증형태
Dim Cnt As Short '//무료사용횟수(데모모드시)
Dim ExpireDate As String
Dim Id As String '//사용자Id
Dim Name As String '//사용자명
Dim authmsg As String
Dim Permission() As Char '//권한
End Structure
Structure Cfont
Dim FontName As String
Dim FontSize As Int16
End Structure
Structure Str_Alllabels '레이블들을 저장한다.
Dim ctl As CEpole.C_label
Dim desc As String
End Structure
Structure SStyle
Dim Desc As String
Dim File As String
Dim Backimg As String
Dim MarginX As Integer
Dim MarginY As Integer
Dim ScaleX As Single
Dim ScaleY As Single
Dim PrintFontOffset As Integer
Dim Viewimage As Boolean
Dim LandScape As Boolean
Dim Dummy As Boolean
Dim Dummytype As Short
Dim dummmyx As Short
Dim dummmyy As Short
Dim picstyle As Short
Dim CanvasX As Integer
Dim CanvasY As Integer
Dim Filter As String
Dim PATTERNTABLE As DataTable
End Structure
Public StyleList() As SStyle
Public DataBaseFile As String = My.Application.Info.DirectoryPath & "\database\irea.mdb"
Public ini As New ACC.MyINI(My.Application.Info.DirectoryPath & "\epole.ini")
'Public ConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBaseFile
Public Arin As New acc.ARINCLASS
Public ArinPath As New acc.MyPath
Public Auto_Log As Boolean = False '//디비나 각종 로그파일을 쌓을지 여부
Public PICmanFile As String = vbNullString '//그림관리프로그램의 파일명을 적는다.
Public MakeState As String = vbNullString
Public PoleState As String = vbNullString
Public PoleEtcState As String = vbNullString
Public PicState As String = vbNullString '/그림파일연결관리다.
Public HelpWebSite As String = vbNullString '//웹페이지주소 일단은 도움말을 얻기위해쓴다.
Public HomePage As String = vbNullString
Public SORTNULL As Boolean = True '//전주세부-정렬이 번호가 비어잇을경우 가장위에표시할지 아닐지!
Public NUMCOLOR As Boolean '//가공번호찰에서 번호에 색상을 지정할지
'Public Admin As Boolean = False '//개발자모드로 접속햇을때
Public ViewFont As Cfont '//뷰의 글자
Public MenuFont As Cfont '//메뉴의 글자
Public FormFont As Cfont '//폼의 글자
Public UserInfo As S_AuthInfo '//사용자정보
Public Enum Work_Type
kakong = 0
jijung = 1
suyong = 2
tongsin = 3
karodung = 4
jongakdung = 5
boandung = 6
Sknetworks = 7
End Enum
Public Sub Work_Form(ByVal T As String)
Form_Work.Show()
Form_Work.Msg(T)
End Sub
Public Function Get_SavePatternString(ByVal 저장대상 As String, ByVal pc As Boolean, ByVal cp As String, ByVal pl As Boolean, ByVal pstr As String, ByVal plen As Short, _
ByVal pchr As String) As System.Text.StringBuilder
If pc Then cp = "[문자패턴]"
If pl Then cp &= "[길이패턴]"
If cp = "" Then cp = "[패턴없음]"
Dim Msg As New System.Text.StringBuilder("(" & 저장대상 & ")" & " 패턴을 저장합니다")
'//문자패턴이 적용되어있다면 문자패턴으로 적용할 것을 궎장하며 그렇지 않은 경우에는 길이패턴이나 문자패턴을 적절히 권장한다.
'//길이가 5자리이하이고 특수문자(-,;)등이 없는경우에 길이패턴 적용을 권유한다.
Msg.AppendLine()
Msg.AppendLine("패턴 저장방법에는 길이,문자가 있습니다")
Msg.AppendLine("패턴우선순위 : 문자패턴 -> 길이패턴")
Msg.AppendLine()
Msg.AppendLine("현재적용된 패턴 : " & cp)
If pc Then
Msg.AppendLine()
Msg.AppendLine(">> 현재 문자패턴이 적용되어있습니다" & vbCrLf & ">> 문자패턴은 가장우선되는 패턴방식입니다")
Msg.AppendLine(">> 저장시에는 [문자패턴]으로 저장하시기 바랍니다.")
Msg.AppendLine(">> [길이패턴]으로 저장하는것은 의미가 없습니다")
ElseIf pl Then
Msg.AppendLine()
Msg.AppendLine(">> 현재 길이패턴이 적용되어있습니다" & vbCrLf & ">> 패턴은 길이,문자 둘다 저장이 가능합니다")
Else
Msg.AppendLine()
Msg.AppendLine(">> 적용된 패턴이없습니다")
Msg.AppendLine(">> 문자수(길이)가 적은 문자의경우 [길이패턴] 저장을 권장합니다")
End If
Msg.AppendLine()
Msg.AppendLine("길이패턴이란? (문자의 길이가 같을떄 적용)")
Msg.AppendLine(" 선택된문자는 " & pstr & " 이며 길이는 = " & plen & " 입니다")
Msg.AppendLine(" 저장을 하면 " & 저장대상 & " 의 길이가 " & plen & vbCrLf & " 인 문자가 오면 패턴이 적용됩니다")
Msg.AppendLine()
Msg.AppendLine("문자패턴이란? (같은 형태의 문자일때 적용)")
Msg.AppendLine(" 선택된문자는 " & pstr & " 이며 형태는 = " & pchr & " 입니다")
Msg.AppendLine(" 저장을 하면 " & 저장대상 & " 의 형태가 " & pchr & vbCrLf & " 인 문자가 오면 패턴이 적용됩니다")
Msg.AppendLine(" * 1=숫자,0=알파벳문자,H=한글문자,;=특수문자(;),-=특수문자(-)")
Msg.AppendLine()
Msg.AppendLine("패턴우선순위란? (패턴이 중복적용되었을때 높은우선순위가 적용)")
Msg.AppendLine(" 길이,문자 패턴이 둘다 적용되어있을경우 우선순위가 높은")
Msg.AppendLine(" 문자패턴이 최종적으로 적용이 됩니다.(길이패턴은 무시됨)")
Msg.AppendLine()
Msg.AppendLine("# 길이패턴으로 저장하시겠습니까?")
Msg.AppendLine("# 예) 길이저장 , 아니오) 문자저장 , 취소) 취소")
If pc Then Msg.AppendLine("# 문자패턴이 적용되었으므로 [길이패턴] 저장은 의미가 없습니다")
Return Msg
End Function
Public Function Check_auth() As Boolean
If UserInfo.Type = E_AuthType.Demo Then
MsgBox("현재권한으로는 이기능을 사용할 수 없습니다", MsgBoxStyle.Critical, "임시사용자권한")
Return False
End If
Return True
End Function
Public Sub NOTICE(ByVal MSG As String, ByVal Src As Object)
On Error Resume Next
If Src.GetType.Name.ToUpper = "TOOLSTRIPSTATUSLABEL" Then
CType(Src, ToolStripStatusLabel).Text = "" & MSG & Space(1)
CType(Src, ToolStripStatusLabel).ForeColor = Color.Black
ElseIf Src.GetType.Name.ToUpper = "LABEL" Then
CType(Src, Label).Text = "" & MSG & Space(1)
CType(Src, Label).ForeColor = Color.Black
End If
' My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
End Sub
Public Sub NOTICE(ByVal MSG As String, ByVal FCOLOR As Color, ByVal Src As Windows.Forms.ToolStripStatusLabel)
Src.Text = "" & MSG & Space(1)
Src.ForeColor = FCOLOR
' My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
End Sub
Public Function PATTERN_ENC(ByVal SRCSTR As String) As String
Dim MSG As New System.Text.StringBuilder
For Each A As Char In SRCSTR.ToCharArray '//모든문자의 숫자번호를 판별한다.
If A = ";" Then '//구분자라면
MSG.Append(";")
ElseIf A = "-" Then
MSG.Append("-")
ElseIf Char.IsNumber(A) Then
MSG.Append("1")
ElseIf Asc(A) < 0 Then
MSG.Append("H")
Else
MSG.Append("0")
End If
Next
Return MSG.ToString
End Function
Public Sub ReNum(ByVal Srcspread As ArinNewFp.NewFp, ByVal NumColumnindex As Integer, Optional ByVal PBar As ProgressBar = Nothing)
If Not PBar Is Nothing Then
PBar.Minimum = 0
PBar.Maximum = Srcspread.ActiveSheet.RowCount
PBar.Value = 0
End If
For Each SR As FarPoint.Win.Spread.Row In Srcspread.ActiveSheet.Rows
If Not PBar Is Nothing Then PBar.Value += 1
Srcspread.ActiveSheet.Cells(SR.Index, NumColumnindex).Value = SR.Index + 1
Next
End Sub
Public Sub AddLog(ByVal t1 As Boolean, ByVal txt As String, Optional ByVal t2fn As String = "")
If UserInfo.Type = E_AuthType.Admin Then Log.RichTextBox1.AppendText(txt & vbCrLf)
End Sub
Public Sub showlog()
Log.Show()
End Sub
Public Sub hidelog()
Log.Close()
End Sub
Public Sub resetLog()
Log.RichTextBox1.Text = ""
End Sub
Public Sub ReNum(ByRef SrcTable As DataTable, ByVal ColumnName As String, Optional ByVal PBar As ProgressBar = Nothing)
If Not SrcTable.GetChanges Is Nothing Then
MsgBox("변경된 내용이 있습니다" & vbCrLf & vbCrLf & "먼저 저장을 하세요", MsgBoxStyle.Information, "확인")
Return
End If
If MsgBox("모든번호가 새로 갱신됩니다" & vbCrLf & vbCrLf & "계속하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then
Return
End If
If Not PBar Is Nothing Then
PBar.Minimum = 0
PBar.Maximum = SrcTable.Rows.Count
PBar.Value = 0
End If
Dim i As Integer = 0
Dim DV As New DataView(SrcTable, "", "정렬번호,번호", DataViewRowState.CurrentRows)
Dim DT As DataTable = DV.ToTable
For Each dr As DataRow In DT.Rows
i += 1
dr(ColumnName) = i
If Not PBar Is Nothing Then PBar.Value += 1
Next
SrcTable.Merge(DT)
MsgBox("번호 정렬이 완료되었습니다", MsgBoxStyle.Information, "확인")
End Sub
Public Function GetFirstIP() As String '//ip주소보기
Dim objAddress() As Net.IPAddress
'Dim IA As Net.IPAddress
Dim B(15) As Byte
Dim sAns As String = vbNullString
objAddress = Dns.GetHostEntry(GetHostName).AddressList
Try
Return objAddress(0).ToString
Catch ex As Exception
Return ""
End Try
End Function
End Module