using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Net;
public partial class Admin_Generate_Ticket : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
SqlCommand cmd = null;
SqlDataReader dr = null;
string Status = null, ResponseMessage = null, DateCreatedPaymentID = null, MerchantRefNo = null, PaymentID = null, Amount = null, Mode = null, BillingName = null, BillingAddress = null, BillingCity = null, BillingState = null, BillingPostalCode = null, BillingPhone = null, BillingEmail = null, Description = null, IsFlagged = null, TransactionID = null;
protected void Page_Load(object sender, EventArgs e)
{
Check c = new Check();
c.check_admin_state();
if (con.State == System.Data.ConnectionState.Open)
{
con.Close();
}
con.Open();
if (!IsPostBack)
{
if (Request.Form["From"] == "mysite")
{
get_all_details();
//insert_into_pg_details();
if (Status == "0")
{
success_stories();
show_ticket();
}
else
{
failure_stories();
}
}
else
{
Response.Write("");
Load_data l = new Load_data();
Response.Redirect(l.admin_home_page);
}
}
}
protected void insert_into_pg_details()
{
try
{
cmd = new SqlCommand("insert_into_pg_details", con);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add("Status", System.Data.SqlDbType.Int).Value = Convert.ToInt16(Status);
cmd.Parameters.Add("MerchantRefNo", System.Data.SqlDbType.BigInt).Value = Convert.ToInt64(MerchantRefNo);
cmd.Parameters.Add("Amount", System.Data.SqlDbType.Money).Value = Convert.ToDouble(Amount);
cmd.Parameters.Add("Description", System.Data.SqlDbType.NVarChar).Value = Description;
cmd.Parameters.Add("BillingName", System.Data.SqlDbType.NVarChar).Value = BillingName;
cmd.Parameters.Add("BillingAddress", System.Data.SqlDbType.NVarChar).Value = BillingAddress;
cmd.Parameters.Add("BillingCity", System.Data.SqlDbType.NVarChar).Value = BillingCity;
cmd.Parameters.Add("BillingState", System.Data.SqlDbType.NVarChar).Value = BillingState;
cmd.Parameters.Add("BillingPostalCode", System.Data.SqlDbType.NVarChar).Value = BillingPostalCode;
cmd.Parameters.Add("BillingEmail", System.Data.SqlDbType.NVarChar).Value = BillingEmail;
cmd.Parameters.Add("BillingPhone", System.Data.SqlDbType.NVarChar).Value = BillingPhone;
cmd.Parameters.Add("PaymentID", System.Data.SqlDbType.Int).Value = Convert.ToInt64(PaymentID);
cmd.Parameters.Add("IsFlagged", System.Data.SqlDbType.VarChar).Value = IsFlagged;
cmd.Parameters.Add("TransactionID", System.Data.SqlDbType.NVarChar).Value = TransactionID;
cmd.ExecuteNonQuery();
//Response.Write("");
}
catch (SqlException sqlex)
{
Response.Write("");
}
catch (Exception ex)
{
Response.Write("");
}
}
protected void get_all_details()
{
Status = Request.Form["Status"];
MerchantRefNo = Request.Form["reference_no"];
/*Amount = Request.Form["amount"];
Description = Request.Form["description"];
BillingName = Request.Form["name"];
BillingAddress = Request.Form["address"];
BillingCity = Request.Form["city"];
BillingState = Request.Form["state"];
BillingPostalCode = Request.Form["postal_code"];
BillingEmail = Request.Form["email"];
BillingPhone = Request.Form["phone"];
PaymentID = Request.Form["PaymentID"];
IsFlagged = Request.Form["IsFlagged"];
TransactionID = Request.Form["TransactionID"];*/
//Label1.Text = Status + MerchantRefNo + Amount + Description + BillingName + BillingAddress + BillingCity + BillingState + BillingPostalCode + BillingEmail + BillingPhone + PaymentID + IsFlagged + TransactionID;
}
protected void success_stories()
{
cmd = new SqlCommand("update orderdetails set flag='1' where pnr='" + MerchantRefNo + "'", con);
cmd.ExecuteNonQuery();
cmd.Dispose();
cmd = new SqlCommand("select Seat,BusDetail from orders where Pnr='" + MerchantRefNo + "'", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
SqlCommand cmd1 = new SqlCommand("update_seats", con);
cmd1.CommandType = System.Data.CommandType.StoredProcedure;
cmd1.Parameters.Add("@seat", System.Data.SqlDbType.VarChar).Value = dr[0].ToString();
cmd1.Parameters.Add("@bus", System.Data.SqlDbType.VarChar).Value = dr[1].ToString();
cmd1.ExecuteNonQuery();
cmd1.Dispose();
}
}
protected void show_ticket()
{
string seats = null;
SqlCommand select_seat = new SqlCommand("select seat from orders where pnr='" + MerchantRefNo + "'", con);
SqlDataReader select_seat_dr = select_seat.ExecuteReader();
while (select_seat_dr.Read())
{
seats += select_seat_dr[0].ToString() + ",";
}
cmd = new SqlCommand("select Pnr,Bookdate,StartPlace,Destination,CONVERT(VARCHAR(8),Departurtime,108),CONVERT(VARCHAR(8),ArrivalTime,108),Passangername,ContactNo,PassangerAddress,Emailid from orders where pnr='" + MerchantRefNo + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
string pnr = dr[0].ToString();
string bdate = dr[1].ToString();
string start = dr[2].ToString();
string dest = dr[3].ToString();
string start_time = dr[4].ToString();
string reach_time = dr[5].ToString();
string name = dr[6].ToString();
string contact = dr[7].ToString();
string address = dr[8].ToString();
string email = dr[9].ToString();
Label1.Text = "
| Print Ticket |
| ||||||||||||||||||||||||||||||||||||||
string to_mail = "
| ||||||||||||||||||||||||||||||||||||||
try
{
Load_data l = new Load_data();
l.send_mail(email, to_mail);
}
catch (Exception ex)
{
// Response.Write("");
}
}
}
protected void failure_stories()
{
cmd = new SqlCommand("rollback_on_failure", con);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add("pnr", System.Data.SqlDbType.NVarChar).Value = MerchantRefNo;
cmd.ExecuteNonQuery();
Label1.Text = "
| Sorry...... Your Payment Was Failed |
}
protected string get_fare(string pnr)
{
cmd = new SqlCommand("select TotalAmount from OrderDetails where Pnr='" + pnr + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
return dr[0].ToString();
}
else
{
return "Error";
}
}
protected string get_bp(string pnr)
{
cmd = new SqlCommand("select distinct(BoardingPoint) from orders where Pnr='" + pnr + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
return dr[0].ToString();
}
else
{
return "Error";
}
}
protected string get_cn(string pnr)
{
cmd = new SqlCommand("SELECT Bus_facility.facilities FROM Bus_facility INNER JOIN Orders ON Bus_facility.Bus_Ref = Orders.BusDetail where Orders.Pnr =(select distinct(Pnr) from orders where Pnr='" + pnr + "')", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
return dr[0].ToString();
}
else
{
return "Error";
}
}
protected string get_jd(string pnr)
{
cmd = new SqlCommand("SELECT CONVERT(VARCHAR(10),Bus_Detail.Journey_Date,111) FROM Bus_Detail INNER JOIN Orders ON Bus_Detail.Bus_Sno = Orders.BusDetail where Orders.Pnr =(select distinct(Pnr) from orders where Pnr='" + pnr + "')", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
return dr[0].ToString();
}
else
{
return "Error";
}
}
}
Iftikar HussainPosted Jul 4, 2013, 2:37 AM
To send SMS from your ASP.NET application, you need to have SMS gateway. You need buy bulk SMS from any mobile provider. I think AIRTEL and Vodafone provides this. After that you can implement as shown in below link.
http://www.codeproject.com/Questions/318471/Sending-Sms-Using-Asp-net
http://forums.asp.net/t/1884671.aspx/1
Regards,
Iftikar