Sunteți pe pagina 1din 4

Imports Imports Imports Imports Imports Imports Imports Imports Imports Imports Imports

System.Data.SqlClient System System.Net.Mail System.Net System.IO System.Web System.Text System.Data System.Configuration System.Collections System.Text.RegularExpressions

Public Class Form1 Private mbno As String, mseg As String, ckuser As String, ckpass As String Private req As HttpWebRequest Private cookieCntr As CookieContainer Private strNewValue As String Public Shared responseee As String Private response As HttpWebResponse Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

ckuser = "9976570006" ckpass = "1234" Try Me.req = DirectCast(WebRequest.Create("http://wwwd.way2sms.com/auth.cl"), HttpWebRequest) Me.req.CookieContainer = New CookieContainer() Me.req.AllowAutoRedirect = False Me.req.Method = "POST" Me.req.ContentType = "application/x-www-form-urlencoded" Me.strNewValue = "username=" & ckuser & "&password=" & ckpass Me.req.ContentLength = Me.strNewValue.Length Dim writer As New StreamWriter(Me.req.GetRequestStream(), Encoding.ASCII) writer.Write(Me.strNewValue) writer.Close() Me.response = DirectCast(Me.req.GetResponse(), HttpWebResponse) Me.cookieCntr = Me.req.CookieContainer Me.response.Close() Me.req = DirectCast(WebRequest.Create("http://wwwd.way2sms.com//jsp/InstantSMS.jsp?val =0"), HttpWebRequest) Me.req.CookieContainer = Me.cookieCntr Me.req.Method = "GET" Me.response = DirectCast(Me.req.GetResponse(), HttpWebResponse) responseee = New StreamReader(Me.response.GetResponseStream()).ReadToEnd() Dim index As Integer = Regex.Match(responseee, "custf").Index responseee = responseee.Substring(index, &H12) responseee = responseee.Replace("""", "").Replace(">", "").Trim() Me.response.Close() 'pnlsend.Visible = True TextBox11.Text = "connected" Catch generatedExceptionName As Exception TextBox11.Text = "Error connecting to the server..." End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As SqlConnection Dim cmd As SqlCommand Dim da As SqlDataAdapter Dim dr As SqlDataReader Dim ds As DataSet con = New SqlConnection("Data Source=system-3\sqlexpress;Initial Catalog=sugarcane;Integrated Security=True") ds = New DataSet cmd = New SqlCommand("Select * from Registration where FName = '" & TextBox1.Text & "' ", con) con.Open() dr = cmd.ExecuteReader() If (dr.HasRows) Then dr.Read()

cmd.Connection.Close() Else dr.Close() cmd.Connection.Close() End If da = New SqlDataAdapter("select * from Registration", con) cmd.Connection = con cmd.CommandText = "insert into Registration(FName, FAge, FPhone, FAddress, CWeight, TWeight, ToWeight, Cost, Username, Password) values('" & TextBox1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox2.Text & "','" & TextBox10.Text & "')" cmd.Connection.Open() cmd.ExecuteNonQuery() cmd.Connection.Close()

mbno = TextBox4.Text 'To mobile number mseg = "You are successfully registered" 'Message If (mbno <> "") AndAlso (mseg <> "") Then Try Me.req = DirectCast(WebRequest.Create("http://wwwd.way2sms.com//FirstServletsms?custid ="), HttpWebRequest) Me.req.AllowAutoRedirect = False Me.req.CookieContainer = Me.cookieCntr Me.req.Method = "POST" Me.req.ContentType = "application/x-www-form-urlencoded" Me.strNewValue = "custid=undefined&HiddenAction=instantsms&Action=" & responseee & "&login=&pass=&MobNo=" & Convert.ToString(Me.mbno) & "&textArea=" & Convert.ToString(Me.mseg) Dim msg As String = Me.mseg Dim mbeno As String = Me.mbno Me.req.ContentLength = Me.strNewValue.Length Dim writer As New StreamWriter(Me.req.GetRequestStream(), Encoding.ASCII) writer.Write(Me.strNewValue) writer.Close() Me.response = DirectCast(Me.req.GetResponse(), HttpWebResponse) Me.response.Close() TextBox11.Text = "Message Sent..... " & mbeno & ": " & msg Catch generatedExceptionName As Exception TextBox11.Text = "Error Sending msg....check your connection..." End Try Else TextBox11.Text = "Mob no or msg missing" End If

MsgBox("Saved") End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox7.Text = "" TextBox8.Text = "" TextBox9.Text = "" TextBox10.Text = "" End Sub End Class

S-ar putea să vă placă și