Kamis, 09 Januari 2014

“Mobile Pulse Rates” dengan Visual Basic.Net 2010

Mobile Pulse Rates VB.NET

Mobile Pulse Rates1 VB.NET

 

 

 

 

 

 

 

 

Public Class Form1

    Private Sub txtNoPhone_KeyPress(ByVal sender As Object, ByVal e As  _
                                  System.Windows.Forms.KeyPressEventArgs) _
                                  Handles txtNoPhone.KeyPress
        If Not (e.KeyChar >= ChrW(Keys.D0) And e.KeyChar <= ChrW(Keys.D9) Or _
                e.KeyChar = ChrW(Keys.Back) Or e.KeyChar = ChrW(Keys.Return)) Then
            e.KeyChar = ChrW(0)
        End If

        If e.KeyChar = ChrW(Keys.Enter) Then SendKeys.Send("{tab}")
    End Sub

    Private Sub txtPaid_KeyPress(ByVal sender As Object, ByVal e As  _
                                  System.Windows.Forms.KeyPressEventArgs) _
                                  Handles txtPaid.KeyPress
        If Not (e.KeyChar >= ChrW(Keys.D0) And e.KeyChar <= ChrW(Keys.D9) Or _
                e.KeyChar = ChrW(Keys.Back) Or e.KeyChar = ChrW(Keys.Return)) Then
            e.KeyChar = ChrW(0)
        ElseIf e.KeyChar = ChrW(Keys.Return) Then
            If Val(txtPaid.Text) >= Val(txtPrice.Text) Then
                btnCalculate_Click(sender, New EventArgs())
            ElseIf Val(txtPaid.Text) < Val(txtPrice.Text) Then
                MsgBox("Wrong input", MsgBoxStyle.Critical, "Warning")
                btnReset_Click(sender, New EventArgs())
                Exit Sub
            End If
        End If
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As  _
                                  System.Windows.Forms.FormClosingEventArgs) _
                                  Handles Me.FormClosing
        If MsgBox("Exit the Aplication?", vbYesNo + vbQuestion, "Confirmation") = vbNo Then
            If e.CloseReason = CloseReason.UserClosing Then
                e.Cancel = True
                txtNoPhone.Focus()
            End If
        End If
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As  _
                              System.EventArgs) Handles btnExit.Click
        Close()
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As  _
                              System.EventArgs) Handles btnReset.Click
        txtPaid.Clear()
        txtPaid.Focus()
        txtMoneyBack.Text = ""
        btnCalculate.Text = "Calculate"
        If txtPaid.ReadOnly = True Then txtPaid.ReadOnly = False
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim strOperatorName As String() = {"Telkomsel", "Indosat", "XL Axiata", "Hutchison 3", _
                                           "AXIS Telecom", "Smartfren Telecom", "Bakrie Telecom", _
                                           "Ceria Telecom", "TELKOM Ind"}
        cmbOperatorName.Items.AddRange(strOperatorName)
        cmbOperatorName.Sorted = True
    End Sub

    Private Sub cmbOperatorName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As  _
                            System.EventArgs) Handles cmbOperatorName.SelectedIndexChanged
        If cmbOperatorName.SelectedIndex = cmbOperatorName.FindStringExact("Telkomsel") Then
            Dim strTelkomsel As String() = {"AS", "Simpati"}
            Dim strPulseTelkomsel As String() = {"5000", "10000", "15000", "20000", _
                                                 "25000", "50000", "100000"}
            cmbProductName.Items.Clear()
            cmbProductName.Items.AddRange(strTelkomsel)
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseTelkomsel)
            CategoryDisable()
        ElseIf cmbOperatorName.SelectedIndex = cmbOperatorName.FindStringExact("Indosat") Then
            Dim strIndosat As String() = {"IM3", "Mentari", "StarOne"}
            cmbProductName.Items.Clear()
            cmbProductName.Items.AddRange(strIndosat)
            cmbRetailPrice.Items.Clear()
            CategoryDisable()
        ElseIf cmbOperatorName.SelectedIndex = cmbOperatorName.FindStringExact("XL Axiata") Then
            Dim strXLCategory As String() = {"Bebas", "Transfer"}
            cmbProductName.Items.Clear()
            cmbProductName.Items.Add("XL")
            cmbProductCategory.Enabled = True
            cmbProductCategory.Items.Clear()
            cmbProductCategory.Items.AddRange(strXLCategory)
            cmbRetailPrice.Items.Clear()
        ElseIf cmbOperatorName.SelectedIndex = cmbOperatorName.FindStringExact("Hutchison 3") Then
            Dim strPulseThree As String() = {"1000", "2000", "3000", "4000", "5000", "10000", _
                                             "15000", "20000", "25000", "30000", "50000", _
                                             "100000"}
            cmbProductName.Items.Clear()
            cmbProductName.Items.Add("Three")
            cmbProductName.SelectedIndex = 0
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseThree)
            CategoryDisable()
        ElseIf cmbOperatorName.SelectedIndex = cmbOperatorName.FindStringExact("AXIS Telecom") Then
            Dim strPulseAxis As String() = {"1000", "2000", "3000", "4000", "5000", "10000", _
                                            "15000", "20000", "25000", "50000", "100000"}
            cmbProductName.Items.Clear()
            cmbProductName.Items.Add("AXIS")
            cmbProductName.SelectedIndex = 0
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseAxis)
            CategoryDisable()
        ElseIf cmbOperatorName.SelectedIndex = cmbOperatorName.FindStringExact("Smartfren Telecom") Then
            Dim strSmartfren As String() = {"Fren", "Hepi", "Smart", "Smartfren"}
            cmbProductName.Items.Clear()
            cmbProductName.Items.AddRange(strSmartfren)
            cmbRetailPrice.Items.Clear()
            CategoryDisable()
        ElseIf cmbOperatorName.SelectedIndex = cmbOperatorName.FindStringExact("Bakrie Telecom") Then
            Dim strPulseEsia As String() = {"1000", "5000", "10000", "11000", "15000", _
                                            "20000", "25000", "50000", "100000"}
            cmbProductName.Items.Clear()
            cmbProductName.Items.Add("Esia")
            cmbProductName.SelectedIndex = 0
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseEsia)
            CategoryDisable()
        ElseIf cmbOperatorName.SelectedIndex = cmbOperatorName.FindStringExact("Ceria Telecom") Then
            Dim strPulseCeria As String() = {"5000", "10000", "20000", "50000", "100000"}
            cmbProductName.Items.Clear()
            cmbProductName.Items.Add("Ceria")
            cmbProductName.SelectedIndex = 0
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseCeria)
            CategoryDisable()
        ElseIf cmbOperatorName.SelectedIndex = cmbOperatorName.FindStringExact("TELKOM Ind") Then
            Dim strPulseTelInd As String() = {"5000", "10000", "20000", "50000", "100000"}
            cmbProductName.Items.Clear()
            cmbProductName.Items.Add("Flexi")
            cmbProductName.SelectedIndex = 0
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseTelInd)
            CategoryDisable()
        End If
    End Sub

    Private Sub cmbProductName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As  _
                                System.EventArgs) Handles cmbProductName.SelectedIndexChanged
        If cmbProductName.SelectedIndex = cmbProductName.FindStringExact("IM3") Or _
            cmbProductName.SelectedIndex = cmbProductName.FindStringExact("Mentari") Then
            Dim strIndosatCategory As String() = {"Regular", "GPRS", "SMS"}
            cmbProductCategory.Enabled = True
            cmbProductCategory.Items.Clear()
            cmbProductCategory.Items.AddRange(strIndosatCategory)
        ElseIf cmbProductName.SelectedIndex = cmbProductName.FindStringExact("StarOne") Then
            Dim strPulseStarOne As String() = {"5000", "10000", "20000", "50000", "100000"}
            cmbProductCategory.Items.Clear()
            cmbProductCategory.Enabled = False
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseStarOne)
        ElseIf cmbProductName.SelectedIndex = cmbProductName.FindStringExact("Fren") Or _
            cmbProductName.SelectedIndex = cmbProductName.FindStringExact("Hepi") Or _
            cmbProductName.SelectedIndex = cmbProductName.FindStringExact("Smartfren") Then
            Dim strPulseSmartfren1 As String() = {"5000", "10000", "20000", "25000", "50000", _
                                                 "100000"}
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseSmartfren1)
        ElseIf cmbProductName.SelectedIndex = cmbProductName.FindStringExact("Smart") Then
            Dim strPulseSmartfren2 As String() = {"5000", "10000", "15000", "20000", "25000", _
                                                  "50000", "100000"}
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseSmartfren2)
        End If
    End Sub

    Private Sub CategoryDisable()
        cmbProductCategory.Items.Clear()
        cmbProductCategory.Enabled = False
    End Sub

    Private Sub cmbProductCategory_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As  _
                            System.EventArgs) Handles cmbProductCategory.SelectedIndexChanged
        If cmbProductCategory.SelectedIndex = cmbProductCategory.FindStringExact("Bebas") Then
            Dim strPulseXLBebas As String() = {"1000", "5000", "10000", "25000", _
                                                  "50000", "100000"}
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseXLBebas)
        ElseIf cmbProductCategory.SelectedIndex = cmbProductCategory.FindStringExact("Transfer") Then
            Dim strPulseXLTransfer As String() = {"3000", "5000", "10000", "25000", _
                                                  "100000"}
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseXLTransfer)
        ElseIf cmbProductCategory.SelectedIndex = cmbProductCategory.FindStringExact("Regular") Then
            Dim strPulseIndosatRegular As String() = {"2000", "5000", "10000", "25000", _
                                                "50000", "100000"}
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseIndosatRegular)
        ElseIf cmbProductCategory.SelectedIndex = cmbProductCategory.FindStringExact("GPRS") Or _
            cmbProductCategory.SelectedIndex = cmbProductCategory.FindStringExact("SMS") Then
            Dim strPulseIndosatGPRSMS As String() = {"10000", "25000"}
            cmbRetailPrice.Items.Clear()
            cmbRetailPrice.Items.AddRange(strPulseIndosatGPRSMS)
        End If
    End Sub

    Private Sub txtPrice_KeyPress(ByVal sender As Object, ByVal e As  _
                        System.Windows.Forms.KeyPressEventArgs) Handles txtPrice.KeyPress
        If e.KeyChar = ChrW(Keys.Enter) Then SendKeys.Send("{tab}")
    End Sub

    Private Sub btnInputBox_Click(ByVal sender As System.Object, ByVal e As  _
                                  System.EventArgs) Handles btnInputBox.Click
        Dim strInputBox As String
        strInputBox = InputBox("Amount pulse price to carge:", "Pulse price Charge")
        If strInputBox <> "" Then
            lblCarge.Text = strInputBox
            txtPrice.Text = Val(cmbRetailPrice.Text) + Val(lblCarge.Text)
            txtPaid.Focus()
            btnReset_Click(sender, New EventArgs)
        Else
            Exit Sub
        End If
    End Sub

    Private Sub cmbRetailPrice_SelectedIndexChanged(ByVal sender As System.Object, ByVal e _
                            As System.EventArgs) Handles cmbRetailPrice.SelectedIndexChanged
        txtPrice.Text = Val(cmbRetailPrice.Text) + Val(lblCarge.Text)
        txtPaid.Focus()
    End Sub

    Private Sub txtPrice_TextChanged(ByVal sender As System.Object, ByVal e As  _
                                     System.EventArgs) Handles txtPrice.TextChanged
        If txtPrice.Text <> "" Then
            btnInputBox.Enabled = True
        Else
            btnInputBox.Enabled = False
        End If
    End Sub

    Private Sub txtPaid_TextChanged(ByVal sender As System.Object, ByVal e As  _
                                    System.EventArgs) Handles txtPaid.TextChanged
        If txtPaid.Text <> "" Then
            btnReset.Enabled = True
            btnCalculate.Enabled = True
        Else
            btnReset.Enabled = False
            btnCalculate.Enabled = False
        End If
    End Sub

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As  _
                                   System.EventArgs) Handles btnCalculate.Click
        If btnCalculate.Text = "Calculate" Then
            txtMoneyBack.Text = Val(txtPaid.Text) - Val(txtPrice.Text)
            txtPaid.ReadOnly = True
            txtPaid.BackColor = Color.FromKnownColor(KnownColor.Window)
            btnCalculate.Text = "New"
        ElseIf btnCalculate.Text = "New" Then
            txtMoneyBack.Clear()
            txtPaid.Clear()
            txtPrice.Clear()
            cmbRetailPrice.Items.Clear()
            cmbProductCategory.Items.Clear()
            cmbProductName.Items.Clear()
            cmbOperatorName.Items.Clear()
            txtNoPhone.Text = ""
            Form1_Load(sender, New EventArgs())
            txtPaid.ReadOnly = False
            btnCalculate.Text = "Calculate"
            txtNoPhone.Focus()
        End If
    End Sub

    Private Sub txtNoPhone_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNoPhone.TextChanged
        If Mid(txtNoPhone.Text, 1, 4) = "0812" Or Mid(txtNoPhone.Text, 1, 4) = "0813" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0821" Or Mid(txtNoPhone.Text, 1, 4) = "0822" Then
            cmbOperatorName.SelectedIndex = 7
            cmbProductName.SelectedIndex = 1
        ElseIf Mid(txtNoPhone.Text, 1, 4) = "0823" Or Mid(txtNoPhone.Text, 1, 4) = "0852" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0853" Then
            cmbOperatorName.SelectedIndex = 7
            cmbProductName.SelectedIndex = 0
        ElseIf Mid(txtNoPhone.Text, 1, 4) = "0815" Or Mid(txtNoPhone.Text, 1, 4) = "0816" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0858" Then
            cmbOperatorName.SelectedIndex = 4
            cmbProductName.SelectedIndex = 1
        ElseIf Mid(txtNoPhone.Text, 1, 4) = "0856" Or Mid(txtNoPhone.Text, 1, 4) = "0857" Then
            cmbOperatorName.SelectedIndex = 4
            cmbProductName.SelectedIndex = 0
        ElseIf Mid(txtNoPhone.Text, 1, 4) = "0817" Or Mid(txtNoPhone.Text, 1, 4) = "0818" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0819" Or Mid(txtNoPhone.Text, 1, 4) = "0859" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0877" Or Mid(txtNoPhone.Text, 1, 4) = "0878" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0879" Then
            cmbOperatorName.SelectedIndex = 8
            cmbProductName.SelectedIndex = 0
        ElseIf Mid(txtNoPhone.Text, 1, 4) = "0828" Then
            cmbOperatorName.SelectedIndex = 2
            cmbProductName.SelectedIndex = 0
        ElseIf Mid(txtNoPhone.Text, 1, 4) = "0831" Or Mid(txtNoPhone.Text, 1, 4) = "0838" Then
            cmbOperatorName.SelectedIndex = 0
            cmbProductName.SelectedIndex = 0
        ElseIf Mid(txtNoPhone.Text, 1, 4) = "0881" Or Mid(txtNoPhone.Text, 1, 4) = "0882" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0883" Or Mid(txtNoPhone.Text, 1, 4) = "0884" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0885" Or Mid(txtNoPhone.Text, 1, 4) = "0886" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0887" Then
            cmbOperatorName.SelectedIndex = 5
            cmbProductName.SelectedIndex = 2
        ElseIf Mid(txtNoPhone.Text, 1, 4) = "0888" Or Mid(txtNoPhone.Text, 1, 4) = "0889" Then
            cmbOperatorName.SelectedIndex = 5
            cmbProductName.SelectedIndex = 0
        ElseIf Mid(txtNoPhone.Text, 1, 4) = "0896" Or Mid(txtNoPhone.Text, 1, 4) = "0897" Or _
            Mid(txtNoPhone.Text, 1, 4) = "0898" Or Mid(txtNoPhone.Text, 1, 4) = "0899" Then
            cmbOperatorName.SelectedIndex = 3
            cmbProductName.SelectedIndex = 0
        Else
            cmbOperatorName.SelectedIndex = -1
            cmbProductName.SelectedIndex = -1
        End If
    End Sub
End Class

Label:

0 Komentar:

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda