void RejectInventoryChanges(int orderId) { lw.ShoppingCart.ShoppingDsTableAdapters.ShoppingItemsTableAdapter adp = new lw.ShoppingCart.ShoppingDsTableAdapters.ShoppingItemsTableAdapter(); ShoppingDs.ShoppingItemsDataTable dt = adp.GetDataByOrder(orderId); StringBuilder sb = new StringBuilder(); foreach (DataRow row in dt.Rows) { if (row["OptionsKey"] == System.DBNull.Value || row["OptionsKey"].ToString() == "") { sb.Append(string.Format("Update Items set StockQuantity = StockQuantity + {0} where ItemId={1};", row["Quantity"], row["ItemId"])); } else { sb.Append(string.Format("Update ItemOptionsInventory set Inventory=Inventory+{0} where ItemId={1} and [Key]='{2}';", row["Quantity"], row["ItemId"], row["OptionsKey"])); } } if (sb.Length > 0) { DBUtils.ExecuteQuery(sb.ToString(), cte.lib); } }
public string GetShoppingItems(OrdersDS.OrdersRow order) { lw.ShoppingCart.ShoppingDsTableAdapters.ShoppingItemsTableAdapter adp = new lw.ShoppingCart.ShoppingDsTableAdapters.ShoppingItemsTableAdapter(); StringBuilder sb = new StringBuilder(); ShoppingDs.ShoppingItemsDataTable shoppingItems = adp.GetDataByOrder(order.OrderId); sb.Append("<table width=500 border=1 cellpadding=3>"); sb.Append("<tr style=\"font-weight:bold\"><td>Product</td><td>Quantity</td><td>Unit Price</td><td>Sub Total</td></tr>"); bool alter = false; foreach (ShoppingDs.ShoppingItemsRow item in shoppingItems) { sb.Append(string.Format( "<tr bgcolor={0}><td>{1}<BR /># {2}<BR>{3}</td><td>{4}<BR />{6}</td><td>{5}</td><td>{7}</td></tr>", alter ? "#ffffff" : "#efefef", item.Title, item.ItemNumber, item.Description, item.Quantity, string.Format("{0:##,###0.00} SAR", item.UnitPrice), item.PriceFor, string.Format("{0:##,###0.00} SAR", item.Quantity * item.UnitPrice) ) ); alter = !alter; } sb.Append("<tr><td colspan=4 align=right>"); sb.Append(string.Format("Sub Total: {0:##,###0.00} SAR<br />", order.SubTotal)); sb.Append(string.Format("Shipping: {0:##,###0.00} SAR<br />", order.Shipping)); sb.Append(string.Format("Handling: {0:##,###0.00} SAR<br />", order.Handling)); if (order.Discount > 0) { sb.Append(string.Format("Discount: {0:##,###0.00} SAR<br />", order.SubTotal)); } if (order.VoucherValue != 0) { sb.Append(string.Format("Voucher Code Value: {0:##,###0.00} SAR<br />", order.VoucherValue)); } string paymentName = ""; lw.Payments.Payment payment = lw.Payments.Payments.GetPayment(order.PaymentType); if (payment != null) { paymentName = payment.DisplayName; } sb.Append(string.Format("Payment Type: {0}<br />", paymentName)); sb.Append(string.Format("Payment Cost: {0:##,###0.00} SAR<br />", order.PaymentCost)); sb.Append(string.Format("<b>Order Total: {0:##,###0.00} SAR</b><br />", order.Total)); sb.Append("</td></tr></table>"); return(sb.ToString()); }