2016-06-07 13 views
0
implementiert
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(); 
    }  
} 

Auch die Rasteransicht Ereignis nicht funktioniert protected void Page_Load (object sender, EventArgs e) { Liste list_order = new List(); list_order = o.view_all_order(); GridView1.DataSource = list_order; GridView1.DataBind(); }Warum funktioniert dieses Snippet nicht? das getrennte Modell wird nicht

Antwort

-1
create procedure placeorder 
(@Product_id int , 
@Required_quantity int , 
@Customer_name varchar(50), 
@Email_id varchar(30), 
@Phone_number bigint) 
as 
begin 
insert into manchester values(@Product_id,@Required_quantity,@Customer_name,@Email_id,@Phone_number) 
end 
create procedure see 
as 
begin 
select * from manchester 
end 
exec see 
declare @Product_id int 

create procedure seestat(@Product_id int) 
as 
begin 
select count(Product_id) As Number_of_Orders from manchester where ([email protected]_id) 
end 
Verwandte Themen