Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleting orders - one more time
Message
De
27/05/2009 18:13:38
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01402330
Message ID:
01402357
Vues:
53
This message has been marked as a message which has helped to the initial question of the thread.
See my comments in line below.

>I'm thinking I programmed everything wrong. Obviously Biz object should be able itself to delete order and its details. Also in the way I implemented it now everything seems to be coupled - interface should not go through details of accessing DataSet row and passing PK, I think.

>
>Let me first understand how should I have programmed it and then try to fix the problem.
>
>In the meantime, this is the whole Order Biz

>

Well sort of. You could have the Orders Biz obj to participate in the delete of the line items. You might consider having a method for deleting orders in your orders business object where you pass in a boolean parameter to also delete any order items. This way it refuse to delete orders if it contains line items or if you pass in true, it would delete line items also. To delete line items, your orders business object would call a method on the line items business object to delete all order line items with the specified order ID. I probably wouldn't actually delete line items from within the orders biz obj itself. Maybe something like below code.
public int DeleteOrders(int orderID, bool deleteLineItems)
{
     bool llSuccess = true;
     if (deleteLineItems)
     {
          LineItemsBizObj oLineItems = new LineItemsBizObj();
          oLineItems.DeleteRowsByOrderID(orderID);
     }
     else
     {
          // Here you could check if so inclined to verify there are not detail line items
         // if there are then set llSuccess to false
     }
     if (llSuccess)
         // Do your delete order Item here.
}

>the _dtSearch is a form's property
>
>// Used for search results
> private OrdersDataSet.OrdersDataTable _dtOrderSearch = new OrdersDataSet.OrdersDataTable();
>
>and the DataGrid uses it as its source.


Then as I mentioned, this is why you were seeing the rows disappear in the grid, but you were not actually deleting the data in the back end.
You would need to delete the order via the business object as I stated above.


>>
>>Is _itemBiz.DeleteItemsByOrderKey a method on a business object? Why not use the same methodology for deleting the actual order as well. Also, you should verify the line items were deleted before attempting to delete the actual order. What is _dtOrderSearch? If this is a grid, then that explains why you are seeing the order disappear in the grid but not deleted in the data.
>>Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform