registepage coding
using BusinessEntities;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace KenCommerceWeb.PublicWebsites
{
public partial class Registerpage : System.Web.UI.Page
{
HttpClient client = new HttpClient();
List<Master_Login_User> Login_UserList = null;
public List<Master_Login_User> gETMaster_Login_User = new List<Master_Login_User>();
Master_Login_User Login_UserEntity = new Master_Login_User();
protected void Page_Load(object sender, EventArgs e)
{
var appsurl = ConfigurationManager.AppSettings["APIPath"].ToString();
client.BaseAddress = new Uri(appsurl);
if (!IsPostBack)
{
//btnVerifay.Visible = true;
//imgverify.Visible = false;
clear();
}
}
private List<Master_Login_User> GetLogin_User()
{
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
Login_UserList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
return Login_UserList.ToList();
}
else
{
return null;
}
}
protected void clear()
{
txtEmail.Text = "";
txtName.Text = "";
txtPassword.Text = "";
txtConfirmPassword.Text = "";
TxtMobileNo.Text = "";
Image1Email.Visible = false;
imgverify.Visible = false;
//btnVerifay.Visible = true;
//btnVerifay.Enabled = false;
EmailVerifyBtn.Visible = true;
//TxtMobileNo.Enabled = false;
}
protected string isKartSession()
{
if (Session["PLACE ORDER"] != null && Session["PLACE ORDER"].ToString() == "PLACE ORDER")
{
return "~/Order/AddCartList.aspx";
}
else if (Session["BUY NOW"] != null && Session["BUY NOW"].ToString() == "BUY NOW")
{
return "~/PublicWebsites/Add2Cart.aspx";
}
else
{
return "";
}
}
protected void btn_submit_Click(object sender, EventArgs e)
{
// SendMail();
var data = GetLogin_User().Where(a => a.Login_EmailId == txtEmail.Text).FirstOrDefault();
if (data == null)
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//if (RadRadioButtonList1.SelectedValue == "Seller")
//{
// Login_UserEntity.Login_User_Type = "Seller";
//}
//else
//{
// Login_UserEntity.Login_User_Type = "Customer";
//}
if (RadRadioButtonList1.SelectedValue == "Customer")
{
Login_UserEntity.Login_User_Type = RadRadioButtonList1.SelectedValue.ToString();
Login_UserEntity.Login_EmailId = txtEmail.Text;
Login_UserEntity.Login_Username = txtName.Text;
Login_UserEntity.Login_Password = txtPassword.Text;
Login_UserEntity.InsertedOn = DateTime.Now;
Login_UserEntity.Login_MobileNo = TxtMobileNo.Text;
Login_UserEntity.InsertedBy = 0;
//Login_UserEntity.LastModifiedOn = ;
//Login_UserEntity.LastModifiedBy =
Login_UserEntity.IsActive = true;
Login_UserEntity.IsDelete = false;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", Login_UserEntity).Result;
if (content.IsSuccessStatusCode)
{
clear();
string LoginUID = content.Content.ReadAsStringAsync().Result;
Session["Loginuserid"] = LoginUID;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
Login_UserList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in Login_UserList
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
if (isKartSession() == "")
{
Response.Redirect("~/PublicWebsites/Default.aspx", false);
}
else
{
Response.Redirect(isKartSession());
}
}
}
// Session["Loginuserid"] != null && Session["UserName"] != null && Session["UserType"] != null && Session["UserMailId"] != null && Session["UserMailId"] != null && Session["Loged"] != null
//Session["Loginuserid"] = login.Login_User_ID.ToString();
//Response.Redirect("~/RegistationPage.aspx");
//Response.Redirect("~/DolnaWebsite/Default.aspx");
}
}
if (RadRadioButtonList1.SelectedValue == "Artist")
{
Login_UserEntity.Login_User_Type = RadRadioButtonList1.SelectedValue.ToString();
Login_UserEntity.Login_EmailId = txtEmail.Text;
Login_UserEntity.Login_Username = txtName.Text;
Login_UserEntity.Login_Password = txtPassword.Text;
Login_UserEntity.InsertedOn = DateTime.Now;
Login_UserEntity.Login_MobileNo = TxtMobileNo.Text;
Login_UserEntity.InsertedBy = 0;
Login_UserEntity.IsActive = true;
Login_UserEntity.IsDelete = false;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", Login_UserEntity).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
Login_UserList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in Login_UserList
where a.Login_User_ID == Convert.ToInt32(LoginUID)
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
clear();
if (isKartSession() == "")
{
Response.Redirect("~/Supplier/Default.aspx");
}
else
{
Response.Redirect(isKartSession());
}
}
}
}
}
if (RadRadioButtonList1.SelectedValue == "Gallerist")
{
Login_UserEntity.Login_User_Type = RadRadioButtonList1.SelectedValue.ToString();
Login_UserEntity.Login_EmailId = txtEmail.Text;
Login_UserEntity.Login_Username = txtName.Text;
Login_UserEntity.Login_Password = txtPassword.Text;
Login_UserEntity.InsertedOn = DateTime.Now;
Login_UserEntity.Login_MobileNo = TxtMobileNo.Text;
Login_UserEntity.InsertedBy = 0;
Login_UserEntity.IsActive = true;
Login_UserEntity.IsDelete = false;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", Login_UserEntity).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
Login_UserList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in Login_UserList
where a.Login_User_ID == Convert.ToInt32(LoginUID)
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
clear();
if (isKartSession() == "")
{
Response.Redirect("~/Supplier/Default.aspx");
}
else
{
Response.Redirect(isKartSession());
}
}
}
}
}
}
else
{
clear();
// Response.Redirect("~/DolnaWebsite/Registerpage.aspx");
Notification.Text = "Already exsit!";
Notification.Show();
}
}
protected void btn_reset_Click(object sender, EventArgs e)
{
clear();
}
protected void btnimg_Click(object sender, EventArgs e)
{
//Image imgverify = (Image)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("imgverify");
//Panel pnlotp = (Panel)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("pnlotp");
//TextBox txtotp = (TextBox)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("txtotp");
//Label lblmsg = (Label)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("lblmsg");
string sessonOtp = Session["OTP"].ToString();
if (txtotp.Text == sessonOtp)
{
// btnVerifay.Visible = false;
imgverify.Visible = true;
pnlotp.Visible = false;
btn_submit.Enabled = true;
}
else
{
lblmsg.Text = "Enter a valid OTP";
}
}
#region Otp Method
public class SendSMS
{
#region -- Class For Sending SMS --
public static bool Mobile(string MobileNo, string Message)
{
//where the SMS Gateway is running
string ozSURL = "http://bhashsms.com/api/sendmsg.php";
//username for successful login
string ozUser = HttpUtility.UrlEncode("eea");
//user's password
string ozPassw = "Swash@2017";
//type of message
string ozSender = "deee";
//who will get the message
string ozRecipients = HttpUtility.UrlEncode(MobileNo);
//body of message
string ozMessageData = HttpUtility.UrlEncode("One Time Password For Dolna Site Registration is : " + Message); //body of message
//priority of message
string ozPriority = "ndnd";
//type of message
string ozStype = "normal";
string createdURL = ozSURL +
"?user=" + ozUser +
"&pass=" + ozPassw +
"&sender=" + ozSender +
"&phone=" + ozRecipients +
"&text=" + ozMessageData +
"&priority=" + ozPriority +
"&stype=" + ozStype;
try
{
//Create the request and send data to the SMS Gateway Server by HTTP connection
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);
//Get response from the SMS Gateway Server and read the answer
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
return true;
}
catch (Exception)
{
//if sending request or getting response is not successful the SMS Gateway Server may do not run
return false;
}
}
#endregion
}
private string GeneratePassword(int PasswordLength)
{
#region -- Generating The OTP Password --
string OTP = null;
try
{
// This OTP Code Created By Mr. Satyabrata Behera
string _allowedChars = "0123456789";
Random randNum = new Random();
char[] chars = new char[PasswordLength];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < PasswordLength; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}
catch (Exception Exc)
{
// lblErrorMsg.Text = "Application Error : " + Exc.Message;
return OTP;
}
#endregion
}
#endregion
//protected void btnVerifay_Click(object sender, EventArgs e)
//{
// string OTP = GeneratePassword(5);
// string message = "One Time Password is " + OTP;
// // TextBox txtmobile = (TextBox)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("txtmobile");
// // Panel pnlotp = (Panel)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("pnlotp");
// SendSMS.Mobile(TxtMobileNo.Text, message);
// //SendMail(message);
// Session["OTP"] = OTP;
// // btnVerifay.Visible = false;
// if (Session["OTP"] != "")
// {
// //imgverify.Visible = false;
// pnlotp.Visible = true;
// }
//}
#region MailIntegration
private void SendMail( string otpmsg)
{
string Froms = "satyabrata@kencloud.co.in";
string Tos = txtEmail.Text.Trim();
string UserName = string.Empty;
string url = string.Empty;
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress(Tos, txtName.Text.Trim()));
msg.From = new MailAddress(Froms, "Dolna");
msg.Subject = "Dolna Testing Mail Azure Web App Email using smtp.office365.com";
#region BodySetup
url = "http://kencommerce.azurewebsites.net/DolnaWebsite/Default.aspx";
//string body = "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
string body = "";
body += "Hi, " + txtName.Text.Trim();
body += "<br /><br />Thank you, for Dolna Registration.";
// body += "<br /><br />This is your One Time Password : " + TemporayUseOtp + " use this OTP to complete your registration ";
body += "<br /><br />To Complete Your Registration and verify your email please use the following link";
// body += "<br/>Here Is Your Existing Password : <br/>" + Password + "";
// body += "<br /><a href=\"" + callbackUrl + "\" class='btn btn-default' >Click Here</a>";
body += "<br /><a href=\"" + url + "\" class='btn btn-default' >Activate your account</a>";
//body += "<br /><b>OR</b>";
body += "<br />"+otpmsg+"</b>";
//body += "<br /><br />If you cannot click on the link alternatively copy and paste in to your browser";
body += "<br /><br /> Best Wishes,";
body += "<br />SBackend Team";
body += "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
body += "<br />---------------------------------------------------------------------------";
body += "<br /><b>This is a Auto generated message please donot reply back to this</b>";
#endregion
msg.Body = body; //"Test message using smtp.office365.com on Azure from a Web App";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("satyabrata@kencloud.co.in", "chuma@1234");
client.Port = 587;
client.Host = "smtp.office365.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
try
{
client.Send(msg);
// statusLabel.Text = "Message Sent Succesfully";
}
catch (Exception ex)
{
// statusLabel.Text = ex.ToString();
}
}
#endregion
protected void EmailVerifyBtn_Click(object sender, EventArgs e)
{
string OTP = GeneratePassword(5);
string message = "One Time Password is " + OTP;
SendMail(message);
Session["OTP2"] = OTP;
// btnVerifay.Visible = false;
if (Session["OTP2"] != "")
{
pnlotpEmail.Visible = true;
}
}
protected void btnimg3_Click(object sender, EventArgs e)
{
string sessonOtp = Session["OTP2"].ToString();
if (txtotp1.Text == sessonOtp)
{
EmailVerifyBtn.Visible = false;
Image1Email.Visible = true;
pnlotpEmail.Visible = false;
//btnVerifay.Enabled = true;
TxtMobileNo.Enabled = true;
btn_submit.Enabled = true;
}
else
{
lblmsgEmail.Text = "Enter a valid OTP";
}
}
}
}
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace KenCommerceWeb.PublicWebsites
{
public partial class Registerpage : System.Web.UI.Page
{
HttpClient client = new HttpClient();
List<Master_Login_User> Login_UserList = null;
public List<Master_Login_User> gETMaster_Login_User = new List<Master_Login_User>();
Master_Login_User Login_UserEntity = new Master_Login_User();
protected void Page_Load(object sender, EventArgs e)
{
var appsurl = ConfigurationManager.AppSettings["APIPath"].ToString();
client.BaseAddress = new Uri(appsurl);
if (!IsPostBack)
{
//btnVerifay.Visible = true;
//imgverify.Visible = false;
clear();
}
}
private List<Master_Login_User> GetLogin_User()
{
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
Login_UserList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
return Login_UserList.ToList();
}
else
{
return null;
}
}
protected void clear()
{
txtEmail.Text = "";
txtName.Text = "";
txtPassword.Text = "";
txtConfirmPassword.Text = "";
TxtMobileNo.Text = "";
Image1Email.Visible = false;
imgverify.Visible = false;
//btnVerifay.Visible = true;
//btnVerifay.Enabled = false;
EmailVerifyBtn.Visible = true;
//TxtMobileNo.Enabled = false;
}
protected string isKartSession()
{
if (Session["PLACE ORDER"] != null && Session["PLACE ORDER"].ToString() == "PLACE ORDER")
{
return "~/Order/AddCartList.aspx";
}
else if (Session["BUY NOW"] != null && Session["BUY NOW"].ToString() == "BUY NOW")
{
return "~/PublicWebsites/Add2Cart.aspx";
}
else
{
return "";
}
}
protected void btn_submit_Click(object sender, EventArgs e)
{
// SendMail();
var data = GetLogin_User().Where(a => a.Login_EmailId == txtEmail.Text).FirstOrDefault();
if (data == null)
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//if (RadRadioButtonList1.SelectedValue == "Seller")
//{
// Login_UserEntity.Login_User_Type = "Seller";
//}
//else
//{
// Login_UserEntity.Login_User_Type = "Customer";
//}
if (RadRadioButtonList1.SelectedValue == "Customer")
{
Login_UserEntity.Login_User_Type = RadRadioButtonList1.SelectedValue.ToString();
Login_UserEntity.Login_EmailId = txtEmail.Text;
Login_UserEntity.Login_Username = txtName.Text;
Login_UserEntity.Login_Password = txtPassword.Text;
Login_UserEntity.InsertedOn = DateTime.Now;
Login_UserEntity.Login_MobileNo = TxtMobileNo.Text;
Login_UserEntity.InsertedBy = 0;
//Login_UserEntity.LastModifiedOn = ;
//Login_UserEntity.LastModifiedBy =
Login_UserEntity.IsActive = true;
Login_UserEntity.IsDelete = false;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", Login_UserEntity).Result;
if (content.IsSuccessStatusCode)
{
clear();
string LoginUID = content.Content.ReadAsStringAsync().Result;
Session["Loginuserid"] = LoginUID;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
Login_UserList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in Login_UserList
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
if (isKartSession() == "")
{
Response.Redirect("~/PublicWebsites/Default.aspx", false);
}
else
{
Response.Redirect(isKartSession());
}
}
}
// Session["Loginuserid"] != null && Session["UserName"] != null && Session["UserType"] != null && Session["UserMailId"] != null && Session["UserMailId"] != null && Session["Loged"] != null
//Session["Loginuserid"] = login.Login_User_ID.ToString();
//Response.Redirect("~/RegistationPage.aspx");
//Response.Redirect("~/DolnaWebsite/Default.aspx");
}
}
if (RadRadioButtonList1.SelectedValue == "Artist")
{
Login_UserEntity.Login_User_Type = RadRadioButtonList1.SelectedValue.ToString();
Login_UserEntity.Login_EmailId = txtEmail.Text;
Login_UserEntity.Login_Username = txtName.Text;
Login_UserEntity.Login_Password = txtPassword.Text;
Login_UserEntity.InsertedOn = DateTime.Now;
Login_UserEntity.Login_MobileNo = TxtMobileNo.Text;
Login_UserEntity.InsertedBy = 0;
Login_UserEntity.IsActive = true;
Login_UserEntity.IsDelete = false;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", Login_UserEntity).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
Login_UserList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in Login_UserList
where a.Login_User_ID == Convert.ToInt32(LoginUID)
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
clear();
if (isKartSession() == "")
{
Response.Redirect("~/Supplier/Default.aspx");
}
else
{
Response.Redirect(isKartSession());
}
}
}
}
}
if (RadRadioButtonList1.SelectedValue == "Gallerist")
{
Login_UserEntity.Login_User_Type = RadRadioButtonList1.SelectedValue.ToString();
Login_UserEntity.Login_EmailId = txtEmail.Text;
Login_UserEntity.Login_Username = txtName.Text;
Login_UserEntity.Login_Password = txtPassword.Text;
Login_UserEntity.InsertedOn = DateTime.Now;
Login_UserEntity.Login_MobileNo = TxtMobileNo.Text;
Login_UserEntity.InsertedBy = 0;
Login_UserEntity.IsActive = true;
Login_UserEntity.IsDelete = false;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", Login_UserEntity).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
Login_UserList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in Login_UserList
where a.Login_User_ID == Convert.ToInt32(LoginUID)
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
clear();
if (isKartSession() == "")
{
Response.Redirect("~/Supplier/Default.aspx");
}
else
{
Response.Redirect(isKartSession());
}
}
}
}
}
}
else
{
clear();
// Response.Redirect("~/DolnaWebsite/Registerpage.aspx");
Notification.Text = "Already exsit!";
Notification.Show();
}
}
protected void btn_reset_Click(object sender, EventArgs e)
{
clear();
}
protected void btnimg_Click(object sender, EventArgs e)
{
//Image imgverify = (Image)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("imgverify");
//Panel pnlotp = (Panel)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("pnlotp");
//TextBox txtotp = (TextBox)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("txtotp");
//Label lblmsg = (Label)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("lblmsg");
string sessonOtp = Session["OTP"].ToString();
if (txtotp.Text == sessonOtp)
{
// btnVerifay.Visible = false;
imgverify.Visible = true;
pnlotp.Visible = false;
btn_submit.Enabled = true;
}
else
{
lblmsg.Text = "Enter a valid OTP";
}
}
#region Otp Method
public class SendSMS
{
#region -- Class For Sending SMS --
public static bool Mobile(string MobileNo, string Message)
{
//where the SMS Gateway is running
string ozSURL = "http://bhashsms.com/api/sendmsg.php";
//username for successful login
string ozUser = HttpUtility.UrlEncode("eea");
//user's password
string ozPassw = "Swash@2017";
//type of message
string ozSender = "deee";
//who will get the message
string ozRecipients = HttpUtility.UrlEncode(MobileNo);
//body of message
string ozMessageData = HttpUtility.UrlEncode("One Time Password For Dolna Site Registration is : " + Message); //body of message
//priority of message
string ozPriority = "ndnd";
//type of message
string ozStype = "normal";
string createdURL = ozSURL +
"?user=" + ozUser +
"&pass=" + ozPassw +
"&sender=" + ozSender +
"&phone=" + ozRecipients +
"&text=" + ozMessageData +
"&priority=" + ozPriority +
"&stype=" + ozStype;
try
{
//Create the request and send data to the SMS Gateway Server by HTTP connection
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);
//Get response from the SMS Gateway Server and read the answer
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
return true;
}
catch (Exception)
{
//if sending request or getting response is not successful the SMS Gateway Server may do not run
return false;
}
}
#endregion
}
private string GeneratePassword(int PasswordLength)
{
#region -- Generating The OTP Password --
string OTP = null;
try
{
// This OTP Code Created By Mr. Satyabrata Behera
string _allowedChars = "0123456789";
Random randNum = new Random();
char[] chars = new char[PasswordLength];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < PasswordLength; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}
catch (Exception Exc)
{
// lblErrorMsg.Text = "Application Error : " + Exc.Message;
return OTP;
}
#endregion
}
#endregion
//protected void btnVerifay_Click(object sender, EventArgs e)
//{
// string OTP = GeneratePassword(5);
// string message = "One Time Password is " + OTP;
// // TextBox txtmobile = (TextBox)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("txtmobile");
// // Panel pnlotp = (Panel)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("pnlotp");
// SendSMS.Mobile(TxtMobileNo.Text, message);
// //SendMail(message);
// Session["OTP"] = OTP;
// // btnVerifay.Visible = false;
// if (Session["OTP"] != "")
// {
// //imgverify.Visible = false;
// pnlotp.Visible = true;
// }
//}
#region MailIntegration
private void SendMail( string otpmsg)
{
string Froms = "satyabrata@kencloud.co.in";
string Tos = txtEmail.Text.Trim();
string UserName = string.Empty;
string url = string.Empty;
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress(Tos, txtName.Text.Trim()));
msg.From = new MailAddress(Froms, "Dolna");
msg.Subject = "Dolna Testing Mail Azure Web App Email using smtp.office365.com";
#region BodySetup
url = "http://kencommerce.azurewebsites.net/DolnaWebsite/Default.aspx";
//string body = "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
string body = "";
body += "Hi, " + txtName.Text.Trim();
body += "<br /><br />Thank you, for Dolna Registration.";
// body += "<br /><br />This is your One Time Password : " + TemporayUseOtp + " use this OTP to complete your registration ";
body += "<br /><br />To Complete Your Registration and verify your email please use the following link";
// body += "<br/>Here Is Your Existing Password : <br/>" + Password + "";
// body += "<br /><a href=\"" + callbackUrl + "\" class='btn btn-default' >Click Here</a>";
body += "<br /><a href=\"" + url + "\" class='btn btn-default' >Activate your account</a>";
//body += "<br /><b>OR</b>";
body += "<br />"+otpmsg+"</b>";
//body += "<br /><br />If you cannot click on the link alternatively copy and paste in to your browser";
body += "<br /><br /> Best Wishes,";
body += "<br />SBackend Team";
body += "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
body += "<br />---------------------------------------------------------------------------";
body += "<br /><b>This is a Auto generated message please donot reply back to this</b>";
#endregion
msg.Body = body; //"Test message using smtp.office365.com on Azure from a Web App";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("satyabrata@kencloud.co.in", "chuma@1234");
client.Port = 587;
client.Host = "smtp.office365.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
try
{
client.Send(msg);
// statusLabel.Text = "Message Sent Succesfully";
}
catch (Exception ex)
{
// statusLabel.Text = ex.ToString();
}
}
#endregion
protected void EmailVerifyBtn_Click(object sender, EventArgs e)
{
string OTP = GeneratePassword(5);
string message = "One Time Password is " + OTP;
SendMail(message);
Session["OTP2"] = OTP;
// btnVerifay.Visible = false;
if (Session["OTP2"] != "")
{
pnlotpEmail.Visible = true;
}
}
protected void btnimg3_Click(object sender, EventArgs e)
{
string sessonOtp = Session["OTP2"].ToString();
if (txtotp1.Text == sessonOtp)
{
EmailVerifyBtn.Visible = false;
Image1Email.Visible = true;
pnlotpEmail.Visible = false;
//btnVerifay.Enabled = true;
TxtMobileNo.Enabled = true;
btn_submit.Enabled = true;
}
else
{
lblmsgEmail.Text = "Enter a valid OTP";
}
}
}
}
Comments
Post a Comment