protected void LinkButton1_Click(object sender, EventArgs e) { //if (Session["_username"] == null) //{ // Common.MessageAlert.Alert(Page, "对不起,你还没有登入!!"); //} // //引用shoplist //else //{ Model.product mypro = new Model.product(); mypro.id = Convert.ToInt32(Request.QueryString["uid"].ToString()); BLL.BLLshoplist blll = new BLL.BLLshoplist(); SqlDataReader dr = blll.readpro(mypro); DataTable dt; if (Session["dt"] == null) { dt = new DataTable(); dt.Columns.Add("id", typeof(Int32)); dt.Columns.Add("title", typeof(String)); dt.Columns.Add("localprice", typeof(Double)); dt.Columns.Add("posttime", typeof(String)); dt.Columns.Add("buycount", typeof(Int32)); dt.Columns.Add("sumprice", typeof(Int32)); } else { dt = (DataTable)Session["dt"]; } DataRow row = dt.NewRow(); if (dr.Read()) { row["id"] = Convert.ToInt32(dr["_id"].ToString()); row["title"] = Convert.ToString(dr["_title"].ToString()); row["localprice"] = Convert.ToDouble(dr["_localprice"].ToString()); row["posttime"] = Convert.ToString(dr["_posttime"].ToString()); row["buycount"] = 1; row["sumprice"] = Convert.ToDouble(dr["_localprice"].ToString()); dt.Rows.Add(row); } dr.Close(); Session["dt"] = dt; Response.Redirect("shoplist.aspx"); }
protected void LinkButton1_Click(object sender, EventArgs e) { //if (Session["_username"] == null) //{ // Common.MessageAlert.Alert(Page, "对不起,你还没有登入!!"); //} // //引用shoplist //else //{ Model.product mypro = new Model.product(); mypro.id = Convert.ToInt32(Request.QueryString["uid"].ToString()); BLL.BLLshoplist blll = new BLL.BLLshoplist(); MySqlDataReader dr = blll.readpro(mypro); DataTable dt; if (Session["dt"] == null) { dt = new DataTable(); dt.Columns.Add("id", typeof(Int32)); dt.Columns.Add("title", typeof( String )); dt.Columns.Add("localprice", typeof(Double)); dt.Columns.Add("posttime", typeof(String)); dt.Columns .Add ("buycount", typeof (Int32)); dt.Columns.Add("sumprice", typeof(Int32)); } else { dt = (DataTable)Session["dt"]; } DataRow row = dt.NewRow(); if (dr.Read()) { row["id"] = Convert.ToInt32(dr["_id"].ToString()); row["title"] = Convert.ToString (dr["_title"].ToString()); row["localprice"] = Convert.ToDouble(dr["_localprice"].ToString()); row["posttime"] = Convert.ToString(dr["_posttime"].ToString()); row["buycount"] = 1; row["sumprice"] = Convert.ToDouble(dr["_localprice"].ToString()); dt.Rows.Add(row); } dr.Close(); Session["dt"] = dt; Response.Redirect("shoplist.aspx"); }
//订单。。。。。。。 protected void LinkButton2_Click(object sender, EventArgs e) { if (Session["_user_name"] == null) { Common.MessageAlert.Alert(Page, "对不起,您还没有登入!!"); } //引用shoplist else { Model.product mypro = new Model.product(); mypro.id = Convert.ToInt32(Request.QueryString["uid"].ToString()); BLL.BLLshoplist blll = new BLL.BLLshoplist(); SqlDataReader dr = blll.readpro(mypro); DataTable dt; if (Session["dt"] == null) { dt = new DataTable(); dt.Columns.Add("id", typeof(Int32)); dt.Columns.Add("localprice", typeof(Double)); dt.Columns.Add("posttime", typeof(String)); dt.Columns.Add("buycount", typeof(Int32)); dt.Columns.Add("sumprice", typeof(Int32)); dt.Columns.Add("color", typeof(String)); dt.Columns.Add("size", typeof(String)); dt.Columns.Add("title", typeof(String)); dt.Columns.Add("cate", typeof(String)); dt.Columns.Add("image", typeof(String)); dt.Columns.Add("only", typeof(String)); dt.Columns.Add("weight", typeof(String)); dt.Columns.Add("sumweight", typeof(String)); } else { dt = (DataTable)Session["dt"]; for (int i = 0; i < dt.Rows.Count; i++) { if (Convert.ToInt32(dt.Rows[i]["id"]) == mypro.id && Convert.ToString(dt.Rows[i]["color"]) == d_color.Text && Convert.ToString(dt.Rows[i]["size"]) == _size.Text) { dt.Rows[i]["buycount"] = Convert.ToInt32(dt.Rows[i]["buycount"]) + 1; Session["dt"] = dt; Response.Redirect("shoplist.aspx"); return; } } } DataRow row = dt.NewRow(); if (dr.Read()) { row["weight"] = dr["_product_weight"].ToString(); row["sumweight"] = dr["_product_weight"].ToString(); row["only"] = DateTime.Now.ToString("yyyyMMddhhmmssfff"); row["size"] = _size.Text; row["image"] = Image_1.ImageUrl; row["cate"] = cate_name.Text; row["title"] = title_l.Text; row["color"] = d_color.Text; row["id"] = Convert.ToInt32(dr["_id"].ToString()); row["localprice"] = Convert.ToDouble(dr["_local_price"].ToString()); row["posttime"] = Convert.ToString(dr["_post_time"].ToString()); row["buycount"] = 1; row["sumprice"] = Convert.ToDouble(dr["_local_price"].ToString()); dt.Rows.Add(row); } dr.Close(); Session["dt"] = dt; Response.Redirect("shoplist.aspx"); } }