| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.ComponentModel;
|
|---|
| 4 | using System.Data;
|
|---|
| 5 | using System.Drawing;
|
|---|
| 6 | using System.Text;
|
|---|
| 7 | using System.Windows.Forms;
|
|---|
| 8 | using System.Net;
|
|---|
| 9 | using System.IO;
|
|---|
| 10 | using System.Web;
|
|---|
| 11 | using System.Text.RegularExpressions;
|
|---|
| 12 |
|
|---|
| 13 | namespace Baza_Reklam
|
|---|
| 14 | {
|
|---|
| 15 | public partial class SMSform : Form
|
|---|
| 16 | {
|
|---|
| 17 | private int customerId;
|
|---|
| 18 |
|
|---|
| 19 | public SMSform(string nrTel, int custID)
|
|---|
| 20 | {
|
|---|
| 21 | InitializeComponent();
|
|---|
| 22 | ntTelTextBox.Text = nrTel;
|
|---|
| 23 | this.customerId = custID;
|
|---|
| 24 |
|
|---|
| 25 | this.kontaktyTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | private void button1_Click(object sender, EventArgs e)
|
|---|
| 29 | {
|
|---|
| 30 | if (ntTelTextBox.Text == "")
|
|---|
| 31 | {
|
|---|
| 32 | MessageBox.Show("Podaj nr telefonu");
|
|---|
| 33 | return;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | if (trescTextBox.Text == "")
|
|---|
| 37 | {
|
|---|
| 38 | MessageBox.Show("Podaj treæ sms-a");
|
|---|
| 39 | return;
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | ASCIIEncoding encoding = new ASCIIEncoding();
|
|---|
| 43 |
|
|---|
| 44 | string postData = "login=" + HttpUtility.UrlEncode("CT_CTRAVEL") + "&pass=" + HttpUtility.UrlEncode("jacek@ct.") +
|
|---|
| 45 | "&MSISDN=" + HttpUtility.UrlEncode(ntTelTextBox.Text) + "&body="
|
|---|
| 46 | + HttpUtility.UrlEncode(trescTextBox.Text);
|
|---|
| 47 | byte[] pom1 = encoding.GetBytes(postData);
|
|---|
| 48 |
|
|---|
| 49 | HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://www.wapster.pl/smssender.asp");
|
|---|
| 50 | req.Method = "POST";
|
|---|
| 51 | req.ContentType = "application/x-www-form-urlencoded";
|
|---|
| 52 | req.ContentLength = pom1.Length;
|
|---|
| 53 |
|
|---|
| 54 | Stream reqStream = req.GetRequestStream();
|
|---|
| 55 | reqStream.Write(pom1, 0, pom1.Length);
|
|---|
| 56 | reqStream.Close();
|
|---|
| 57 |
|
|---|
| 58 | Stream stream = req.GetResponse().GetResponseStream();
|
|---|
| 59 | StreamReader sr = new StreamReader(stream);
|
|---|
| 60 | string stronka = sr.ReadToEnd();
|
|---|
| 61 | if (stronka.Contains("<response><value>1</value></response>"))
|
|---|
| 62 | {
|
|---|
| 63 | MessageBox.Show("Wiadomoæ zosta³a wys³ana.");
|
|---|
| 64 | dodajDoKontaktow();
|
|---|
| 65 | }
|
|---|
| 66 | else
|
|---|
| 67 | {
|
|---|
| 68 | MessageBox.Show("Wyst¹pi³ b³¹d. Wiadomoæ nie zosta³a wys³ana.");
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | sr.Close();
|
|---|
| 72 | stream.Close();
|
|---|
| 73 | this.Close();
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | private void dodajDoKontaktow()
|
|---|
| 77 | {
|
|---|
| 78 | kontaktyTableAdapter1.Insert(this.customerId, User.getUser().Login, DateTime.Now, "SMS", ntTelTextBox.Text + " \n " + trescTextBox.Text);
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | private void SMSform_Load(object sender, EventArgs e)
|
|---|
| 82 | {
|
|---|
| 83 |
|
|---|
| 84 | }
|
|---|
| 85 | }
|
|---|
| 86 | } |
|---|