Lc_KiT : ­Ó¤H¥D­¶ - ¬Ûï - ­q¾\  [ QOOZA - ½×¾Â - µn¤J ]
406 - Not Acceptable
 
2012 ¦~ 1 ¤ë 1 ¤é  ¬P´Á¤é 2012-01-01 04:26 AM


[.Net] Classes / Implements - ISBN

Public Class Form1

#Region "Classes"
    Private Class ¦a°Ï
        Implements IComparable
 
        'shared
        Public Shared ReadOnly ¦a°Ïªí As New SortedDictionary(Of String, ¦a°Ï)
 
        'properties
        Public ReadOnly ID As Integer
        Public ReadOnly ¦WºÙ As String
        Public ¥Xª©ªÀ As New List(Of ¥Xª©ªÀ)
 
        'generation
        ''' <summary>
        ''' It's for preventing the key(name) of the regions is repeated.
        ''' </summary>
        ''' <param name="¨ú²{¦³­È">Actually, it's crap and can be removed.</param>
        Public Shared Function «Ø¥ß(ByVal ¦WºÙ As String, ByVal ID As Integer, _
                Optional ByVal ¨ú²{¦³­È As Boolean = False) As ¦a°Ï
            Dim nw¦a°Ï As ¦a°Ï = Nothing
            If ¦a°Ïªí.TryGetValue(¦WºÙ, nw¦a°Ï) Then
                If ¨ú²{¦³­È Then Return nw¦a°Ï Else Return Nothing
            Else
                Return New ¦a°Ï(¦WºÙ, ID)
            End If
        End Function
        Private Sub New(ByVal ¦WºÙ As String, ByVal ID As Integer)
            Me.¦WºÙ = ¦WºÙ
            Me.ID = ID
            ¦a°Ïªí.Add(¦WºÙ, Me)
        End Sub
        Public Sub ²¾°£() 'crap also.
            Me.¥Xª©ªÀ.Clear()
            ¦a°Ïªí.Remove(Me.¦WºÙ)
            GC.Collect(GC.GetGeneration(Me), GCCollectionMode.Forced)
        End Sub
 
        'Impements
        Public Function CompareTo(obj As Object) As Integer Implements System.IComparable.CompareTo
            Select Case obj.GetType
                Case GetType(¦a°Ï)
                    Return Me.¦WºÙ.CompareTo(CType(obj, ¦a°Ï).¦WºÙ)
                Case GetType(String)
                    Return Me.¦WºÙ.CompareTo(CStr(obj))
                Case GetType(Byte), GetType(Short), GetType(Integer), GetType(Long)
                    Return Me.ID.CompareTo(CLng(obj))
                Case Else
                    Throw New Exception(String.Format("¦a°Ï cannot compare to {0}.", obj.GetType()))
            End Select
        End Function
    End Class
 
    Private Class ¥Xª©ªÀ
        Implements IComparable
 
        'shared
        Public Shared ReadOnly ¥Xª©ªÀªí As New SortedDictionary(Of String, ¥Xª©ªÀ)
 
        'properties
        Public ReadOnly ID As Integer
        Public ReadOnly ¦WºÙ As String
        Public ReadOnly ¦a°Ï() As ¦a°Ï
 
        'generation
        ''' <summary>
        ''' It's for preventing the key(name) of the publishers is repeated.
        ''' </summary>
        ''' <param name="¦a°Ï">The ParamArray for this program only.</param>
        Public Shared Function «Ø¥ß(ByVal ¦WºÙ As String, ByVal ID As Integer, _
                ByVal ParamArray ¦a°Ï() As ¦a°Ï) As ¥Xª©ªÀ
            Dim nw¥Xª©ªÀ As ¥Xª©ªÀ = Nothing
            If ¥Xª©ªÀªí.TryGetValue(¦WºÙ, nw¥Xª©ªÀ) Then
                Return Nothing
            Else
                Return New ¥Xª©ªÀ(¦WºÙ, ID, ¦a°Ï)
            End If
        End Function
        Private Sub New(ByVal ¦WºÙ As String, ByVal ID As Integer, ByVal ¦a°Ï() As ¦a°Ï)
            Me.¦WºÙ = ¦WºÙ
            Me.ID = ID
            Me.¦a°Ï = ¦a°Ï
            For Each e¦a°Ï As ¦a°Ï In ¦a°Ï
                e¦a°Ï.¥Xª©ªÀ.Add(Me)
            Next
            ¥Xª©ªÀªí.Add(¦WºÙ, Me)
        End Sub
        Public Sub ²¾°£() 'crap+1
            For Each e¦a°Ï As ¦a°Ï In ¦a°Ï
                e¦a°Ï.¥Xª©ªÀ.Remove(Me)
            Next
            ¥Xª©ªÀªí.Remove(Me.¦WºÙ)
            GC.Collect(GC.GetGeneration(Me), GCCollectionMode.Forced)
        End Sub
 
        'implements
        Public Function CompareTo(obj As Object) As Integer Implements System.IComparable.CompareTo
            Select Case obj.GetType
                Case GetType(¥Xª©ªÀ)
                    Return Me.¦WºÙ.CompareTo(CType(obj, ¥Xª©ªÀ).¦WºÙ)
                Case GetType(String)
                    Return Me.¦WºÙ.CompareTo(CStr(obj))
                Case GetType(Byte), GetType(Short), GetType(Integer), GetType(Long)
                    Return Me.ID.CompareTo(CLng(obj))
                Case Else
                    Throw New Exception(String.Format("¥Xª©ªÀ cannot compare to {0}.", obj.GetType()))
            End Select
        End Function
    End Class
#End Region
#Region "Initialization"
    Private Sub ME_LOAD(sender As Object, e As EventArgs) Handles Me.Load
 
        'Creating the regions
        Dim TWA As ¦a°Ï = ¦a°Ï.«Ø¥ß("¥xÆW957", 957)
        Dim TWB As ¦a°Ï = ¦a°Ï.«Ø¥ß("¥xÆW986", 986)
        Dim CNA As ¦a°Ï = ¦a°Ï.«Ø¥ß("¤¤°ê81", 81)
        Dim CNB As ¦a°Ï = ¦a°Ï.«Ø¥ß("¤¤°ê93", 93)
        'Dim KOR As ¦a°Ï = ¦a°Ï.«Ø¥ß("¥_Áú", 9946) 'No publishers
 
        'Create Press,, of Tai Wan
        ¥Xª©ªÀ.«Ø¥ß("ùÖ®p", 181, TWA, TWB)
        ¥Xª©ªÀ.«Ø¥ß("¥þµØ", 21, TWA, TWB)
        ¥Xª©ªÀ.«Ø¥ß("ªQ±^", 22, TWA, TWB)
 
        ',, of Mainland CN
        ¥Xª©ªÀ.«Ø¥ß("¤¤°ê¥_¨Ê¤j¾Ç", 301, CNA, CNB)
        ¥Xª©ªÀ.«Ø¥ß("¥_¨Ê¥«ªF¤è", 5060, CNA, CNB)
 
        'GUIs
        ComboBox1.Items.Clear()
        ComboBox2.Items.Clear()
 
        For Each ¦a°Ï As ¦a°Ï In ¦a°Ï.¦a°Ïªí.Values
            ComboBox1.Items.Add(¦a°Ï.¦WºÙ)
        Next
 
    End Sub
#End Region
#Region "Controls Handles"
    ''' <summary>
    ''' Handling Button1.Click, generate a New ISBN number then display in Label4.
    ''' </summary>
    ''' <param name="sender">Button1</param>
    ''' <param name="e">Nothing</param>
    ''' <remarks>The ISBN number will start with 978 or 979 randomly with the same probability</remarks>
    Private Sub Button1_Click(sender As Button, e As System.EventArgs) Handles Button1.Click
        Randomize()
        If ComboBox1.SelectedIndex < 0 Or ComboBox2.SelectedIndex < 0 Then Exit Sub 'debug
 
        Dim s$ = CStr(IIf(Rnd() > 0.5, "978", "979")) & _
            ¦a°Ï.¦a°Ïªí(ComboBox1.SelectedItem).ID & _
            ¥Xª©ªÀ.¥Xª©ªÀªí(ComboBox2.SelectedItem).ID
        s &= New String("0", 12 - s.Length - TextBox1.Text.Length) & TextBox1.Text
 
        Dim b As Boolean, sm As Integer
        For Each c As Char In s.ToCharArray()
            If b Then
                sm += (Asc(c) - 48) * 3
            Else
                sm += Asc(c) - 48
            End If
            b = Not b
        Next c
 
        s &= 10 - (sm Mod 10)
 
#If DEBUG Then
        Debug.Print(s)
#End If
 
        Label4.Text = s
 
    End Sub
    ''' <summary>
    ''' Handling Combox1.SelectedIndexChanged. Change the publishers while the region is changed.
    ''' </summary>
    ''' <param name="sender">Combobox1</param>
    ''' <remarks>If the region is changed to nothing, Combobox2 will be cleared. </remarks>
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As ComboBox, ByVal e As System.EventArgs) _
            Handles ComboBox1.SelectedIndexChanged
        ComboBox2.Items.Clear()
        If sender.SelectedIndex >= 0 Then
            For Each ¥Xª©ªÀ As ¥Xª©ªÀ In ¦a°Ï.¦a°Ïªí(sender.SelectedItem).¥Xª©ªÀ
                ComboBox2.Items.Add(¥Xª©ªÀ.¦WºÙ)
            Next
        End If
    End Sub
#End Region
End Class


¡¹Kit¡û..

 [ ³X«È¯d¨¥(0) ] [ ½s¿è¤é»x ] [ ¤À¨É¦ÜFACEBOOK ]  
MySelf
¼ÊºÙ¡G Tikwal
©Ê§O¡G ¨k
°ê®a¡G ­»´ä
¦a°Ï¡G ¤¸®Ô°Ï
++¤ô´¹­µ¼Ö²°++
Mariage D'Amour
³Ìªñ³X«È
³Ìªñ¨S¦³³X«È
³X«È¯d¨¥
³Ìªñ¤T­Ó¤ë©|µL¥ô¦ó¯d¨¥
³Ì·s¤å³¹
Ũì½Ð¶¼³¥ lol
[VB.Net] ¤¤°ê¶H´Ñ
[.Net] Classes / Imp...
[Âà][API]4­Ókeybd ¼Ò...
[VB2010]±`ª±ªº, ±µ¤ô...
¤å³¹¤ÀÃþ
¥þ³¡ (32)
API (5)
Âø½Í (2)
DataBase (2)
M$ (9)
php (1)
VB.Net (5)
¯Âºé·d¯º (4)
ºô­¶ (5)
¥¼¤ÀÃþ (1)
¤é»x²Î­p
¤å³¹Á`¼Æ¡G 32
¯d¨¥Á`¼Æ¡G 28
¤µ¤é¤H®ð¡G 1
²Ö¿n¤H®ð¡G 1807