Imports System.Text
Public Class MySearchGrp
'''
''' ÀÌ °³Ã¼¿¡ Ä¿¼¸¦ À̵¿ÇÕ´Ï´Ù.
'''
'''
Public Sub DB_SetFocus()
'Á¤·ÄµÈ ¾ÆÀÌÅÛÁß¿¡ 1¹ø¤Š ¾ÆÀÌÅÛ¿¡ Æ÷Ä¿¸£¸¦ ÁÝ´Ï´Ù.
Dim A As ArrayList = GetSortedItem()
Dim itm As Control = A(0)
Dim ItmType As String = itm.GetType.Name.ToString.ToUpper
Select Case ItmType
Case "TEXTBOX"
CType(itm, MyControlOLEDBv2.MyTextBox).Focus()
Case "CHECKBOX"
CType(itm, MyControlOLEDBv2.MyCheckBox).Focus()
Case "COMBOBOX"
CType(itm, MyControlOLEDBv2.MyCombo).Focus()
End Select
End Sub
'''
''' ÅǼø¼¸¦ ÀÌ¿ëÇÏ¿© Á¤·ÄµÈ ¾ÆÀÌÅÛÀÇ ¹è¿(ARRAYLIST)À» ¹ÝȯÇÕ´Ï´Ù.
'''
'''
'''
Public Function GetSortedItem() As ArrayList
Dim Iname As String
Dim CAr As New ArrayList
Dim CArC As New ArrayList
For Each itm As Control In Me.Controls
Iname = itm.GetType.Name.ToString.ToUpper
If Iname = "TEXTBOX" OrElse Iname = "CHECKBOX" OrElse Iname = "COMBOBOX" Then
CAr.Add(itm.TabIndex)
End If
Next
CAr.Sort()
For i As Integer = 0 To CAr.Count - 1
For Each itm As Control In Me.Controls
Iname = itm.GetType.Name.ToString.ToUpper
If itm.TabIndex = CAr.Item(i) Then CArC.Add(itm)
Next
Next
Return CArC
End Function
'''
''' WHERE SQLÀ» ¹ÝÇÑÇÕ´Ï´Ù.(PROMPT=TRUE À̸é WHEREÀýÀÌ ºÙ¾î¼ ¹ÝȯµË´Ï´Ù)
'''
'''
'''
Public Function GetWhere(Optional ByVal HEADER As Boolean = False, Optional ByVal AddParam As Boolean = True, Optional ByVal ResetParam As Boolean = True) As String
'where ÀýÀº kcode = >= <= != ÀÌ·±ÇüŰ¡ µé¾î°¡¼ ¸¸µé¾îÁø´Ù.
'where Àý³»ÀÇ Db_item ŸÀÔÀÌ true Àΰ͵鸸 ±¸¹®À» ÀÛ¼ºÇÑ´Ù.
Dim SQL As New StringBuilder(vbNullString)
Dim CNT As Integer = 0
If ResetParam Then
' MsgBox("ÆÄ¶ó¹ÌÅÍ ¸®¼Â")
'DB.MyParam_Reset()
End If
For Each ITM As Object In Me.Controls
' MsgBox(ITM.GetType.Name)
Select Case ITM.GetType.Name.ToUpper
Case "MYMASKTEXTBOX"
Dim A As MyControlOLEDBv2.MyMaskBox = ITM
If A.DB_ITEM AndAlso A.Text.Trim <> "" Then
'±âº»°ª WHERE_DEFAULT_VALUE °ªÀ» È®ÀÎÇÕ´Ï´Ù. º¯°æÀ̵Ǿú´Ù¸é WHEREÀýÀ» »ý¼ºÇÕ´Ï´Ù
If A.Text <> A.WHERE_DEFAULT_VALUE Then
CNT += 1
If CNT <> 1 Then SQL.Append(" AND ")
If Not AddParam Then '//¹®ÀÚ´Â '¸¦ºÙ¿©ÁØ´Ù
If A.DB_Type = OleDbType.VarChar Then
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & "'" & A.Value & "'")
Else
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & A.Value)
End If
Else
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & " :S" & CNT)
End If
'If AddParam Then DB.MyParam_Add(" :S" & CNT, A.DB_Type, A.Value)
End If
End If
Case "TEXTBOX"
Dim A As MyControlOLEDBv2.MyTextBox = ITM
If A.DB_ITEM AndAlso A.Text.Trim <> "" Then
'±âº»°ª WHERE_DEFAULT_VALUE °ªÀ» È®ÀÎÇÕ´Ï´Ù. º¯°æÀ̵Ǿú´Ù¸é WHEREÀýÀ» »ý¼ºÇÕ´Ï´Ù
If A.Text <> A.WHERE_DEFAULT_VALUE Then
CNT += 1
If CNT <> 1 Then SQL.Append(" AND ")
If Not AddParam Then
If A.DB_Type = OleDbType.VarChar Then
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & "'" & A.Value & "'")
Else
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & A.Value)
End If
Else
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & " :S" & CNT)
End If
'If AddParam Then DB.MyParam_Add(" :S" & CNT, A.DB_Type, A.Value)
End If
End If
Case "CHECKBOX"
Dim A As MyControlOLEDBv2.MyCheckBox = ITM
If A.DB_ITEM Then
'±âº»°ª WHERE_DEFAULT_VALUE °ªÀ» È®ÀÎÇÕ´Ï´Ù. º¯°æÀ̵Ǿú´Ù¸é WHEREÀýÀ» »ý¼ºÇÕ´Ï´Ù
CNT += 1
If CNT <> 1 Then SQL.Append(" AND ")
If Not AddParam Then
If A.DB_Type = OleDbType.VarChar Then
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & "'" & A.Value & "'")
Else
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & A.Value)
End If
Else
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & " :S" & CNT)
End If
'If AddParam Then DB.MyParam_Add(" :S" & CNT, A.DB_Type, A.Value)
End If
Case "COMBOBOX"
Dim A As MyControlOLEDBv2.MyCombo = ITM
If A.DB_ITEM Then
'±âº»°ª WHERE_DEFAULT_VALUE °ªÀ» È®ÀÎÇÕ´Ï´Ù. º¯°æÀ̵Ǿú´Ù¸é WHEREÀýÀ» »ý¼ºÇÕ´Ï´Ù
If (A.DropDownStyle <> ComboBoxStyle.DropDownList AndAlso A.Text.Trim <> "") OrElse (A.DropDownStyle = ComboBoxStyle.DropDownList AndAlso Not (A.SelectedIndex = 0 AndAlso A.SelectedValue = -1)) Then
CNT += 1
If CNT <> 1 Then SQL.Append(" AND ")
If Not AddParam Then
If A.DB_Type = OleDbType.VarChar Then
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & "'" & A.Value & "'")
Else
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & A.Value)
End If
Else
SQL.Append(A.DB_ColName & Space(1) & A.DB_WhereType & " :S" & CNT)
End If
' If AddParam Then DB.MyParam_Add(" :S" & CNT, A.DB_Type, A.Value)
End If
End If
End Select
Next
If SQL.ToString.Trim = "" Then '//¸¸µé¾îÁø°Ô ¾Æ¿¹¾øÀ»°æ¿ìÀÌ´Ù.
Return vbNullString
Else
Return IIf(HEADER, " WHERE " & SQL.ToString, SQL.ToString)
End If
End Function
'''
''' °Ë»öºí·°³»ÀÇ ¸ðµç ÄÞº¸¹Ú½ºÀÇ ¸ñ·ÏÀ» °»½ÅÇÕ´Ï´Ù.
'''
'''
Public Sub UpdateComboBox()
For Each Itm As Control In Me.Controls
Select Case Itm.GetType.Name.ToString.ToUpper
Case "COMBOBOX"
CType(Itm, MyControlOLEDBv2.MyCombo).UpdateItem()
End Select
Next
End Sub
End Class