pram[10].Value = System.DateTime.Now;
pram[11].Value = currency1;
//Now create loop to insert
for (int i = 0; i < pram.Length; i++)
{
cmd.Parameters.Add(pram[i]);
}
cmd.Parameters.AddWithValue("@amount", amount);
// cmd.Parameters.AddWithValue("@currency", currency);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
}
catch (System.Data.SqlClient.SqlException ex_msg)
{
//Here will be catch elements
string msg = "ERROR occured while Inserting -";
msg += ex_msg.Message;
throw new Exception(msg);
}
conn.Close();
//-------------------------MAIL SENDING GOES HERE-------------------------------------
String username1 = "donotreply.mu@manipal.edu";
String password1 = "abc#4321";
MailMessage m1 = new MailMessage();
SmtpClient sc1 = new SmtpClient();
try
{
string email1 = Text_Email.Text;
string name1 = txt_name.Text;
sc1.Host = "smtp.office365.com";
m1.From = new MailAddress(username1, "DoNotReply");
m1.To.Add(new MailAddress(email1, name1));
// m.Bcc.Add(new MailAddress("ashwinimanipal@gmail.com", "Deepthi"));
//m1.CC.Add(new MailAddress("cp.maps@manipal.edu"));
//similarly BCC
m1.Subject = "Registration Ackowledgement: GPPEd 2019 ";
m1.Body = "
";
m1.Body = m1.Body + "Dear " + name + ",
Greetings from MAPS, Manipal Academy of Higher Education!
We acknowledge the receipt of your registration details. Please SAVE the Registration ID given below.
Registration ID : " + regno + "
Name : " + name + "
GPPEd 2019 Registration code : " + regcode + "
Email ID: " + email + "
Mobile No: " + mobile + "
Current University Name : " + univ + "
Country : " + country + "
Nationality : " + nationality + "
MAHE Category : " + mahecategory + "
MAHE ID : " + empid + "
Amount : " + amount + " " + currency1 + "
";
m1.Body = m1.Body + "
Please Note : The registration is complete only after successful payment. In case of online payment you'll receive an intimation immediately.
";
m1.Body = m1.Body + "
Looking forward to seeing you
";
m1.Body = m1.Body + "
Warm Regards
Organizing Committee,
GPPEd 2019
";
m1.Body = m1.Body + "
";
m1.Priority = MailPriority.High;
m1.IsBodyHtml = true;
sc1.Credentials = new System.Net.NetworkCredential(username1, password1);
sc1.Port = 587;
sc1.EnableSsl = true;
sc1.Send(m1);
m1.To.Clear();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
//-------------------------MAIL SENDING ENDS HERE-------------------------------------
//-----------
string stroflusd;
if (currency1 == "USD")
{
conn.Open();
string dvalue = "select top 1 D_value from dollerichtr order by submit_date desc";
//select top 1 D_value from adminstration order by submit_date desc;
SqlCommand cmd_dollar = new SqlCommand(dvalue, conn);
cmd_dollar.ExecuteNonQuery();
SqlDataReader dr_dollar = cmd_dollar.ExecuteReader();
if (dr_dollar.Read())
{
dvalue = dr_dollar["D_value"].ToString();
}
dr_dollar.Close();
dollar = float.Parse(dvalue);
float AmountValue = float.Parse(amount);
AmountValue = AmountValue * dollar;
stroflusd = "Update Reg_GPPEd set amountInDollars='" + AmountValue + "', DollarValue='" + dollar + "' Where Regno ='" + regno + "'";
//conn.Open();
SqlCommand cmdoflusd = new SqlCommand(stroflusd, conn);
cmdoflusd.ExecuteNonQuery();
conn.Close();
}
//Inserting into Payment table
string strpay = "select isnull(right(max(orderid),5),0)+1 from Pay_GPPEd";
try
{
conn.Open();
SqlCommand compay = new SqlCommand(strpay, conn);
int count2 = Convert.ToInt32(compay.ExecuteScalar());
//string str2 = "GM#00000";
conn.Close();
string strp = "GPPEdO_" + Strings.Right("00000" + Convert.ToString(count2), 6);
//reg_id = String.Concat(str2, count);
o_id = strp;
string strp2;
string curdt = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
if (currency1 == "USD")
{
conn.Open();
string dvalue = "select top 1 D_value from dollerichtr order by submit_date desc";
//select top 1 D_value from adminstration order by submit_date desc;
SqlCommand cmd_dollar = new SqlCommand(dvalue, conn);
cmd_dollar.ExecuteNonQuery();
SqlDataReader dr_dollar = cmd_dollar.ExecuteReader();
if (dr_dollar.Read())
{
dvalue = dr_dollar["D_value"].ToString();
}
dr_dollar.Close();
dollar = float.Parse(dvalue);
float AmountValue = float.Parse(amount);
AmountValue = AmountValue * dollar;
conn.Close();
strp2 = "insert into Pay_GPPEd(RegID,orderid,name,Datem,amount,amountInDollars,DollarValue) VALUES" + "('" + regno + "','" + o_id + "','" + name + "','" + curdt + "','" + amount + "','" + AmountValue + "','" + dollar + "')";
}
else
{
strp2 = "insert into Pay_GPPEd(RegID,orderid,name,Datem,amount) VALUES" + "('" + regno + "','" + o_id + "','" + name + "','" + curdt + "','" + amount + "')";
// strp2 = "insert into mipcon17_Payment(RegID,orderid,name,Datem,amount) VALUES" + "('" + reg_id + "','" + o_id + "','" + name1 + "','" + curdt + "','" + amount + "')";
}
conn.Open();
SqlCommand cmd2p = new SqlCommand(strp2, conn);
cmd2p.ExecuteNonQuery();
if (currency1 == "USD")
{
Response.Redirect("pay_international.aspx?amount=" + amount + "&orderid=" + o_id + "&name=" + name + "&Mobile_no=" + mobile + "&email=" + email + "&dollar=" + dollar + "®no=" + regno);
}
else
{
//Response.Redirect("pay.aspx?amount=" + amount + "&orderid=" + o_id + "&name=" + name + "&Mobile_no=" + mobile + "&email=" + email + "®no=" + regno);
Response.Redirect("pay.aspx?amount=" + amount + "&orderid=" + o_id + "&name=" + name + "&Mobile_no=" + mobile + "&email=" + email + "&empid=" + empid + "®no=" + regno);
}
// Response.Redirect("pay.aspx?amount=" + amount + "&orderid=" + o_id + "&name=" + name1 + "&Mobile_no=" + mob1 + "&email=" + email1 + "®no=" + reg_id);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
//Here will be fially elements
conn.Close();
}
}
protected void Page_Load(object sender, EventArgs e)
{
txtcurr.Text = curr;
}
protected void Register_button_Click(object sender, EventArgs e)
{
string[] main_arr;
SqlConnection conn = new SqlConnection(GetConnectionString());
if (string.IsNullOrEmpty(txt_name.Text) || string.IsNullOrEmpty(Text_Email.Text) || string.IsNullOrEmpty(txt_regcode.Text) || string.IsNullOrEmpty(txt_univ.Text) || string.IsNullOrEmpty(txt_country.Text) || string.IsNullOrEmpty(rbNationality.SelectedValue) || string.IsNullOrEmpty(Text_mobile.Text))
{
//Response.Write("Please complete the form.");
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + "Please Fill ALL the Required Fields In The Form" + "')", true);
}
else
{
Text_Email_Leave(sender, e);
if (txt_empid.Text == "")
employeeid = "NA";
else
employeeid = txt_empid.Text;
execution(regno, txt_name.Text, Text_Email.Text, txt_regcode.Text, Text_mobile.Text ,txt_univ.Text,txt_country.Text, rbNationality.SelectedValue, rbMAHEcat.SelectedValue, employeeid, amount.Text);
txt_name.Text = "";
Text_mobile.Text = "";
Text_Email.Text = "";
txt_regcode.Text = "";
txt_univ.Text = "";
txt_country.Text = "";
rbNationality.ClearSelection();
rbMAHEcat.ClearSelection();
rbMAHEcat.ClearSelection();
txt_empid.Text = "";
amount.Text = "";
Text_Email.Text = "";
amount.Text = "";
txtcurr.Text = "";
amount.Text = "";
txtcurr.Text = "";
}
}
protected void emailcheck(object sender, EventArgs e)
{
int count2;
string emailval = Text_Email.Text;
if (!string.IsNullOrEmpty(emailval))
{
SqlConnection conn = new SqlConnection(GetConnectionString());
//INSERT INTO Registration_CME2016(Regno,name,Designation,College,Address,Mobile,Email,SMC_RegNo,Food) VALUES "
//+ "(@regno,@name,@designation,@college,@address,@mobile,@email,@smc_regno,@food)
string emch = "select * from Reg_GPPEd where Email=@emailval";
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(emch, conn);
cmd.Parameters.AddWithValue("@emailval", emailval);
//count2 = Convert.ToInt32(cmd.ExecuteScalar());
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
string cregid = Convert.ToString(reader["Regno"]);
string alum_amount = Convert.ToString(reader["Amount"]);
string alum_name = Convert.ToString(reader["Name"]);
string alum_mobile = Convert.ToString(reader["MobileNo"]);
string alum_email = Convert.ToString(reader["email"]);
string alum_date = Convert.ToString(reader["DateTime"]);
emerrmsg.Visible = true;
emerrmsg.Text = "This Email ID is Already Registered";
HiddenField1.Value = cregid;
// Table1.Visible = false;
Btn_Go.Visible = false;
flag = 1;
string sql_fnl = "select * from Pay_GPPEd where RegID ='" + cregid + "' and status='Transaction Success'";
SqlConnection conn3 = new SqlConnection(GetConnectionString());
conn3.Open();
SqlCommand cmdonlc = new SqlCommand(sql_fnl, conn3);
SqlDataReader reader2 = cmdonlc.ExecuteReader();
if (reader2.HasRows)
{
emerrmsg.Text = "User Registered";
PayCont.Visible = false;
}
else
{
emerrmsg.Text = "User Validated. Proceed to Payment to confirm registration";
PayCont.Visible = true;
Btn_Go.Visible = false;
Table1.Visible = false;
//return;
}
conn3.Close();
}
conn.Close();
}
else
{
emerrmsg.Visible = false;
emerrmsg.Text = "";
Table1.Visible = true;
Btn_Go.Visible = false;
PayCont.Visible = false;
Text_Email.Enabled = false;
flag = 0;
}
}
catch (System.Data.SqlClient.SqlException ex_msg)
{
//Here will be catch elements
string msg = "Error occured while inserting";
msg += ex_msg.Message;
throw new Exception(msg);
}
}
else
{
Btn_Go.Visible = true;
emerrmsg.Visible = false;
emerrmsg.Text = "";
Table1.Visible = false;
PayCont.Visible = false;
}
}
protected void Text_Email_Leave(object sender, EventArgs e)
{
emailcheck(sender, e);
}
protected void PayCont_Click(object sender, EventArgs e)
{
string regid = HiddenField1.Value;
string o_id;
string empid;
string str = "select * from Reg_GPPEd where Regno=@regid";
SqlConnection conn = new SqlConnection(GetConnectionString());
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(str, conn);
cmd.Parameters.AddWithValue("@regid", regid);
cmd.CommandType = CommandType.Text;
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
string alum_name = Convert.ToString(reader["Name"]);
string alum_mobile = Convert.ToString(reader["MobileNo"]);
string alum_email = Convert.ToString(reader["email"]);
string alum_amount = Convert.ToString(reader["amount"]);
string alum_currency = Convert.ToString(reader["currency"]);
string alum_empid = Convert.ToString(reader["EmpId"]);
SqlConnection connonl = new SqlConnection(GetConnectionString());
string strpay = "select isnull(right(max(orderid),5),0)+1 from Pay_GPPEd";
try
{
connonl.Open();
SqlCommand compay = new SqlCommand(strpay, connonl);
int count2 = Convert.ToInt32(compay.ExecuteScalar());
//string str2 = "GM#00000";
string strp = "GPPEdO_" + Strings.Right("00000" + Convert.ToString(count2), 6);
//reg_id = String.Concat(str2, count);
o_id = strp;
string strp2;
string curdt = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
if (alum_currency == "USD")
{
SqlConnection conn1 = new SqlConnection(GetConnectionString());
conn1.Open();
string dvalue = "select top 1 D_value from dollerichtr order by submit_date desc";
//select top 1 D_value from adminstration order by submit_date desc;
SqlCommand cmd_dollar = new SqlCommand(dvalue, conn1);
cmd_dollar.ExecuteNonQuery();
SqlDataReader dr_dollar = cmd_dollar.ExecuteReader();
if (dr_dollar.Read())
{
dvalue = dr_dollar["D_value"].ToString();
}
dr_dollar.Close();
dollar = float.Parse(dvalue);
float AmountValue = float.Parse(alum_amount);
AmountValue = AmountValue * dollar;
conn1.Close();
//SqlConnection cn1 = new SqlConnection(GetConnectGPPEdtring());
//cn1.Open();
//string stroflusd = "Update mipcon17 set amountInDollars='" + AmountValue + "', DollarValue='" + dollar + "' Where RegID ='" + regid + "'";
////conn.Open();
//SqlCommand cmdoflusd = new SqlCommand(stroflusd, cn1);
//cmdoflusd.ExecuteNonQuery();
//cn1.Close();
strp2 = "insert into Pay_GPPEd(RegID,orderid,name,Datem,amount,amountInDollars,DollarValue) VALUES" + "('" + regid + "','" + o_id + "','" + alum_name + "','" + curdt + "','" + alum_amount + "','" + AmountValue + "','" + dollar + "')";
//strp2 = "insert into mipcon17_Payment(RegID,orderid,name,Datem,amount,amountInDollars,DollarValue) VALUES" + "('" + regid + "','" + o_id + "','" + alum_name + "','" + curdt + "','" + alum_amount + "','" + AmountValue + "','" + dollar + "')";
}
else
{
//SqlConnection cn2 = new SqlConnection(GetConnectGPPEdtring());
//cn2.Open();
//string stroflusd = "Update mipcon17 set amount='" + alum_amount + "' Where RegID ='" + regid + "'";
////conn.Open();
//SqlCommand cmdoflusd = new SqlCommand(stroflusd, cn2);
//cmdoflusd.ExecuteNonQuery();
//cn2.Close();
strp2 = "insert into Pay_GPPEd(RegID,orderid,name,Datem,amount) VALUES" + "('" + regid + "','" + o_id + "','" + alum_name + "','" + curdt + "','" + alum_amount + "')";
// strp2 = "insert into mipcon17_Payment(RegID,orderid,name,Datem,amount) VALUES" + "('" + regid + "','" + o_id + "','" + alum_name + "','" + curdt + "','" + alum_amount + "')";
}
SqlConnection connonl1 = new SqlConnection(GetConnectionString());
connonl1.Open();
SqlCommand cmd2p = new SqlCommand(strp2,