Thanks for replying me...
Your help is really precious to me..
Actually, I'm doing a
reservation cart facilities for my proj. (named WISE LIBRARY proj.)
Thought that saying shopping cart might be the same, so I posted the topic as shopping cart. But found out that I need to explain my problems more clearer, so that u can help me...
I do my project using 3-tiers.
1. Data Layer using ---- Class Library
2. Business Logic Layer using ---- ASP.NET Web Service
3. Presentation Layer using ---- ASP.NET Web Application
In the BusinessLogicLayer, I Add Reference to DataLayer.
Then, in the PresentationLayer, I Add Web Reference to BusinessLogicLayer.
Here are my codings:
[u]
DataLayer -- ReservationData.vb</u>
Imports System.Data.OleDb
Public Class ReservationData
Dim ConStr As String
Dim cn As OleDbConnection
Private m_Item As Item
Public Sub New()
ConStr = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\inetpub\wwwroot\ReservationData\WISELIBRARY.mdb "
cn = New OleDbConnection(ConStr)
End Sub
'Search for an item in the database using SQL statement
Public Function SearchItemDetails(ByVal strSearch As String) As DataSet
Dim da As New OleDbDataAdapter("SELECT * FROM Item WHERE Author LIKE '%" & strSearch & "%' OR Title LIKE '%" & strSearch & "%' OR Publisher LIKE '%" & strSearch & "%'", cn)
Dim ds As New DataSet
cn.Open()
da.Fill(ds)
cn.Close()
Return ds
End Function
'Search for the Item Status in database
Public Function GetItemStatus(ByVal strSQL As String) As DataSet
Dim da As New OleDbDataAdapter("SELECT * FROM Branch b INNER JOIN Item i ON b.BranchID = i.BranchID WHERE Title='" + strSQL + "'", cn)
Dim ds As New DataSet
cn.Open()
da.Fill(ds)
cn.Close()
Return ds
End Function
End Class
[u]
BusinessLogicLayer -- ReservationService.vb</u>
Imports System.Web.Services
<System.Web.Services.WebService(Namespace := "http://tempuri.org/ReservationBizLogic/ReservationService")> _
Public Class ReservationService
Inherits System.Web.Services.WebService
<WebMethod()> Public Function SearchKeyWords(ByVal strSearch As String) As DataSet
Dim dl As New ReservationData.ReservationData
Return (dl.SearchItemDetails(strSearch))
End Function
<WebMethod()> Public Function SearchItemStatus(ByVal strSQL As String) As DataSet
Dim dl As New ReservationData.ReservationData
Return (dl.GetItemStatus(strSQL))
End Function
<WebMethod()> Public Function GetAuthor(ByVal ds As DataSet) As String
Dim Author As String = ds.Tables(0).Rows(0)(10)
Return Author
End Function
<WebMethod()> Public Function GetPublisher(ByVal ds As DataSet) As String
Dim strPublisher As String = ds.Tables(0).Rows(0)(14)
Return strPublisher
End Function
<WebMethod()> Public Function GetTitle(ByVal ds As DataSet) As String
Dim strTitle As String = ds.Tables(0).Rows(0)(11)
Return strTitle
End Function
<WebMethod()> Public Function GetCallNo(ByVal ds As DataSet) As String
Dim strCallNo As String = ds.Tables(0).Rows(0)(21)
Return strCallNo
End Function
<WebMethod()> Public Function GetDes(ByVal ds As DataSet) As String
Dim strDes As String = ds.Tables(0).Rows(0)(18)
Return strDes
End Function
[u]
'Here is the problems I encounter</u>
<WebMethod()> Public Function GetDSCart(ByVal dv As DataView, ByVal strItemID As String) As DataTable
Dim ds As DataSet
Dim dr As DataRow
Dim Cart As DataTable = New DataTable
Dim arr1 As New ArrayList
Dim arr2 As New ArrayList
Dim arr3 As New ArrayList
For Each dr In Cart.Rows
arr1.Add(dv.Item)
arr2.Add(dv.Item)
arr3.Add(dv.Item)
Cart.Columns.Add(New DataColumn("BranchName"))
Cart.Columns.Add(New DataColumn("Title"))
Cart.Columns.Add(New DataColumn("Type"))
dr = Cart.NewRow()
dr(0) = arr1
dr(1) = arr2
dr(2) = arr3
Cart.Rows.Add(dr)
Next
Return Cart
End Function
End Class
[u]
PresentaionLayer</u>
1. I have a search engine for searching a book or other items.
[u]ReservationSearch.aspx.
vb</u>
'This call my businessLogic layer function
Dim bl As New ReservationBizLogic.ReservationService
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Session("dsSearch") = bl.SearchKeyWords(txtSearch.Text)
Response.Redirect("ReservationSearchResult.aspx")
End Sub
2. Here display a list of search results.
[u]ReservationSearchResult.aspx.
vb</u>
Public Class ReservationSearchResult
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dgSearchResult.DataSource = Session("dsSearch")
dgSearchResult.DataBind()
End Sub
Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
Response.Redirect("ReservationSearch.aspx")
End Sub
3. Here display the Item status.
[u]ReservationStatus.aspx.
vb</u>
Public Class ReservationStatus
Inherits System.Web.UI.Page
Dim bl As New ReservationBizLogic.ReservationService
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As DataSet = bl.SearchItemStatus(Request.QueryString("topic"))
lblTitleName.Text = bl.GetTitle(ds)
lblAuthorName.Text = bl.GetAuthor(ds)
lblPublisherName.Text = bl.GetPublisher(ds)
lblDescrip.Text = bl.GetDes(ds)
dgItemStatus.Columns(1).Visible = False
dgItemStatus.DataSource = ds
dgItemStatus.DataBind()
Session("ds") = ds
End Sub
Private Sub dgItemStatus_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles dgItemStatus.ItemCommand
Dim strItemIDCell As TableCell = e.Item.Cells(1)
Dim strItemID As String = strItemIDCell.Text
If e.CommandName = "Select" Then
Dim ds As DataSet = Session("ds")
Dim dv As DataView = New DataView(ds.Tables(0))
dv.RowFilter = "ItemID='" & strItemID & "'"
bl.GetDSCart(dv, strItemID)
End If
End Sub
Private Sub dgItemStatus_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgItemStatus.SelectedIndexChanged
Response.Redirect("ReservationCart.aspx")
End Sub
Private Sub btnBackResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBackResult.Click
Response.Redirect("ReservationSearchResult.aspx")
Session("ds") = ""
End Sub
End Class
4. Here display the Reservation Cart.
[u]ReservationCart.aspx.
vb</u>
Public Class ReservationCart
Inherits System.Web.UI.Page
Dim bl As New ReservationBizLogic.ReservationService
'Here is my problems
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'What should I do over here?
Dim dt As DataTable = bl.GetDSCart(???,???)
dgReCart.DataSource = dt
dgReCart.DataBind()
End Sub
Private Sub btnConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfirm.Click
'After the user confirms to reserve certain item, I need to save it into the database.
'How am I going to do that?
End Sub
End Class
Btw, I do not save the reservation cart details into the database when the user clicks on the Item he/she wants. As this will reduce the performance.
I save the reservation details only when the user confirms to reserve all items in the cart.
Hope to receive ur reply soon.
Hope that u can help me... Thanks u in advance...