205 lines
6.2 KiB
VB.net
205 lines
6.2 KiB
VB.net
Imports System.Text
|
|
Imports System.Data
|
|
Imports System
|
|
|
|
Public Class MyCombo
|
|
Dim ColName As String
|
|
Dim Coltype As OleDbType = OleDbType.VarChar
|
|
Dim Ditem As Boolean
|
|
Dim SQl As String
|
|
Dim QueryType As Boolean = False
|
|
Dim Prompt As String
|
|
Dim WhereState As String = vbNullString
|
|
Dim POS As Int16
|
|
Dim StaticList As String = vbNullString '//쿼리아이템이아닌 수동아이템용 목록을 저장한다.
|
|
Dim QueryList As String = vbNullString '//쿼리아이템시 수동으로 입력할 목록을 저장한다.
|
|
Dim NotNull As Boolean = False
|
|
|
|
<System.ComponentModel.Description("반드시입력되어야 할 값입니까?")> _
|
|
Public Property DB_NotNull() As Boolean
|
|
Get
|
|
Return NotNull
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
NotNull = value
|
|
End Set
|
|
End Property
|
|
<System.ComponentModel.Description("데이터베이의 위치표시")> _
|
|
Public Property DB_POs() As Int16
|
|
Get
|
|
Return POS
|
|
End Get
|
|
Set(ByVal value As Int16)
|
|
POS = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("[STR] 검색조건절의 형태를 씁니다.(EX, >= , > , = , <= , < , LIKE )")> _
|
|
Public Property DB_WhereType() As String
|
|
Get
|
|
Return WhereState
|
|
End Get
|
|
Set(ByVal value As String)
|
|
WhereState = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("목록을 작성할 쿼리문입니다" & vbCrLf & "Ex: select name,val from table")> _
|
|
Public Property DB_Query() As String
|
|
Get
|
|
Return SQl
|
|
End Get
|
|
Set(ByVal value As String)
|
|
SQl = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("아이템목록이 쿼리로 되어있는지" & vbCrLf & "수동문자열인지 선택합니다")> _
|
|
Public Property DB_QueryType() As Boolean
|
|
Get
|
|
Return QueryType
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
QueryType = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("아이템을 쿼리로 작성시 추가로 입력할값을 표시" & vbCrLf & "ex:DSP,VAL,POS:텍스트,값,위치")> _
|
|
Public Property DB_QueryItem() As String
|
|
Get
|
|
Return QueryList
|
|
End Get
|
|
Set(ByVal value As String)
|
|
QueryList = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("아이템을 수동작성시 입력할값" & vbCrLf & "ex:DSP,VAL:텍스트,값")> _
|
|
Public Property DB_StaticItem() As String
|
|
Get
|
|
Return StaticList
|
|
End Get
|
|
Set(ByVal value As String)
|
|
StaticList = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("현재 별 의미는 없다..컬럼이 의미하는 글자")> _
|
|
Public Property DB_Prompt() As String
|
|
Get
|
|
Return IIf(Prompt Is vbNullString, DB_ColName, Prompt)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Prompt = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("데이터베이스 컬럼의 이름을 적는다!. 반드시 필수")> _
|
|
Public Property DB_ColName() As String
|
|
Get
|
|
If ColName = "" Then
|
|
Return Me.Name
|
|
Else
|
|
Return ColName
|
|
End If
|
|
End Get
|
|
Set(ByVal value As String)
|
|
ColName = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("데이터베이스 컬럼의 형식을 고른다")> _
|
|
Public Property DB_Type() As OleDbType
|
|
Get
|
|
Return Coltype
|
|
End Get
|
|
Set(ByVal value As OleDbType)
|
|
Coltype = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("현재 컨트롤이 데이터베이스 필드인지 선택합니다.")> _
|
|
Public Property DB_ITEM() As Boolean
|
|
Get
|
|
Return Ditem
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
Ditem = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("현재값")> _
|
|
Public Property Value() As String
|
|
Get
|
|
If Me.SelectedValue = "" Then
|
|
Return Me.Text
|
|
Else
|
|
Return Me.SelectedValue
|
|
End If
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.SelectedValue = value
|
|
If Me.SelectedValue Is vbNullString Then Me.Text = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
''' <summary>
|
|
''' 지정된 목록으로 업데이트
|
|
''' </summary>
|
|
''' <remarks></remarks>
|
|
Public Sub UpdateItem()
|
|
Dim NTab As New DataTable
|
|
Dim UserRow As DataRow
|
|
|
|
If QueryType = True Then '//쿼리를 사용해서 아이템을 쓸때
|
|
'DB.DB_SQL = (SQl)
|
|
' DB.Get_Data(NTab)
|
|
'NTab = DB.Get_TABLE
|
|
|
|
If Not QueryList Is Nothing Then
|
|
If QueryList.Trim.Length > 0 Then
|
|
For Each R As String In QueryList.Split(":")
|
|
UserRow = NTab.NewRow
|
|
UserRow(0) = R.Split(",")(0)
|
|
UserRow(1) = R.Split(",")(1)
|
|
NTab.Rows.InsertAt(UserRow, R.Split(",")(2))
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
'If QueryList <> Nothing OrElse QueryList.Trim.Length > 0 Then '//추가쿼리목록이 있을경우에 추가해준다.
|
|
'For Each R As String In QueryList.Split(",")
|
|
'NTab.Rows.Add(R.Split(","))
|
|
'Next
|
|
'End If
|
|
|
|
Me.DataSource = NTab
|
|
Me.DisplayMember = Me.DisplayMember
|
|
Me.ValueMember = Me.ValueMember
|
|
Else '//쿼리가아닌 staticitem 을 데이터테이블로 만들어서 한다.
|
|
If StaticList = "" Then Exit Sub
|
|
|
|
Dim A As New DataTable("NEWTAB")
|
|
Dim CDIV() As String = StaticList.Split(":")
|
|
A.Columns.Add("DSP")
|
|
A.Columns.Add("VAL")
|
|
'SataicList 를 :로 분할한뒤 , 데이터를 나눈다.
|
|
|
|
For Each R As String In CDIV
|
|
A.Rows.Add(R.Split(","))
|
|
Next
|
|
|
|
Me.DataSource = A
|
|
Me.DisplayMember = "DSP"
|
|
Me.ValueMember = "VAL"
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub ComboBOx_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
|
|
If e.KeyCode = Keys.Enter Then SendKeys.Send("{TAB}")
|
|
End Sub
|
|
End Class |