ASKER
<asp:LinqDataSource ID="BidsLDS" runat="server"
ContextTypeName="lucidequipmentDataContext" EnableInsert="True"
EntityTypeName="" TableName="Bids" Where = "BuyerId == @currentUserId" >
<WhereParameters>
<asp:Parameter DbType=Guid name=currentUserId />
</WhereParameters>
<InsertParameters>
<asp:Parameter Name = "equipmentId" DefaultValue="@SelectedMasterId" />
<asp:Parameter Name = "BuyerId" DefaultValue="@buyerId" />
<asp:Parameter Name = "BidAmount" direction=inputoutput dbtype = decimal />
<asp:Parameter Name = "BidDate" DefaultValue= "@bidDate" />
</InsertParameters>
</asp:LinqDataSource>
ASKER
Imports System.Web.Security
Imports System.Web.UI.WebControls
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.DynamicData
Imports System.Web.Routing
Imports System.Web.UI.WebControls.Expressions
Imports System.Web.UI.WebControls.GridView
Partial Class BuyerPages_PlaceABid
Inherits System.Web.UI.Page
Dim currentUser As MembershipUser = Membership.GetUser()
Dim currentUserId As Guid = DirectCast(currentUser.ProviderUserKey, Guid)
Dim BuyerId As Guid = currentUserId
Protected Sub BidSelectionListGV_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles BidSelectionListGV.SelectedIndexChanged
ShowDetailsButton.Visible = True
PlaceBidsButton.Visible = True
ManageBidsButton.Visible = True
Dim rowIndex As Integer = BidSelectionListGV.SelectedIndex
Dim selectedMasterId As Integer = BidSelectionListGV.DataKeys(rowIndex).Value
ViewState("eqIndex") = selectedMasterId
End Sub
Protected Sub EqTypesLDS_Selecting(sender As Object, e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles EqTypesLDS.Selecting
Dim DetailsIndex As Integer = ViewState("eqIndex")
e.WhereParameters("equipment_master_id") = DetailsIndex
End Sub
Protected Sub PlaceBidsButton_Click(sender As Object, e As System.EventArgs) Handles PlaceBidsButton.Click
'turn on (make visible) the DetailsView to collect the bid
CollectBidDV.ChangeMode(DetailsViewMode.Insert)
CollectBidDV.Visible = True
End Sub
Protected Sub ManageBidsButton_Click(sender As Object, e As System.EventArgs) Handles ManageBidsButton.Click
'turn off the bid collection DV
CollectBidDV.Visible = False
'turn off the equipment details GV
EqDetailsGV.Visible = False
'turn off the bid success label
BidSuccessLabel.Visible = False
'turn on gridview showing bid list for current user
ManageBidsGV.Visible = True
End Sub
Protected Sub BidsLDS_Selecting(sender As Object, e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles BidsLDS.Selecting
e.WhereParameters("currentUserId") = currentUserId
End Sub
Protected Sub CollectBidDV_ItemInserting(sender As Object, e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles CollectBidDV.ItemInserting
'define equipmentId, currentUserId, BidDate and of course the newly collected bid amount
'then stuff them all into the Bids table
'first, the equipmentId comes from the viewstate collection
Dim EquipmentId As Integer = ViewState("eqIndex")
e.Values("EquipmentId") = ViewState("eqIndex")
'the BuyerId by our usual method
Dim BuyerId As Guid = currentUserId
e.Values("buyerId") = currentUserId
'and the datetime
e.Values("biddate") = DateTime.Now
Dim currentDate As DateTime = DateTime.Now
End Sub
Protected Sub BidsLDS_Inserted(sender As Object, e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles BidsLDS.Inserted
CollectBidDV.Visible = False
BidSuccessLabel.Visible = True
'now change the Status in the equipment_master table
Dim EquipmentId As Integer = ViewState("eqIndex")
Dim connectionString As String = ConfigurationManager.ConnectionStrings("lucidequipmentConnectionString").ConnectionString
Dim updateSql As String = "UPDATE equipment_master SET equipment_master.statusId='4' WHERE equipment_master.id = " & EquipmentId
Using myConnection As New SqlConnection(connectionString)
myConnection.Open()
Dim myCommand As New SqlCommand(updateSql, myConnection)
myCommand.Parameters.Add("@id", SqlDbType.Int).Value = EquipmentId
myCommand.ExecuteNonQuery()
myConnection.Close()
End Using
BidSelectionListGV.DataBind()
'send mail to seller
Session("keyId") = EquipmentId
'Dim myBidAmount As String = CollectBidDV.Rows(0).Cells(2).ToString()
'get currentuser
Dim currentUser As MembershipUser = Membership.GetUser()
Dim currentUserId As Guid = DirectCast(currentUser.ProviderUserKey, Guid)
Dim buyerId As Guid = currentUserId
' Dim bidid As Integer = CollectBidDV.SelectedValue
'LatestBidId.LatestBid(currentUserId)
'Dim bidId As Integer = Session.Item("BidId")
End Sub
Protected Sub ManageBidsLDS_Selecting(sender As Object, e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles ManageBidsLDS.Selecting
e.WhereParameters("currentUserId") = currentUserId
End Sub
Protected Sub ShowDetailsButton_Command(sender As Object, e As System.Web.UI.WebControls.CommandEventArgs) Handles ShowDetailsButton.Command
EqDetailsGV.Visible = True
End Sub
Protected Sub DetailValuesLDS_Selecting(sender As Object, e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles DetailValuesLDS.Selecting
e.WhereParameters("equipment_master_id") = ViewState("eqIndex")
End Sub
Protected Sub CollectBidDV_ItemInserted(sender As Object, e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles CollectBidDV.ItemInserted
Dim msgName As String = "bidsubmitted"
Dim bidamount As String = CType("bidamount", String)
' Dim thisRowID As Integer
'thisRowID = e.Command.Parameters("@value_rowid").Value
Dim bidid As Integer = CollectBidDV.SelectedValue
SendSystemMail.SendSysMail(msgName, bidid)
End Sub
End Class
ASKER
ASKER
Dim newbid As Bid
newbid = CType(e.Result, Bid)
Dim newbidId As Integer = newbid.BidId
ASKER
The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications
TRUSTED BY
<asp:SqlDataSource …
InsertCommand = “INSERT INTO [tblPayments] ([BillingName], [BillingAmount]) VALUES (@BillingName, @BillingAmount); Select @Payment_rowid=SCOPE_IDENT
OnInserted=”dtlPayment_Ite
…
</asp:SqlDataSource>
<asp:SqlDataSource …
InsertCommand = “INSERT INTO [yourTable] ([field1], [field2]) VALUES (@value1, @value2); Select @value_rowid=SCOPE_IDENTIT
OnInserted=”dtlPmt_ItemIns
…
</asp:SqlDataSource>