January 3rd, 2014, 12:03 AM
N-Tier C# Master Detail member
I am using Visual Studio 2010, Sql server Express Edition & C#.
I have develop a simple Master Detail application (mostly with the help of experts help from this forum) An Order system, and now I want to go one step further from simple application to N-Tier version.
Did some search on net and came up with Tutorial which guides me enough to create Order class which contains methods: -DataTable GetOrders(int OrdId) Retrieve order based on ID provided -int SaveData(string CustID, DateTime ShpDate, DateTime OrdDate) To save the order, This method has all Insert, Update, Delete command in it, using SqlAdapter.
Following the same pattern I've also created OrderDetails class for setting up line items for each order. OrderDetails also contains methods GetOrder & SaveData...
I've created DAL class for data access ofcourse, purpose of which is to provide Database connection and execute Sql commands or stored proc.
As mentioned in my question, I've created Order class which will access DAL class and Get and Save Order..
The problem I am facing is from OrderDetails class...
My approach is: On the Winform (which is I think Presentation layer) when user clicks save button It should do the following:
1-Create Order class instance (for eg. Order od = new Order()) and then call Order class SaveData method by providing parameters: Like od.SaveData(OrdId,CustId OrdDate, ShpDate)
Which then ultimately save the order Master data...Order master is bind to DataTable.
Now the problem: How should I save OrderDetails...which is in DataGridView name dgGrd, dgGrd is also bind to DataTable.
OrderDetails also have SaveData method which take parameters (ProductID, Quantity, UnitPrice)...How should I call SaveData method within Order class? How should I pass whole DataGridView DataTable to SaveData method of OrderDetails class?
I will be very much appreciate if you could help me to line up my coding, perhaps anyone could provide a sample? showing N-Tier Master Detail...I am still at beginner learning stage...And still doing lots of net searching for answer..
Thanks in advance
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!