private void Bind() { DataTable table = ocart.getcartlist(ocart.GetShoppingCartId()); this.cartrepeater.DataSource = table.DefaultView; this.cartrepeater.DataBind(); this.counttypelieteral.Text = this.cartrepeater.Items.Count.ToString(); this.countnumlieteral.Text = num.ToString(); this.countpricelieral.Text = price.ToString(); }
public int createorder(string orderid, int userid, string acceptname, string address, string postalcode, string phone, string delivery, string payment, int state, DateTime ordertime, double orderprice, int ordercount) { StringBuilder sb = new StringBuilder(); sb.Append("insert into orders (orderid,[userid],acceptname,address,postalcode,phone,delivery,payment,state,ordertime,orderprice,ordercount) values "); sb.Append("(@orderid,@userid,@acceptname,@address,@postalcode,@phone,@delivery,@payment,@state,@ordertime,@orderprice,@ordercount)"); OleDbParameter[] param1 = { OleDbHelper.GetParameter("@orderid", OleDbType.Char, 50, "orderid", orderid), OleDbHelper.GetParameter("@userid", OleDbType.Integer, 4, "[userid]", userid), OleDbHelper.GetParameter("@acceptname", OleDbType.Char, 50, "acceptname", acceptname), OleDbHelper.GetParameter("@address", OleDbType.Char, 200, "address", address), OleDbHelper.GetParameter("@postalcode", OleDbType.Char, 50, "postalcode", postalcode), OleDbHelper.GetParameter("@phone", OleDbType.Char, 50, "phone", phone), OleDbHelper.GetParameter("@delivery", OleDbType.Char, 50, "delivery", delivery), OleDbHelper.GetParameter("@payment", OleDbType.Char, 50, "payment", payment), OleDbHelper.GetParameter("@state", OleDbType.Integer, 4, "state", state), OleDbHelper.GetParameter("@ordertime", OleDbType.Date, 8, "ordertime", ordertime), OleDbHelper.GetParameter("@orderprice", OleDbType.Double, 8, "orderprice", orderprice), OleDbHelper.GetParameter("@ordercount", OleDbType.Integer, 4, "ordercount", ordercount) }; List <OleDbParameter[]> paramlist = new List <OleDbParameter[]>(); List <string> sqls = new List <string>(); sqls.Add(sb.ToString()); paramlist.Add(param1); cart mycart = new cart(); DataTable carttable = mycart.getcartlist(mycart.GetShoppingCartId()); for (int i = 0; i < carttable.Rows.Count; i++) { sqls.Add("insert into orderdetails (productid,[count],orderid) values (@productid,@count,@orderid)"); OleDbParameter[] param = { new OleDbParameter("@productid", Int64.Parse(carttable.Rows[i]["productid"].ToString())), new OleDbParameter("@count", int.Parse(carttable.Rows[i]["count"].ToString())), new OleDbParameter("@orderid", orderid) }; //OleDbParameter[] param = // {OleDbHelper.GetParameter("@productid",OleDbType.Integer,4,"productid",Int64.Parse(carttable.Rows[i]["productid"].ToString())), // OleDbHelper.GetParameter("@count",OleDbType.Integer,4,"count",int.Parse(carttable.Rows[i]["count"].ToString())), // OleDbHelper.GetParameter("@orderid",OleDbType.Char,50,"orderid",orderid) // }; paramlist.Add(param); } return(OleDbHelper.executeNonQuery(sqls.ToArray(), paramlist)); }
public void SetCookie(string username) { DataTable table = getUser(username); if (table.Rows.Count > 0) { int userID = int.Parse(table.Rows[0]["userid"].ToString()); int power = int.Parse(table.Rows[0]["power"].ToString()); string userData = username.Replace(@"\", @"\\") + "#" + power.ToString(); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userID.ToString(), DateTime.Now, DateTime.Now.AddMinutes(60), false, userData, FormsAuthentication.FormsCookiePath); string encTicket = FormsAuthentication.Encrypt(ticket); HttpCookie newCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); HttpContext.Current.Response.Cookies.Add(newCookie); cart ocart = new cart(); string oldcartid = ocart.GetShoppingCartId(); ocart.migratecart(oldcartid, userID.ToString()); } }