我正在研究mircosoft asp网站上的asp.net tailspin spyworks教程,当我在最后提交订单时,我收到了try catch块的错误,只是想知道是否有人可以帮助我,这是下面的错误 TAILSPIN SPYWORKS TRY CATCH ERROR
public bool SubmitOrder(string UserName)
{
using (CommerceEntities1 db = new CommerceEntities1())
{
try
{
//----------------------------------------------------------------+
// Add New Order Record |
//----------------------------------------------------------------+
Order newOrder = new Order();
newOrder.CustomerName = UserName;
newOrder.OrderDate = DateTime.Now;
newOrder.ShipDate = CalculateShipDate();
db.Orders.Add(newOrder);
db.SaveChanges();
//----------------------------------------------------------------+
// Create a new OderDetail Record for each item in the Shopping
String cartId = GetShoppingCartId();
var myCart = (from c in db.ViewCarts where c.CartID == cartId select c);
foreach (ViewCart item in myCart)
{
int i = 0;
if (i < 1)
{
OrderDetail od = new OrderDetail();
od.OrderID = newOrder.OrderID;
od.ProductID = item.ProductID;
od.Quantity = item.Quantity;
od.UnitCost = item.UnitCost;
db.OrderDetails.Add(od);
i++;
}
var myItem = (from c in db.ShoppingCarts
where c.CartID == item.CartID &&
c.ProductID == item.ProductID
select c).FirstOrDefault();
if (myItem != null)
{
db.DeleteObject(myItem);
}
}
db.SaveChanges();
}
catch (Exception exp)
{
throw new Exception("ERROR: Unable to Submit Order - " + exp.Message.ToString(),
exp);
}
}
return (true);
}
用户代码
未处理异常错误:无法提交订单 - 方法或操作不是 实现。