Public Class SchedularEditor

    Public username As String
    Public password As String
    Public action As String
    Public scheduleid As String

    Dim webClient As New System.Net.WebClient
    Dim result As String

    Private Sub SchedularEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        username = username.ToString.Replace(" ", "%20")
        password = password.ToString.Replace(" ", "%20")

        messagetype1_cmb.SelectedIndex = 0
        trigger1_cmb.SelectedIndex = 0
        hour1_cmb.SelectedIndex = 0
        minute1_cmb.SelectedIndex = 0
        week1_cmb.SelectedIndex = 0
        month1_cmb.SelectedIndex = 0
        day1_cmb.SelectedIndex = 0

    End Sub

    Private Sub cancel_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel_btn.Click

        Me.Close()

    End Sub

    Dim recipient1 As String = ""
    Dim message1 As String = ""
    Dim senderid1 As String = ""
    Dim type1 As String = ""
    Dim taskdescription1 As String = ""
    Dim senddate As String = ""

    Private Sub send_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles send_btn.Click

        recipient1 = phoneno1_txt.Text.Trim.Replace(" ", "%20")

        If recipient1 = "" Then

            MsgBox("Please insert phone number")

        End If

        If messagetype1_cmb.SelectedItem.ToString() = "1 - ASCII (English, Bahasa Melayu, etc)" Then

            type1 = "1"

        Else

            type1 = "2"

        End If

        message1 = message1_area.Text.Trim.Replace(" ", "%20")

        If message1 = "" Then

            MsgBox("Please insert message")

        End If

        senderid1 = senderid1_txt.Text.Trim.Replace(" ", "%20")

        If senderid1 = "" Then

            MsgBox("Please insert sender ID")

        End If

        taskdescription1 = taskdescription1_txt.Text.Trim.Replace(" ", "%20")

        If taskdescription1 = "" Then

            MsgBox("Please task description")

        End If

        senddate = DateTimePicker.Value.ToString("yyyy-MM-dd")

        If action = "add" Then

            setResponse("http://www.isms.com.my/isms_scheduler.php?un=" + username + "&pwd=" + password + "&dstno=" + recipient1 + "&msg=" + message1 + "&det=" + taskdescription1 + "&tr=" + trigger1_cmb.SelectedItem.ToString() + "&type=" + type1 + "&sendid=" + senderid1 + "&date=" + senddate + "&hour=" + hour1_cmb.SelectedItem.ToString() + "&min=" + minute1_cmb.SelectedItem.ToString() + "&week=" + week1_cmb.SelectedItem.ToString() + "&month=" + month1_cmb.SelectedItem.ToString() + "&day=" + day1_cmb.SelectedItem.ToString() + "")

        Else

            setResponse("http://www.isms.com.my/isms_scheduler.php?un=" + username + "&pwd=" + password + "&dstno=" + recipient1 + "&msg=" + message1 + "&det=" + taskdescription1 + "&tr=" + trigger1_cmb.SelectedItem.ToString() + "&type=" + type1 + "&sendid=" + senderid1 + "&date=" + senddate + "&hour=" + hour1_cmb.SelectedItem.ToString() + "&min=" + minute1_cmb.SelectedItem.ToString() + "&week=" + week1_cmb.SelectedItem.ToString() + "&month=" + month1_cmb.SelectedItem.ToString() + "&day=" + day1_cmb.SelectedItem.ToString() + "&scid=" + scheduleid + "&action=update")

        End If

    End Sub

    Private Sub setResponse(ByVal url As String)

        result = webClient.DownloadString(url)
        response_area.AppendText("----- Command Breaker -----" + vbLf)
        response_area.AppendText(url + vbLf)
        response_area.AppendText(result + vbLf)
        response_area.SelectionStart = response_area.Text.Length
        response_area.ScrollToCaret()

    End Sub

    Private Sub message1_area_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles message1_area.KeyUp

        countwords1_lbl.Text = message1_area.TextLength

    End Sub

End Class