using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Runtime.Remoting.Contexts;
namespace Newdelhibarassocia
{
public partial class newidcard : System.Web.UI.Page
{
Class1 obj = new Class1();
SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlDataAdapter adp;
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
try
{
string con = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
if (DropDownList1.SelectedItem.Text == "Select Type")
{
RegisterStartupScript("12", "");
}
else
{
if (DropDownList1.SelectedItem.Text == "NDBA.No.")
{
string sel = "select top 1 * from Memberslist where Ndbano='" + TextBox1.Text + "'";
SqlDataAdapter da = new SqlDataAdapter(sel, con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Panel4.Visible = true;
Panel3.Visible = false;
Literal4.Text = dt.Rows[0]["Mobile_1"].ToString();
string[] saAllowedCharacters = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
string sRandomOTP = GenerateRandomOTP(4, saAllowedCharacters);
HiddenField1.Value = sRandomOTP;
string messag = " NDBA User, Your OTP is " + sRandomOTP + ". Do Not share this with anyone. TEAM NDBA";
string SmsStatusMsg = string.Empty;
WebClient client = new WebClient();
string mm = dt.Rows[0]["Mobile_1"].ToString();
// mm = "9871482014";
if (dt.Rows[0]["Mobile_1"].ToString() != "0")
{
string URL = "http://www.canlog.in/api/mt/SendSMS?user=NDBA1234&password=NDBA1234&senderid=NDBATM&channel=Trans&DCS=0&flashsms=0&number=" + mm + "&text=" + messag + "&route=2";
SmsStatusMsg = client.DownloadString(URL);
if (SmsStatusMsg.Contains("
"))
{
SmsStatusMsg = SmsStatusMsg.Replace("
", ", ");
}
}
else
{
RegisterStartupScript("12", "");
}
//Repeater1.DataSource = dt;
//Repeater1.DataBind();
//Repeater1.Visible = true;
}
else
{
// Repeater1.Visible = false;
}
}
else if (DropDownList1.SelectedItem.Text == "Mobile No.")
{
string sel = "select top 1 * from Memberslist where Mobile_1 like '%" + TextBox1.Text + "%'";
SqlDataAdapter da = new SqlDataAdapter(sel, con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Panel4.Visible = true;
Panel3.Visible = false;
//Panel2.Visible = true;
Literal4.Text = dt.Rows[0]["Mobile_1"].ToString();
string[] saAllowedCharacters = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
string sRandomOTP = GenerateRandomOTP(4, saAllowedCharacters);
HiddenField1.Value = sRandomOTP;
//NDBA User, Your OTP is 464654. Do Not share this with anyone. TEAM NDBA
// NDBA User, Your OTP is " + sRandomOTP + ". Do Not share this with anyone. TEAM NDBA
string messag = " NDBA User, Your OTP is " + sRandomOTP + ". Do Not share this with anyone. TEAM NDBA";
string SmsStatusMsg = string.Empty;
WebClient client = new WebClient();
// mm = "9871482014";
if (dt.Rows[0]["Mobile_1"].ToString() != "0")
{
string URL = "http://www.canlog.in/api/mt/SendSMS?user=NDBA1234&password=NDBA1234&senderid=NDBATM&channel=Trans&DCS=0&flashsms=0&number=" + dt.Rows[0]["Mobile_1"].ToString() + "&text=" + messag + "&route=2";
SmsStatusMsg = client.DownloadString(URL);
if (SmsStatusMsg.Contains("
"))
{
SmsStatusMsg = SmsStatusMsg.Replace("
", ", ");
}
}
else
{
RegisterStartupScript("12", "");
}
}
else
{
// Repeater1.Visible = false;
}
}
else if (DropDownList1.SelectedItem.Text == "BCD Enrollment No.")
{
string sel = "select top 1 * from Memberslist where Bcdenroll like '%" + TextBox1.Text + "%'";
SqlDataAdapter da = new SqlDataAdapter(sel, con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Panel4.Visible = true;
Panel3.Visible = false;
Literal4.Text = dt.Rows[0]["Mobile_1"].ToString();
//Panel2.Visible = true;
//Literal1.Text = dt.Rows[0]["Mobile_1"].ToString();
string[] saAllowedCharacters = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
string sRandomOTP = GenerateRandomOTP(4, saAllowedCharacters);
HiddenField1.Value = sRandomOTP;
string messag = sRandomOTP + " is the OTP for your NDBA. do not share this with anyone.";
string SmsStatusMsg = string.Empty;
WebClient client = new WebClient();
// mm = "9871482014";
string URL = "http://www.canlog.in/api/mt/SendSMS?user=NDBA1234&password=NDBA1234&senderid=NDBATM&channel=Trans&DCS=0&flashsms=0&number=" + dt.Rows[0]["Mobile_1"].ToString() + "&text=" + messag + "&route=2";
SmsStatusMsg = client.DownloadString(URL);
if (SmsStatusMsg.Contains("
"))
{
SmsStatusMsg = SmsStatusMsg.Replace("
", ", ");
}
//Repeater1.DataSource = dt;
//Repeater1.DataBind();
//Repeater1.Visible = true;
}
else
{
//Repeater1.Visible = false;
}
}
}
// Literal1.Text = "9871482014";
// Panel2.Visible = false;
}
catch (Exception ex)
{
RegisterStartupScript("12", "");
}
}
private string GenerateRandomOTP(int iOTPLength, string[] saAllowedCharacters)
{
string sOTP = String.Empty;
string sTempChars = String.Empty;
Random rand = new Random();
for (int i = 0; i < iOTPLength; i++)
{
int p = rand.Next(0, saAllowedCharacters.Length);
sTempChars = saAllowedCharacters[rand.Next(0, saAllowedCharacters.Length)];
sOTP += sTempChars;
}
return sOTP;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (HiddenField1.Value == TextBox17.Text)
{
if (DropDownList1.SelectedItem.Text == "Select Type")
{
RegisterStartupScript("12", "");
}
else
{
string empt = "";
if (DropDownList1.SelectedItem.Text == "NDBA.No.")
{
empt = " and Ndbano='" + TextBox1.Text + "'";
}
else if (DropDownList1.SelectedItem.Text == "Mobile No.")
{
empt = " and Mobile_1='" + TextBox1.Text + "'";
}
else if (DropDownList1.SelectedItem.Text == "BCD Enrollment No.")
{
empt = " and Bcdenroll='" + TextBox1.Text + "'";
}
string qrajneeti = "select * from Memberslist where id!='' " + empt + " order by id desc";
DataSet dsrajneeti = obj.ReturnDataSet(qrajneeti);
if (dsrajneeti != null && dsrajneeti.Tables[0].Rows.Count > 0)
{
TextBox3.Text = dsrajneeti.Tables[0].Rows[0]["F_name"].ToString()+ " "+ dsrajneeti.Tables[0].Rows[0]["L_name"].ToString();
TextBox3.Text = dsrajneeti.Tables[0].Rows[0]["Ndbano"].ToString();
TextBox4.Text = dsrajneeti.Tables[0].Rows[0]["Bcdenroll"].ToString();
TextBox5.Text = dsrajneeti.Tables[0].Rows[0]["Resid_1"].ToString();
TextBox6.Text = dsrajneeti.Tables[0].Rows[0]["Mobile_1"].ToString();
}
}
}
}
protected void Button3_Click(object sender, EventArgs e)
{
string kl = "";
if (FileUpload1.FileBytes.Length > 1024)
{
string nname = DateTime.Now.Ticks.ToString();
FileUpload FileUpload7 = FileUpload1;
string virtualFolder7 = "dataimp1/" + nname;
string physicalFolder7 = Server.MapPath(virtualFolder7);
FileUpload7.SaveAs(physicalFolder7 + FileUpload7.FileName);
kl = "../dataimp1/" + nname + FileUpload7.FileName;
}
connect.Open();
cmd = new SqlCommand("update Memberslist set I_card_no=@I_card_no, Photo=@Photo,Resid_1=@Resid_1 where Ndbano='" + TextBox3.Text + "' and Mobile_1='" + TextBox6.Text + "' ", connect);
cmd.Parameters.Add("@Resid_1", System.Data.SqlDbType.VarChar);
cmd.Parameters["@Resid_1"].Value = TextBox5.Text;
cmd.Parameters.Add("@Photo", System.Data.SqlDbType.VarChar);
cmd.Parameters["@Photo"].Value = kl;
cmd.Parameters.Add("@I_card_no", System.Data.SqlDbType.VarChar);
cmd.Parameters["@I_card_no"].Value = "New";
cmd.ExecuteNonQuery();
connect.Close();
HiddenField1.Value = "";
RegisterStartupScript("12", "");
}
}
}