我正在使用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);
}
堆栈追踪:
[NotImplementedException:未实现方法或操作。] c:\ Users \ podge \ Desktop \ WebApplication23 \ WebApplication23 \ Data_Access \ Model1.Context.cs中的WebApplication23.Data_Access.CommerceEntities1.DeleteObject(ShoppingCart myItem):52 c:\ Users \ podge \ Desktop \ WebApplication23 \ WebApplication23 \ Classes \ MyShoppingCart.cs:116
中的WebApplication23.MyShoppingCart.SubmitOrder(String UserName)[例外:错误:无法提交订单 - 未实施方法或操作。] c:\ Users \ podge \ Desktop \ WebApplication23 \ WebApplication23 \ Classes \ MyShoppingCart.cs中的WebApplication23.MyShoppingCart.SubmitOrder(String UserName):123 WebApplication23.CheckOut.CheckoutBtn_Click(Object sender,ImageClickEventArgs e)位于c:\ Users \ podge \ Desktop \ WebApplication23 \ WebApplication23 \ CheckOut.aspx.cs:27 System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)+115 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)+124 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)+10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)+13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)+35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+1724