Cookie DataList實現購物車

2021-08-25 00:05:44 字數 2326 閱讀 9878

分享是一種美德

--(1)下面是購物車類

namespace xr.web /// /// 將商品資訊新增到購物籃 /// /// 商品編號 /// 數量 public static void addshoppingcart(int productid, int amount) else ; httpcookie mycookie = (httpcookie)httpcontext.current.request.cookies["shoppingcart"]; mycookie.expires = datetime.now.adddays(1); string sprodid = mycookie.value.tostring(); string arrcookie = sprodid.split(sep); //檢視cookie中是否有該產品 string newcookie = ""; for (int i = 0; i < arrcookie.length; i++) else } } if (!bexists) else } else httpcontext.current.response.cookies.add(mycookie); } } /// /// 刪除相應產品 /// /// /// public static int removeshoppingcart(int productid) else ; ocookie.expires = datetime.now.addhours(6); //check if cookie already contain same item string sprodid = ocookie.value.tostring(); string arrcookie = sprodid.split(sep); string arrcookie2 = new string[arrcookie.length - 1]; int j = 0; for (int i = 0; i < arrcookie.length; i++) } string scookieid = ""; for (int i = 0; i < arrcookie2.length; i++) if (scookieid.length > 0) else httpcontext.current.response.cookies.add(ocookie); if (ocookie.value.length < cookiestotal) else } catch } return result; } /// /// 更新產品的數量 /// /// /// /// public static int updateshoppingcart(int productid, int account) else } } mycookie.value = newcookie.substring(1); httpcontext.current.response.cookies.add(mycookie); if (oldaccount != account) return results; } } }

--(2)商品的更新刪除,頁面

datatable mytable = new datatable(); productbll productinfo = new productbll(); protected decimal total = 0; protected string member = string.empty; protected void page_load(object sender, eventargs e) } private void binddata() else ; string sarrprodid = sproductid.split(sep); datatable dt = new datatable(); dt.columns.add(new datacolumn("id")); dt.columns.add(new datacolumn("title")); dt.columns.add(new datacolumn("total")); dt.columns.add(new datacolumn("price")); dt.columns.add(new datacolumn("pictureurl")); int counter = 1; for (int i = 0; i < sarrprodid.length; i++) datalist1.datasource = dt; datalist1.databind(); } } } protected void datalist1_deletecommand(object source, datalistcommandeventargs e) else binddata(); } public void updateshopping(int productid, string acount) protected void textbox1_textchanged(object sender, eventargs e) binddata(); }

實變函式 實分析總結

一 概述。實變函式,又叫實分析,整本書滿滿的證明就講了乙個勒貝格積分。最為大家所熟知的是用牛頓 萊布尼茨公式算的黎曼積分。但是黎曼積分本身依賴於函式的連續性,像不連續的狄利克雷函式就無法積分了。為了解決這一問題,勒貝格利用分割值域的方法,使得函式可積。但是分割出來的值域,只能放在一起,形式集合。如果...

NestedScrollWebview實現與優化

nestedscrollwebview實現與優化 原文如下 好久沒寫了,好像也沒什麼人關注我,呵呵,但我還是堅持寫一下,希望能幫到有需要的人!今天我來說一下nestedscrollwebview。最近在弄乙個需求,我需要用到coordinatorlayout webview 實現滾動互動效果,但要實...

saltstack keepalived實現高可用

本篇部落格承接saltstack安裝部署和saltstack grains,pillar,jinja模組的使用 建立目錄。root server1 keepalived vim files keepalived.conf configuration file for keepalived globa...