public ActionResult EditRows(Order editedOrder) { // Get the grid and database (northwind) models var gridModel = new OrdersJqGridModel(); var northWindModel = new NorthwindDataContext(); // If we are in "Edit" mode if (gridModel.OrdersGrid.AjaxCallBackMode == AjaxCallBackMode.EditRow) { // Get the data from and find the Order corresponding to the edited row Order order = (from o in northWindModel.Orders where o.OrderID == editedOrder.OrderID select o).First<Order>(); // update the Order information order.OrderDate = editedOrder.OrderDate; order.CustomerID = editedOrder.CustomerID; order.Freight = editedOrder.Freight; order.ShipName = editedOrder.ShipName; northWindModel.SubmitChanges(); } if (gridModel.OrdersGrid.AjaxCallBackMode == AjaxCallBackMode.AddRow) { // since we are adding a new Order, create a new istance Order order = new Order(); // set the new Order information order.OrderID = (from o in northWindModel.Orders select o) .Max<Order>(o => o.OrderID) + 1; order.OrderDate = editedOrder.OrderDate; order.CustomerID = editedOrder.CustomerID; order.Freight = editedOrder.Freight; order.ShipName = editedOrder.ShipName; northWindModel.Orders.InsertOnSubmit(order); northWindModel.SubmitChanges(); } if (gridModel.OrdersGrid.AjaxCallBackMode == AjaxCallBackMode.DeleteRow) { Order order = ( from o in northWindModel.Orders where o.OrderID == editedOrder.OrderID select o) .First<Order>(); // delete the record northWindModel.Orders.DeleteOnSubmit(order); northWindModel.SubmitChanges(); } return RedirectToAction("GridDemo", "Grid"); }
private void detach_Orders(Order entity) { this.SendPropertyChanging(); entity.Customer = null; }
private void attach_Orders(Order entity) { this.SendPropertyChanging(); entity.Customer = this; }
partial void DeleteOrder(Order instance);
partial void UpdateOrder(Order instance);
partial void InsertOrder(Order instance);