public void make_new_order(IorderBO order)
{
int id;
using (SqlConnection con = DButility.getconnection())
{
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "placeorder";
com.Parameters.AddWithValue("@Customer_name", order.Customer_name);
com.Parameters.AddWithValue("@Email_id", order.Email_id);
com.Parameters.AddWithValue("@Phone_number", order.Phone_number);
com.Parameters.AddWithValue("@Required_quantity", order.Required_quantity);
com.Parameters.AddWithValue("@Product_id", order.Product_id);
int row_affected = com.ExecuteNonQuery();
if(row_affected>0)
{
HttpContext.Current.Response.Write("<script>alert('Order placed Sucessfully!!')</script>");
string s = "select max(Order_id) from manchester";
SqlCommand c = new SqlCommand(s, con);
id = (int)c.ExecuteScalar();
HttpContext.Current.Response.Write("<script>alert('Please note your Order-Id:" + id + "')</script>");
}
con.Close();
}
}
public List<IorderBO> view_all_order()
{
using(SqlConnection con = DButility.getconnection())
{
List<IorderBO> list_of_order = new List<IorderBO>();
SqlCommand com = new SqlCommand();
com.Connection = con;
con.Open();
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "see";
SqlDataReader r = com.ExecuteReader();
while(r.Read())
{
int id = Convert.ToInt16(r["Order_id"].ToString());
int pid = Convert.ToInt16(r["Product_id"].ToString());
int re = Convert.ToInt16(r["Required_quantity"].ToString());
string n = r["Customer_name"].ToString();
string e = r["Email_id"].ToString();
Int64 p = Convert.ToInt64(r["Phone_number"].ToString());
IorderBO or = new orderBO(id, pid, re, n, e, p);
list_of_order.Add(or);
}
con.Close();
return list_of_order;
}
}
public DataTable searchby_id(int id)
{
using (SqlConnection con = DButility.getconnection())
{
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "seestat";
com.Parameters.AddWithValue("@Product_id", id);
DataTable d = new DataTable();
SqlDataReader r = com.ExecuteReader();
d.Load(r);
return d;
//con.Close();
}
}
Even the grid view event is not working protected void Page_Load(object sender, EventArgs e) { List list_order = new List(); list_order = o.view_all_order(); GridView1.DataSource = list_order; GridView1.DataBind(); }