Skip to content

Instantly share code, notes, and snippets.

@sunmughan
Created June 18, 2019 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunmughan/f171c2c95c82efb12a7da745e359fd2c to your computer and use it in GitHub Desktop.
Save sunmughan/f171c2c95c82efb12a7da745e359fd2c to your computer and use it in GitHub Desktop.
Textlocal API
using System;
using System.Collections.Generic;
using System.Net;
using System.Collections.Specialized;
using System.IO;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
namespace fraud_detection_Credit_Card_payment_system
{
public partial class frmCCregistration : Form
{
string randomNumber;
SqlConnection con = new SqlConnection(Connection.strconnect());
public frmCCregistration()
{
InitializeComponent();
Test.Sms("");
}
private void button1_Click(object sender, EventArgs e)
{
if (txtloginid.Text.Length == 4)
{
MessageBox.Show("The ID can't be less than four!!!", "Field Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
txtloginid.Focus();
}
else
{
if (txtname.Text.Length == 0)
{
MessageBox.Show("Please don't leave it blank!!!", "Field Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
txtname.Focus();
}
if (txtcardno.Text.Length == 14)
{
MessageBox.Show("Please enter the fourteen or sixteen digit card number!!!", "Field Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
txtcardno.Focus();
}
if (txtccpin.Text.Length == 0)
{
MessageBox.Show("Please enter the four digit PIN!!!", "Field Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
txtccpin.Focus();
}
if (txtchpwd.Text.Length == 6)
{
MessageBox.Show("Please enter the password!!!", "Field Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
txtchpwd.Focus();
}
//if (txtconpwd.Text.Length == 6)
//{
// MessageBox.Show("Please re-enter the password!!!", "Field Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
// txtconpwd.Focus();
//}
}
try
{
SqlCommand cmdCCReg = new SqlCommand("Insert into tblCCRegistration(vloginid,vname,icardno,vmonth,vyear,iccpin,vpwd) values (@vloginid,@vname,@icardno,@vmonth,@vyear,@iccpin,@vpwd)", con);
cmdCCReg.Parameters.AddWithValue("@vloginid", txtloginid.Text);
cmdCCReg.Parameters.AddWithValue("@vname", txtname.Text);
cmdCCReg.Parameters.AddWithValue("@icardno", txtcardno.Text);
cmdCCReg.Parameters.AddWithValue("@vmonth", nudmm.Value);
cmdCCReg.Parameters.AddWithValue("@vyear", nudyy.Value);
cmdCCReg.Parameters.AddWithValue("@iccpin", txtccpin.Text);
cmdCCReg.Parameters.AddWithValue("@vpwd", txtchpwd.Text);
con.Open();
cmdCCReg.ExecuteNonQuery();
con.Close();
MessageBox.Show("Now you have successfully registered", "Registration completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtloginid.Text = "";
txtname.Text = "";
txtcardno.Text = "";
txtccpin.Text = "";
txtchpwd.Text = "";
//txtconpwd.Text = "";
}
catch (Exception ex)
{
con.Close();
MessageBox.Show(ex.Message, "Exception occured", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
finally
{
con.Close();
}
}
private void txtcardno_TextChanged(object sender, EventArgs e)
{
}
private void frmCCregistration_Load(object sender, EventArgs e)
{
}
private void btnclear_Click(object sender, EventArgs e)
{
//try
//{
// con.Open();
// SqlCommand check_User_Name = new SqlCommand("SELECT icardno FROM tblCCRegistration", con);
// check_User_Name.Parameters.AddWithValue("@icardno", txtcardno.Text);
// int UserExist = (int)check_User_Name.ExecuteScalar();
// if (UserExist > 1)
// {
// MessageBox.Show("Card number exists");
// }
// else
// {
// MessageBox.Show("Card number not exists");
// //Username doesn't exist.
// }
// con.Close();
//}
//catch (Exception ex)
//{
// con.Close();
// MessageBox.Show(ex.Message, "Exception occured", MessageBoxButtons.OK, MessageBoxIcon.Warning);
//}
//finally
//{
// con.Close();
//}
//try
//{
// con.Open();
// String query=Convert.ToString("Insert into tblCCRegistration values (vloginid,icardno)");
// SqlCommand comd = new SqlCommand(query, con);
// if (txtloginid.ToString("Insert into tblregistration values if (vlogin==vloginid")
//}
//catch(Exception ex)
//{
// con.Close();
// MessageBox.Show(ex.Message, "Exception occured", MessageBoxButtons.OK, MessageBoxIcon.Wang);
//}
//finally
//{
// con.Close();
//}
}
private void btnnext_Click(object sender, EventArgs e)
{
Security_Information_Check sc = new Security_Information_Check();
sc.Show();
}
private void txtloginid_TextChanged(object sender, EventArgs e)
{
}
private void label6_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged_1(object sender, EventArgs e)
{
}
private void btnotp_Click(object sender, EventArgs e)
{
string inputtype;
String result;
string apiKey = "wJNJX64kIII-V7r4xLYZIEvbtozTqbpf7mqBgtf3kz";
string numbers = txtphone.Text; // in a comma seperated list
string send = "SSWAMY";
string name = txtname.Text;
Random rnd = new Random();
randomNumber = (rnd.Next(1000, 9999)).ToString();
// first, add this to the top of your code file: using System.Text.RegularExpressions;
string message = "Hello, your OTP is: "+randomNumber+ "";
String url = "https://api.textlocal.in/send/?apikey=wJNJX64kIII-iL1QJvLyBdIs5BykgooZXSaQQxZu7h&sender=SSWAMY&numbers=919584215603&message=Hello, Your OTP is : "+randomNumber+"";
//String url = "https://api.textlocal.in/send/?apikey=" + apiKey + "&numbers=" + numbers + "&message=" + message + "&sender=" + send;
//refer to parameters to complete correct url string
StreamWriter myWriter = null;
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = Encoding.UTF8.GetByteCount(url);
objRequest.ContentType = "application/x-www-form-urlencoded";
try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(url);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
myWriter.Close();
}
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
MessageBox.Show("OTP Sent Successfully");
//Test.show();
}
private void btnverify_Click(object sender, EventArgs e)
{
if(txtverify.Text == randomNumber)
{
btnnext.Focus();
}
else
{
MessageBox.Show("Verification Failed!");
}
}
private void txtverify_TextChanged(object sender, EventArgs e)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment