/// <summary> /// 刪除已取得的交易批次的訂單 /// </summary> public static void DeleteOrder() { bool bln_delete = false; string str_id1 = CartID; string str_id2 = ""; int int_hours = 0; DateTime dtm_date1 = DateTime.MinValue; DateTime dtm_date2 = DateTime.Now; if (BuyCart.Rows.Count > 0) { for (int i = 0; i < BuyCart.Rows.Count; i++) { str_id2 = BuyCart.Rows[i]["cart_id"].ToString(); dtm_date1 = DateTime.Parse(BuyCart.Rows[i]["buy_date"].ToString()); int_hours = new TimeSpan(dtm_date1.Ticks - dtm_date2.Ticks).Hours; if (str_id1 == str_id2) { bln_delete = true; } if (int_hours > 3) { bln_delete = true; } if (bln_delete) { BuyCart.Rows[i].Delete(); } } BuyCart.AcceptChanges(); } }
/// <summary> /// 刪除購物車記錄 /// </summary> /// <param name="iRow">記錄ID</param> /// <param name="bConfirm">確定要刪除</param> public static void DeleteRow(int iRow, bool bConfirm) { BuyCart.Rows[iRow].Delete(); if (bConfirm) { BuyCart.AcceptChanges(); } }
/// <summary> /// 清除所有資料 /// </summary> public static void ClearAllData() { if (BuyCart.Rows.Count > 0) { for (int i = 0; i < BuyCart.Rows.Count; i++) { BuyCart.Rows[i].Delete(); } BuyCart.AcceptChanges(); } }
//public static bool dtHasRow() //{ // DataRow[] dr = BuyCart.Select(); //} public static void DeleteCart(string sRowID) { string str_rowid = ""; if (BuyCart.Rows.Count > 0) { for (int i = 0; i < BuyCart.Rows.Count; i++) { str_rowid = BuyCart.Rows[i]["rowid"].ToString(); if (str_rowid == sRowID) { BuyCart.Rows[i].Delete(); } } BuyCart.AcceptChanges(); } }
public static void UpdateCart(string sRowID, int iQty) { string str_rowid = ""; if (BuyCart.Rows.Count > 0) { for (int i = 0; i < BuyCart.Rows.Count; i++) { str_rowid = BuyCart.Rows[i]["rowid"].ToString(); if (str_rowid == sRowID) { BuyCart.Rows[i]["qty"] = iQty; int price = int.Parse(BuyCart.Rows[i]["price"].ToString()); BuyCart.Rows[i]["amount"] = iQty * price; } } BuyCart.AcceptChanges(); } }