Button clicks on refresh, doubling the calculation...

  • Thread starter Thread starter Trint Smith
  • Start date Start date
T

Trint Smith

There is no call to Button7 in the load_page either. I even put "If Not
IsPostBack Then" in the Button7 function and nothing works.
Any help is appreciated.
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Textbox1.Text = ""
'Button7.Enabled = False
Panel4.Visible = False
Label34.Visible = False
Textbox21.Visible = False
Textbox1.Visible = False
Button5.Visible = False
Button7.Visible = False
Image3.Visible = False
Panel9.Visible = False
Label42.Visible = False
Label43.Visible = False
Label44.Visible = False
Textbox21.Visible = False
Textbox22.Visible = False
Button4.Visible = False
Image4.Visible = False

Panel5.Visible = False
Label38.Visible = False
Label39.Visible = False
Label40.Visible = False
Label41.Visible = False
Label45.Visible = False

TextBox2.Visible = False
Button8.Visible = False

Label47.Visible = False

Image5.Visible = False



MakeItemNumberPublic = Request.Params("itemnumber")
MakeItemNumberTrimString =
Trim(MakeItemNumberPublic).Replace("""", "")
Label6.Text = MakeItemNumberTrimString

Dim stringLength As Integer
stringLength = Len(UserID)
If stringLength < 4 Then
stringLength = Len(UserID)
Label5.Visible = False
Button2.Visible = False
ElseIf stringLength > 3 Then
Label5.Text = UserID
Label5.Visible = True
Button2.Visible = True
End If

Dim objListItem As ListItem
Dim strID As String

Try
'*************test
strSQL = "SELECT item_itemnumber, " & _
" item_sellrnumber, " & _
" item_itemtitle, " & _
" item_itemdescription, " & _
" item_photosaddress, " & _
" item_beginningbiddatetime, " & _
" item_endingbiddatetime, " & _
" item_timezone, " & _
" item_itemstartbidprice, " & _
" item_itemshipgcost, " & _
"
item_itemshipmentandpaymentdetails, " & _
" item_itembuyitnowyn, " & _
" item_itemcurrentbidprice, " & _
" item_itembidhistory, " & _
"
item_itemcurrentorpurchasedbidder " & _
"FROM TBL_Items WHERE item_itemnumber =
'" & MakeItemNumberTrimString & "'"
'*************end test item_itembidhistory

cnSQL = New SqlConnection("Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep")
cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()

If drSQL.Read() Then
' Populate form with the data
MakeItemNumberPublic =
drSQL.Item("item_itemnumber").ToString()

sellrNumber = drSQL.Item("item_sellrnumber").ToString()

itemTitle = drSQL.Item("item_itemtitle").ToString()
itemDescription =
drSQL.Item("item_itemdescription").ToString()
photosAddress =
drSQL.Item("item_photosaddress").ToString()
beginningBiddatetime =
drSQL.Item("item_beginningbiddatetime").ToString()
endingBiddatetime =
drSQL.Item("item_endingbiddatetime").ToString()
timeZone = drSQL.Item("item_timezone").ToString()
itemstartBidprice =
drSQL.Item("item_itemstartbidprice").ToString()
itemShipgcost =
drSQL.Item("item_itemshipgcost").ToString()
itemShipmentandpaymentdetails =
drSQL.Item("item_itemshipmentandpaymentdetails").ToString()
itemBuyitnowyn =
drSQL.Item("item_itembuyitnowyn").ToString()
itemCurrentbidprice =
drSQL.Item("item_itemcurrentbidprice").ToString()
itembidHistory =
drSQL.Item("item_itembidhistory").ToString()
itemCurrentorpurchasedbidder =
drSQL.Item("item_itemcurrentorpurchasedbidder").ToString()
End If

If Len(photosAddress) <= 1 Then
imageFound = 32
End If
'photosAddress
'System.IO.DirectoryInfo.GetFiles

'D:\Inetpub\wwwroot\WebApplication1\SellerAccounts\b4e81177-35dd-44d7-b9
96-8e285103f11a\3.jpg
If Not imageFound = 32 Then
'ExtendedPhotosAddress =
"D:/Inetpub/wwwroot/WebApplication1/" & photosAddress & "/"
'E:\web\tribidzcom0\htdocs
ExtendedPhotosAddress = "http://www.tribidz.com/" &
photosAddress & "/"
Dim ExtendedPhotosAddress2 As String =
"E:\web\tribidzcom0\htdocs\" & photosAddress & "/"
' Make a reference to a directory.

'START HERE!!!!!

'D:\Inetpub\wwwroot\WebApplication1\SellerAccounts\b4e81177-35dd-44d7-b9
96-8e285103f11a\3.jpg
Dim di As New DirectoryInfo(ExtendedPhotosAddress2)
' Get a reference to each file in that directory.

File.Delete("E:\web\tribidzcom0\htdocs\ReferenceImages\filesindir.txt")

Dim sw As StreamWriter
sw = New
StreamWriter("E:\web\tribidzcom0\htdocs\ReferenceImages\filesindir.txt",
True)

fiArr = di.GetFiles()
' Display the names of the files.
'fileName = fri.Name
'Label13.Text = fri.Name
For Each fri In fiArr
' Console.WriteLine(fri.Name)
sw.WriteLine(fri)
Next fri ' ExtendedPhotosAddress & fiArr
sw.Close()
Dim sr As StreamReader
sr = New
StreamReader("E:\web\tribidzcom0\htdocs\ReferenceImages\filesindir.txt",
True)
filesndir = sr.ReadLine()
sr.Close()

'Dim sq As StreamWriter
'sq = New StreamWriter("D:\pathtest.txt", True)
'sq.WriteLine(ExtendedPhotosAddress & filesndir)
'sq.Close()
'If Len(photosAddress) <= 1 Then
Image2.ImageUrl = ExtendedPhotosAddress & "/" &
filesndir

Image5.Visible = True

'Dim MyBitmap As New Bitmap(Server.MapPath(".") &
"\MyPicture.jpg")
Dim MyBitmap As New Bitmap(Server.MapPath(".") & "/" &
photosAddress & "/" & filesndir)
Dim bmp As Bitmap = New Bitmap(MyBitmap)
'Dim heightInt As String
'Me.Label1.Text = MyBitmap.Height.ToString &
MyBitmap.Width.ToString
'Image5.Height = New
System.Web.UI.WebControls.Unit(MyBitmap.Height)
'Image5.Width = New
System.Web.UI.WebControls.Unit(MyBitmap.Width)
'Image5.ImageUrl = ExtendedPhotosAddress & "/" &
filesndir

Image5.Height = New
System.Web.UI.WebControls.Unit(bmp.Height)
Image5.Width = New
System.Web.UI.WebControls.Unit(bmp.Width)
Image5.ImageUrl = ExtendedPhotosAddress & "/" &
filesndir
MyBitmap.Dispose()
bmp.Dispose()
Else
Image2.ImageUrl =
"http://www.tribidz.com/Images/noimage.jpg"
'End If
End If

Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter personal
data.")

'Dim mw As StreamWriter
'mw = New StreamWriter("D:\testfile1.txt", True)
'mw.WriteLine(ex)
'mw.Close()
End Try
' Populate Items View Page with the data
' Item number is already on screen but stored here as public
MakeItemNumberPublic
Label4.Text = itemTitle
Label17.Text = itemDescription
' do something to show photo photosAddress
'Start here tomorrow
beginningBiddatetime =
drSQL.Item("item_beginningbiddatetime").ToString()
endingBiddatetime =
drSQL.Item("item_endingbiddatetime").ToString()
itemstartBidprice =
drSQL.Item("item_itemstartbidprice").ToString()
'itemShipgcost = drSQL.Item("item_itemshipgcost").ToString()
Label30.Text = endingBiddatetime
Label29.Text = timeZone
Label32.Text = itemShipmentandpaymentdetails
'itemBuyitnowyn = drSQL.Item("item_itembuyitnowyn").ToString()
If Len(itemCurrentbidprice) <= 0 Then
Label18.Text = "0"
Else
Label18.Text = itemCurrentbidprice
End If

Dim result As Integer
result = String.Compare(itemBuyitnowyn, "y")
If result = 0 Then
Image3.Visible = True
End If
'This will need to come from somewhere else when 'live bid'
If Len(itemCurrentorpurchasedbidder) < 2 Then
Label28.Text = "0"
Else
Label28.Text = itemCurrentorpurchasedbidder
End If
If Len(itemCurrentbidprice) < 1 Then
Label26.Text = "0 Bidders"
Else
Label26.Text = itembidHistory & " Bidders"
End If
'*****************
Dim SecondDate As Date = endingBiddatetime
Dim FirstDate As Date = Now
Dim secs As Long = DateDiff(DateInterval.Second, Now,
SecondDate)

Dim ts As TimeSpan = TimeSpan.FromSeconds(secs)

'This function determins the end of the bid
Dim dtStartBidDateTime As DateTime =
DateTime.Parse(beginningBiddatetime)
Dim dt2EndBidDateTime As DateTime =
DateTime.Parse(endingBiddatetime)
Dim message1 As String = "Your time format is incorrect please
try again."
Dim message2 As String = "your bid is over."
Dim message3 As String = "your bid needs to be set for future
time running."
Dim NowDate As Date = Now
If Now > dt2EndBidDateTime Then
Label23.Visible = True
Label25.Text = "This Bid is over"
Else
'********This is the magic number
Label25.Text = (ts.Days.ToString() & "d:" &
ts.Hours.ToString() & "h:" & ts.Minutes.ToString() & "m:" &
ts.Seconds.ToString() & "s")
End If
File.Delete("E:\web\tribidzcom0\htdocs\countdown.txt")

Dim CountDownFile As String
CountDownFile = ("days=" & ts.Days.ToString() & "&hours=" &
ts.Hours.ToString() & "&minutes=" & ts.Minutes.ToString() & "&seconds="
& ts.Seconds.ToString())
Dim fw As StreamWriter
fw = New StreamWriter("E:\web\tribidzcom0\htdocs\countdown.txt",
True)
fw.WriteLine(CountDownFile)
fw.Close()

cnSQL.Close()
'****************************
Dim PasswordA As String = Nothing
' Build Select statement to query product information from the
products
' table

Try
'*************test
strSQL = "SELECT sellr_buserid, " & _
" sellr_bsstate, " & _
" sellr_bscountry, " & _
" sellr_ratesellerpositive, " & _
" sellr_ratesellermiddle, " & _
" sellr_ratesellernegative " & _
"FROM TBL_RegSeller " & _
"WHERE sellr_number = '" &
sellrNumber & "' "

'*************end test sellr_bscountry

cnSQL = New SqlConnection("Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep")
cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()

If drSQL.Read() Then
' Populate form with the data ratesellerPositive =
drSQL.Item("sellr_ratesellerpositive").ToString()
buserID = drSQL.Item("sellr_buserid").ToString()
bsState = drSQL.Item("sellr_bsstate").ToString()
bsCountry = drSQL.Item("sellr_bscountry").ToString()
ratesellerPositive =
drSQL.Item("sellr_ratesellerpositive").ToString()
ratesellerMiddle =
drSQL.Item("sellr_ratesellermiddle").ToString()
ratesellerNegative =
drSQL.Item("sellr_ratesellernegative").ToString()
End If

Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter personal
data.")

'Dim tw As StreamWriter
'tw = New StreamWriter("D:\testfile1.txt", True)
'tw.WriteLine(ex)
'tw.Close()
Finally
cnSQL.Close()
End Try
Label8.Text = buserID
Label27.Text = bsState
Label31.Text = bsCountry
If Len(ratesellerPositive) < 1 Then
Label19.Text = "none"
Else
Label19.Text = ratesellerPositive
End If

If Len(ratesellerMiddle) < 1 Then
Label20.Text = "none"
Else
Label20.Text = ratesellerMiddle
End If

If Len(ratesellerNegative) < 1 Then
Label21.Text = "none"
Else
Label21.Text = ratesellerNegative
End If
'***************************
'create a DataTable
'For DataGrid1
If Not IsPostBack Then
DataGrid1.DataSource = CreateDataSource()
DataGrid1.DataBind()

'This loads the highest bidders avitar
Try
'*************test
strSQL = "SELECT buyr_fname, " & _
" buyr_lname, " & _
" buyr_cphone, " & _
" buyr_baddress1, " & _
" buyr_baddress2, " & _
" buyr_bcity, " & _
" buyr_bstate, " & _
" buyr_bzip, " & _
" buyr_bstateprov, " & _
" buyr_bcountry, " & _
" buyr_buserid, " & _
" buyr_bpassword, " & _
" buyr_bemail, " & _
" buyr_bavatar, " & _
" buyr_bsaddress1, " & _
" buyr_bsaddress2, " & _
" buyr_bscity, " & _
" buyr_bsstate, " & _
" buyr_bszip, " & _
" buyr_bsstateprov, " & _
" buyr_bscountry, " & _
" buyr_bccname, " & _
" buyr_bcctype, " & _
" buyr_bccnumber, " & _
" buyr_bccvnumber, " & _
" buyr_bccxmonth, " & _
" buyr_bccxyear " & _
"FROM TBL_RegBuyer " & _
"WHERE buyr_buserid = '" &
itemCurrentorpurchasedbidder & "' "
'*************end test

cnSQL = New SqlConnection("Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep")
cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()

If drSQL.Read() Then
' Populate form with the data
Dim Avitar As String
Avitar = drSQL.Item("buyr_bavatar").ToString()
If Len(Avitar) >= 1 Then
Dim avitarTest As String
Image4.Visible = True
Image4.ImageUrl =
"http://www.tribidz.com/Images/Avatar/" & Trim(Avitar) & ".gif"
avitarTest =
"http://www.tribidz.com/Images/Avatar/" & Trim(Avitar) & ".gif"

'Dim mw As StreamWriter
'mw = New StreamWriter("D:\AvitarTest.txt",
True)
'mw.WriteLine(avitarTest)
'mw.Close()
End If

End If

Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter personal
data.")


Finally
cnSQL.Close()
End Try
End If
'Button7.Enabled = True
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button7.Click
'Button7.Visible = False
If Not IsPostBack Then
'Do nothing
Else

'get current bid and bidder
Try
'*************test
strSQL = "SELECT item_itemcurrentbidprice, " & _
" item_itembidhistory, " & _
"
item_itemcurrentorpurchasedbidder " & _
"FROM TBL_Items WHERE
item_itemnumber = '" & MakeItemNumberTrimString & "'"
'*************end test item_itembidhistory

cnSQL = New SqlConnection("Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep")
cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()

If drSQL.Read() Then
' Manage data with strings
itemCurrentbidprice =
drSQL.Item("item_itemcurrentbidprice").ToString()
itembidHistory =
drSQL.Item("item_itembidhistory").ToString()
itemCurrentorpurchasedbidder =
drSQL.Item("item_itemcurrentorpurchasedbidder").ToString()

'Calculate Price
IntCurrentBidPrice = Val(itemCurrentbidprice)

'I'm not sure about this 'If'
'If IntCurrentBidPrice > 1 Then
IntCalculate1 = Val(Textbox1.Text)
IntCalculate2 = IntCurrentBidPrice + IntCalculate1

itemCurrentbidprice = Str(IntCalculate2)
tempbidHistoryInt = Val(itembidHistory)
itembidHistory = Str(tempbidHistoryInt + 1)
itemCurrentorpurchasedbidder = UserID
'End If
End If

Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter personal
data.")
Finally
cnSQL.Close()
End Try

' Populate Items View Page with the data
'end get current bid and bidder
Try
' Build update statement to update product table with
data
' on form.
strSQL = "UPDATE TBL_Items SET" & _
" item_itemnumber = " & PrepareStr(Label6.Text)
& _
" ,item_itemcurrentbidprice = " &
PrepareStr(itemCurrentbidprice) & _
" ,item_itembidhistory = " &
PrepareStr(itembidHistory) & _
" ,item_itemcurrentorpurchasedbidder = " &
PrepareStr(itemCurrentorpurchasedbidder) & _
"FROM TBL_Items " & _
"WHERE item_itemnumber = '" & Label6.Text &
"'"

cnSQL = New SqlConnection("Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep")
cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)
intRowsAffected = cmSQL.ExecuteNonQuery()

Catch ex As SqlException

Finally
cnSQL.Close()
End Try

'***Insert Bid History************
conn.ConnectionString = "Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep"
' "Password=angiep;Persist Security Info=True;User
ID=trint;Initial Catalog=tribidz;Data Source=TRINITY"
With cmd
.Connection = conn
End With
Try
conn.Open()
Dim itemNumber As String
itemNumber = Label6.Text
'get UserID
Dim itemBidPrice As String = itemCurrentbidprice
Dim datetimeposted As String
datetimeposted = System.DateTime.Now

cmd.CommandText = "INSERT
[DB_48952].[dbo].[TBL_ItemsBidHistory]" & _
"(itembidhist_itemnumber, itembidhist_UserID ,
itembidhist_BidAmount, itembidhist_BidDateTime)" & _
" VALUES('" & itemNumber & "'," & _
"'" & UserID & "'," & _
"'" & itemBidPrice & "'," & _
"'" & datetimeposted & "')"
cmd.ExecuteNonQuery()

Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter personal
data.")

'Dim fw As StreamWriter
'fw = New StreamWriter("D:\testfile1.txt", True)
'fw.WriteLine(ex)
'fw.Close()
'*********
Finally
File.Delete("E:\web\tribidzcom0\htdocs\" & Label6.Text &
".txt")
Dim sw As StreamWriter
Dim highBid As String
sw = New StreamWriter("E:\web\tribidzcom0\htdocs\" &
Label6.Text & ".txt", True)
highBid = "day=" & Trim(itemCurrentbidprice) & "&month="
& Trim(itemCurrentorpurchasedbidder)
sw.WriteLine(highBid)
sw.Close()
conn.Close()
End Try
'****end Insert Bid History

'This loads the highest bidders avitar
Try

'*************test
strSQL = "SELECT buyr_fname, " & _
" buyr_lname, " & _
" buyr_cphone, " & _
" buyr_baddress1, " & _
" buyr_baddress2, " & _
" buyr_bcity, " & _
" buyr_bstate, " & _
" buyr_bzip, " & _
" buyr_bstateprov, " & _
" buyr_bcountry, " & _
" buyr_buserid, " & _
" buyr_bpassword, " & _
" buyr_bemail, " & _
" buyr_bavatar, " & _
" buyr_bsaddress1, " & _
" buyr_bsaddress2, " & _
" buyr_bscity, " & _
" buyr_bsstate, " & _
" buyr_bszip, " & _
" buyr_bsstateprov, " & _
" buyr_bscountry, " & _
" buyr_bccname, " & _
" buyr_bcctype, " & _
" buyr_bccnumber, " & _
" buyr_bccvnumber, " & _
" buyr_bccxmonth, " & _
" buyr_bccxyear " & _
"FROM TBL_RegBuyer " & _
"WHERE buyr_buserid = '" &
itemCurrentorpurchasedbidder & "' "
'*************end test

cnSQL = New SqlConnection("Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep")
cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()

If drSQL.Read() Then
' Populate form with the data
Dim Avitar As String
Avitar = drSQL.Item("buyr_bavatar").ToString()
If Len(Avitar) >= 1 Then
Dim avitarTest As String
Image4.Visible = True
Image4.ImageUrl =
"http://www.tribidz.com/Images/Avatar/" & Trim(Avitar) & ".gif"
avitarTest =
"http://www.tribidz.com/Images/Avatar/" & Trim(Avitar) & ".gif"

'Dim mw As StreamWriter
'mw = New StreamWriter("D:\AvitarTest.txt",
True)
'mw.WriteLine(avitarTest)
'mw.Close()
End If

End If

Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter personal
data.")


Finally
cnSQL.Close()
End Try

Label18.Text = itemCurrentbidprice & ".00"
Label28.Text = itemCurrentorpurchasedbidder
Label26.Text = itembidHistory
Panel4.Visible = True
Label34.Visible = True
Textbox1.Visible = True
Button5.Visible = True
Button7.Visible = True
Button3.Visible = False
'For DataGrid1
DataGrid1.DataSource = CreateDataSource()
DataGrid1.DataBind()

'Where CHECK for End of Bid starts
Dim noString As String = "n"

strSQL = "SELECT item_itemnumber, " & _
" item_sellrnumber, " & _
" item_itemtitle, " & _
" item_itemdescription, " &
_
" item_photosaddress, " & _
"
item_beginningbiddatetime, " & _
" item_endingbiddatetime, "
& _
" item_itemstartbidprice, "
& _
" item_itemshipgcost, " & _
"
item_itemshipmentandpaymentdetails, " & _
" item_itembuyitnowyn, " &
_
" item_itemcurrentbidprice,
" & _
" item_itemsoldprice, " & _
" item_itembidhistory, " &
_
"
item_itemcurrentorpurchasedbidder " & _
"FROM TBL_Items WHERE
item_itembuyitnowyn = '" & noString & "' "

cnSQL = New SqlConnection("Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep")
cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()

'while starts here
r = -1
t = -1
Do While drSQL.Read()
' Populate form with the data
MakeItemNumberPublic =
drSQL.Item("item_itemnumber").ToString()
beginningBiddatetime =
drSQL.Item("item_beginningbiddatetime").ToString()
endingBiddatetime =
drSQL.Item("item_endingbiddatetime").ToString()
itemBuyitnowyn =
drSQL.Item("item_itembuyitnowyn").ToString()
itemCurrentbidprice =
drSQL.Item("item_itemcurrentbidprice").ToString()
itemSoldprice =
drSQL.Item("item_itemsoldprice").ToString()
'FindItemsSoldAndStillOpen2()
Dim dtStartBidDateTime As DateTime =
DateTime.Parse(beginningBiddatetime)
Dim dt2EndBidDateTime As DateTime =
DateTime.Parse(endingBiddatetime)
Dim NowDate As Date = Now
'*****This is where to do the UPDATE AND SKIP
If Now > dt2EndBidDateTime Then

Dim itsldlen As Integer
itsldlen = Len(itemSoldprice)
If itsldlen < 1 Then
Dim soldresult As Integer
soldresult = String.Compare(itemBuyitnowyn, "n")
If soldresult = 0 Then
'add to array
FirstQuery.Add(MakeItemNumberPublic)
r += 1
t += 1
End If
End If
End If
Loop
cnSQL.Close()
'FindItemsSoldAndStillOpen3()
Dim fstQuery As String

'While t > 0
For r = 0 To t
'Do another search for Need to Show sold
Dim itemNumberSold As String = Nothing
itemNumberSold = FirstQuery(r)
'itemNumberSold = "b4e81177-35dd-44d7-b996-8e285103f11a"

strSQL = "SELECT item_itemcurrentbidprice, " & _
"item_itemcurrentorpurchasedbidder " & _
"FROM TBL_Items " & _
"WHERE item_itemnumber = '" &
itemNumberSold & "' "

'strSQL = "SELECT TBL_Items item_itemcurrentbidprice, "
& _
'
"item_itemcurrentorpurchasedbidder " & _
' "WHERE item_itemnumber = '"
& itemNumberSold & "' "
cnSQL = New SqlConnection("Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep")

Try
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
'drSQL = cmSQL.ExecuteReader()
drSQL = cmSQL.ExecuteReader()
Do While drSQL.Read()
itemCurrentbidprice =
drSQL.Item("item_itemcurrentbidprice").ToString()
Loop
Catch ex As SqlException
'Dim fw As StreamWriter
'fw = New StreamWriter("D:\itemsupdatedtosold2.txt",
True)
'fw.WriteLine(ex)
'fw.Close()
Finally
cnSQL.Close()
End Try
'End Need to show
If Len(itemCurrentbidprice) > 0 Then
strSQL = "UPDATE TBL_Items SET" & _
" item_itemsoldprice = " &
PrepareStr(itemCurrentbidprice) & _
"FROM TBL_Items " & _
"WHERE item_itemnumber = '" &
itemNumberSold & "'"
cnSQL = New SqlConnection("Data
Source=mssql04;Initial Catalog=DB_48952;User
ID=tribidzcom0;Password=angiep")
Try
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
cmSQL.ExecuteNonQuery()
Catch ex As SqlException

Finally
itemnumber3 = Trim(itemNumberSold)
cnSQL.Close()
End Try
End If
'Next r
'Where Start check end of bid and do
strSQL = "SELECT item_itemnumber, " & _
" item_sellrnumber, " & _
" item_itemtitle, " & _
" item_itemdescription, " & _
" item_photosaddress, " & _
" item_beginningbiddatetime, "
& _
" item_endingbiddatetime, " &
_
" item_itemstartbidprice, " &
_
" item_itemshipgcost, " & _
"
item_itemshipmentandpaymentdetails, " & _
" item_itembuyitnowyn, " & _
" item_itemcurrentbidprice, "
& _
" item_itemsoldprice, " & _
" item_itembidhistory, " & _
"
item_itemcurrentorpurchasedbidder " & _
"FROM TBL_Items " & _
"WHERE item_itemnumber = '"
& itemnumber3 & "' "

cnSQL = New SqlConnection("Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep")
Try
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
'drSQL = cmSQL.ExecuteReader()
drSQL = cmSQL.ExecuteReader()
If drSQL.Read() Then
MakeItemNumberPublic =
drSQL.Item("item_itemnumber").ToString()
sellrNumber =
drSQL.Item("item_sellrnumber").ToString()
itemTitle =
drSQL.Item("item_itemtitle").ToString()
itemDescription =
drSQL.Item("item_itemdescription").ToString()
photosAddress =
drSQL.Item("item_photosaddress").ToString()
beginningBiddatetime =
drSQL.Item("item_beginningbiddatetime").ToString()
endingBiddatetime =
drSQL.Item("item_endingbiddatetime").ToString()
itemstartBidprice =
drSQL.Item("item_itemstartbidprice").ToString()
itemShipgcost =
drSQL.Item("item_itemshipgcost").ToString()
itemShipmentandpaymentdetails =
drSQL.Item("item_itemshipmentandpaymentdetails").ToString()
itemBuyitnowyn =
drSQL.Item("item_itembuyitnowyn").ToString()
itemCurrentbidprice =
drSQL.Item("item_itemcurrentbidprice").ToString()
itemSoldprice =
drSQL.Item("item_itemsoldprice").ToString()
itembidHistory =
drSQL.Item("item_itembidhistory").ToString()
itemCurrentorpurchasedbidder =
drSQL.Item("item_itemcurrentorpurchasedbidder").ToString()
End If

If Len(itemCurrentbidprice) > 0 Then
'put on screen info of bid over here
End If

Catch ex As SqlException
'Dim fw As StreamWriter
'fw = New StreamWriter("D:\itemsupdatedtosold2.txt",
True)
'fw.WriteLine(ex)
'fw.Close()
Finally
cnSQL.Close()
End Try
'where End end of bid check and do
If Len(itemSoldprice) > 0 Then
'Item Sold information
strSQL = "SELECT item_itemnumber, " & _
" item_sellrnumber, " & _
" item_itemtitle, " & _
" item_itemdescription, " & _
" item_photosaddress, " & _
" item_beginningbiddatetime, "
& _
" item_endingbiddatetime, " &
_
" item_itemstartbidprice, " &
_
" item_itemshipgcost, " & _
"
item_itemshipmentandpaymentdetails, " & _
" item_itembuyitnowyn, " & _
" item_itemcurrentbidprice, "
& _
" item_itemsoldprice, " & _
" item_itembidhistory, " & _
"
item_itemcurrentorpurchasedbidder " & _
"FROM TBL_Items " & _
"WHERE item_itemnumber = '"
& MakeItemNumberPublic & "' "
cnSQL = New SqlConnection("Data
Source=mssql04;Initial Catalog=DB_48952;User
ID=tribidzcom0;Password=angiep")
Try
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
'drSQL = cmSQL.ExecuteReader()
drSQL = cmSQL.ExecuteReader()
If drSQL.Read() Then
MakeItemNumberPublic =
drSQL.Item("item_itemnumber").ToString()
sellrNumber =
drSQL.Item("item_sellrnumber").ToString()
itemTitle =
drSQL.Item("item_itemtitle").ToString()
itemDescription =
drSQL.Item("item_itemdescription").ToString()
photosAddress =
drSQL.Item("item_photosaddress").ToString()
beginningBiddatetime =
drSQL.Item("item_beginningbiddatetime").ToString()
endingBiddatetime =
drSQL.Item("item_endingbiddatetime").ToString()
itemstartBidprice =
drSQL.Item("item_itemstartbidprice").ToString()
itemShipgcost =
drSQL.Item("item_itemshipgcost").ToString()
itemShipmentandpaymentdetails =
drSQL.Item("item_itemshipmentandpaymentdetails").ToString()
itemBuyitnowyn =
drSQL.Item("item_itembuyitnowyn").ToString()
itemCurrentbidprice =
drSQL.Item("item_itemcurrentbidprice").ToString()
itemSoldprice =
drSQL.Item("item_itemsoldprice").ToString()
itembidHistory =
drSQL.Item("item_itembidhistory").ToString()
itemCurrentorpurchasedbidder =
drSQL.Item("item_itemcurrentorpurchasedbidder").ToString()
'End Item Sold information
End If
Catch ex As SqlException
'Dim fw As StreamWriter
'fw = New
StreamWriter("D:\itemsupdatedtosold2.txt", True)
'fw.WriteLine(ex)
'fw.Close()
Finally
cnSQL.Close()
End Try
'Do email and transaction here:
Try
'*************test '(sellr_number
strSQL = "SELECT sellr_number, " & _
" sellr_fname, " & _
" sellr_lname, " & _
" sellr_cphone, " & _
" sellr_baddress1, " &
_
" sellr_baddress2, " &
_
" sellr_bcity, " & _
" sellr_bstate, " & _
" sellr_bzip, " & _
" sellr_bstateprov, "
& _
" sellr_bcountry, " &
_
" sellr_buserid, " & _
" sellr_bpassword, " &
_
" sellr_bemail, " & _
" sellr_bavatar, " & _
" sellr_bsaddress1, "
& _
" sellr_bsaddress2, "
& _
" sellr_bscity, " & _
" sellr_bsstate, " & _
" sellr_bszip, " & _
" sellr_bsstateprov, "
& _
" sellr_bscountry, " &
_
" sellr_bccname, " & _
" sellr_bcctype, " & _
" sellr_bccnumber, " &
_
" sellr_bccvnumber, "
& _
" sellr_bccxmonth, " &
_
" sellr_bccxyear " & _
"FROM TBL_RegSeller " & _
"WHERE sellr_buserid =
'" & Label8.Text & "' "
'*************end test

cnSQL = New SqlConnection("Data
Source=mssql04;Initial Catalog=DB_48952;User
ID=tribidzcom0;Password=angiep")
cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()
'Seller Information
If drSQL.Read() Then
' Populate strings with the data
slrIDnumber =
drSQL.Item("sellr_number").ToString()
slrFirstName =
drSQL.Item("sellr_fname").ToString()
slrLastName =
drSQL.Item("sellr_lname").ToString()
slrMainPhone =
drSQL.Item("sellr_cphone").ToString()
slrAddressLine1 =
drSQL.Item("sellr_baddress1").ToString()
slrAddressLine2 =
drSQL.Item("sellr_baddress2").ToString()
slrCity =
drSQL.Item("sellr_bcity").ToString()
slrState =
drSQL.Item("sellr_bstate").ToString()
slrZip = drSQL.Item("sellr_bzip").ToString()
slrStateProvidence =
drSQL.Item("sellr_bstateprov").ToString()
slrCountry =
drSQL.Item("sellr_bcountry").ToString()
slrUserID =
drSQL.Item("sellr_buserid").ToString()
slrEmail =
drSQL.Item("sellr_bemail").ToString()
'CHARGE HERE We should be able to charge
from this
slrCCname =
drSQL.Item("sellr_bccname").ToString()
slrCCtype =
drSQL.Item("sellr_bcctype").ToString()
slrCCnumber =
drSQL.Item("sellr_bccnumber").ToString()
slrCCvnumber =
drSQL.Item("sellr_bccvnumber").ToString()
slrCCxmonth =
drSQL.Item("sellr_bccxmonth").ToString()
slrCCxyear =
drSQL.Item("sellr_bccxyear").ToString()
'End Seller Information
End If
Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter
personal data.")
'Dim fw As StreamWriter
'fw = New StreamWriter("D:\testfile1.txt", True)
'fw.WriteLine(ex)
'fw.Close()
End Try
'Buyer Information
Try
'*************test
strSQL = "SELECT buyr_number, " & _
" buyr_fname, " & _
" buyr_lname, " & _
" buyr_cphone, " & _
" buyr_baddress1, " &
_
" buyr_baddress2, " &
_
" buyr_bcity, " & _
" buyr_bstate, " & _
" buyr_bzip, " & _
" buyr_bstateprov, " &
_
" buyr_bcountry, " & _
" buyr_buserid, " & _
" buyr_bpassword, " &
_
" buyr_bemail, " & _
" buyr_bavatar, " & _
" buyr_bsaddress1, " &
_
" buyr_bsaddress2, " &
_
" buyr_bscity, " & _
" buyr_bsstate, " & _
" buyr_bszip, " & _
" buyr_bsstateprov, "
& _
" buyr_bscountry, " &
_
" buyr_bccname, " & _
" buyr_bcctype, " & _
" buyr_bccnumber, " &
_
" buyr_bccvnumber, " &
_
" buyr_bccxmonth, " &
_
" buyr_bccxyear " & _
"FROM TBL_RegBuyer " & _
"WHERE buyr_buserid = '"
& itemCurrentorpurchasedbidder & "' "
'*************end test
cnSQL = New SqlConnection("Data
Source=mssql04;Initial Catalog=DB_48952;User
ID=tribidzcom0;Password=angiep")
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()
If drSQL.Read() Then
' Populate strings with the data
byrIDnumber =
drSQL.Item("buyr_number").ToString()
byrFirstName =
drSQL.Item("buyr_fname").ToString()
byrLastName =
drSQL.Item("buyr_lname").ToString()
byrMainPhone =
drSQL.Item("buyr_cphone").ToString()
byrAddressLine1 =
drSQL.Item("buyr_baddress1").ToString()
byrAddressLine2 =
drSQL.Item("buyr_baddress2").ToString()
byrCity =
drSQL.Item("buyr_bcity").ToString()
byrState =
drSQL.Item("buyr_bstate").ToString()
byrZip = drSQL.Item("buyr_bzip").ToString()
byrStateProvidence =
drSQL.Item("buyr_bstateprov").ToString()
byrCountry =
drSQL.Item("buyr_bcountry").ToString()
byrUserID =
drSQL.Item("buyr_buserid").ToString()
byrEmail =
drSQL.Item("buyr_bemail").ToString()
End If

Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter
personal data.")
'Dim fw As StreamWriter
'fw = New StreamWriter("D:\testfile1.txt", True)
'fw.WriteLine(ex)
'fw.Close()
End Try
'End Buyer Information
'***********************
'Start Insert to Item Sold Table
Dim AddPercent As Double
Dim AddPercent2 As Double
Dim StringAdd As String

AddPercent = Val(itemSoldprice)
AddPercent2 = AddPercent * 0.1
StringAdd = Str(AddPercent2) 'StringAdd goes into
charge row

conn.ConnectionString = "Data Source=mssql04;Initial
Catalog=DB_48952;User ID=tribidzcom0;Password=angiep"

With cmd
.Connection = conn
End With
Try
chargedatetimeposted = System.DateTime.Now
conn.Open()

cmd.CommandText = "INSERT
[DB_48952].[dbo].[TBL_ItemSold]" & _
"(ItemSold_number, ItemSold_slrid,
ItemSold_byrid, " & _
"ItemSold_chargedatetime,
ItemSold_typeofcharge, " & _
"ItemSold_percentcharge,
ItemSold_soldforprice, " & _
"ItemSold_tribidzcharge)" & _
" VALUES('" & MakeItemNumberPublic & "'," &
_
"'" & slrUserID & "'," & _
"'" & byrIDnumber & "'," & _
"'" & chargedatetimeposted & "'," & _
"'" & typeofCharge & "'," & _
"'" & WhatPercentDoWeCharge & "'," & _
"'" & itemSoldprice & "'," & _
"'" & StringAdd & "')"
cmd.ExecuteNonQuery()

Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter
personal data.")

Dim fw As StreamWriter
fw = New StreamWriter("D:\testfile1.txt", True)
fw.WriteLine(ex)
fw.Close()
'*********
Finally
conn.Close()
End Try
'End Insert to Item Sold Table

'end transaction
Label13.Visible = False
Label18.Visible = False
Image3.Visible = False
Panel4.Visible = False
Label34.Visible = False
Textbox1.Visible = False
Button5.Visible = False
Button7.Visible = False
Button3.Visible = False
Label35.Visible = False
Label25.Visible = False
Label14.Visible = False
Label30.Visible = False
Label36.Visible = False
Label29.Visible = False
Label23.Visible = False
Label28.Visible = False
Image4.Visible = False
Label16.Visible = False
Label31.Visible = False
Label27.Visible = False
'if this item matches any that are sold!
Dim result1 As Integer
result1 = String.Compare(MakeItemNumberPublic,
Label6.Text)
If result1 = 0 Then
Panel5.Visible = True
Label38.Visible = True
Label39.Visible = True
Label40.Text = itemCurrentorpurchasedbidder
Label40.Visible = True
Label41.Visible = True
Label45.Text = itemSoldprice
Label45.Visible = True
End If
'end if item matches any that are sold!
'message to tribidz
Dim mailMessage As System.Web.Mail.MailMessage = New
System.Web.Mail.MailMessage
mailMessage.From = "(e-mail address removed)"
mailMessage.To = "(e-mail address removed),
(e-mail address removed)"
mailMessage.Subject = "Item " & itemTitle & " was
sold!"
mailMessage.BodyFormat =
System.Web.Mail.MailFormat.Html
mailMessage.Body = "This is the Item# " &
MakeItemNumberPublic & _
". Buyer by email:" & byrEmail & "." & Chr(13) &
"Phone number at " & _
byrMainPhone & "." & Chr(13) & StringAdd & " or 10%
of total sale of" & _
itemSoldprice & "was charged at the moment of sale,
which was at " & _
chargedatetimeposted
System.Web.Mail.SmtpMail.SmtpServer = "localhost"
System.Web.Mail.SmtpMail.Send(mailMessage)
'Label1.Text = "Mail Sent"
'message to seller
'Dim mailMessage As System.Web.Mail.MailMessage =
New System.Web.Mail.MailMessage
mailMessage.From = "(e-mail address removed)"
mailMessage.To = slrEmail
mailMessage.Subject = "Item " & itemTitle & " was
sold!"
mailMessage.BodyFormat =
System.Web.Mail.MailFormat.Html
mailMessage.Body = "Item# " & MakeItemNumberPublic &
_
". You may contact the buyer by email:" & byrEmail &
"." & Chr(13) & "Or by phone number at " & _
byrMainPhone & "." & Chr(13) & StringAdd & " or 10%
of total sale of" & _
itemSoldprice & "was charged to your account at the
moment of sale, which was at " & _
chargedatetimeposted & Chr(13) & Chr(13) & "If you
have any questions, feel free to email us at " & _
"(e-mail address removed)" & "Thank you once again
for joining tribidz.com"
System.Web.Mail.SmtpMail.SmtpServer = "localhost"
System.Web.Mail.SmtpMail.Send(mailMessage)
'Label1.Text = "Mail Sent"
'message to buyer
'Dim mailMessage As System.Web.Mail.MailMessage =
New System.Web.Mail.MailMessage
mailMessage.From = "(e-mail address removed)"
mailMessage.To = byrEmail
mailMessage.Subject = "You are the winning bidder
for " & itemTitle
mailMessage.BodyFormat =
System.Web.Mail.MailFormat.Html
mailMessage.Body = "Item# " & MakeItemNumberPublic &
_
". You may contact the seller by email:" & slrEmail
& "." & Chr(13) & "Or by phone number at " & _
slrMainPhone & "." & Chr(13) & "Your purchase was
for $" & itemSoldprice & _
" which was at " & chargedatetimeposted & Chr(13) &
Chr(13) & "If you have any questions, feel free to email us at " & _
"(e-mail address removed)" & Chr(13) & "Thank you
once again for joining tribidz.com"
System.Web.Mail.SmtpMail.SmtpServer = "localhost"
System.Web.Mail.SmtpMail.Send(mailMessage)
'Label1.Text = "Mail Sent"
End If
'Where CHECK for End of Bid ends
Next r
End If
End Sub

It's kinda long.
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
Back
Top