473,395 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Objects properties overwriting itself in vb.net web app

2
I have 2 objects, 1 that is essentially a parent object and another that is a child object. In the parent object (Purchase_order) very little visible data is stored but in the child object (Poline) a little more data is stored. There should only be one object for the parent object but multiple ones for the child one. The issue im having is when different data is entered in the child object it overwrites the data entered before it. My terms might be a bit off as im still learning but any help would be greatly appreciated.
Expand|Select|Wrap|Line Numbers
  1.     Dim po As New Purchase_Order
  2.     Protected Sub submitponum_Click(ByVal sender As Object, ByVal e As EventArgs) Handles submitponum.Click
  3.  
  4.         If ponum.Text.ToString = "" Then
  5.             ponum.BackColor = Drawing.Color.Red
  6.             poerror.Text = "This Can't Be Blank"
  7.             poerror.Visible = True
  8.             Exit Sub
  9.         End If
  10.  
  11.         Dim params(0) As SqlClient.SqlParameter
  12.         params(0) = New SqlClient.SqlParameter()
  13.         params(0).Value = ponum.Text
  14.         params(0).ParameterName = "@ponum"
  15.         Dim rd As SqlClient.SqlDataReader = Data.SqlHelper.ExecuteReader(ConnString, "dbo.ponum", params)
  16.         While rd.Read
  17.             If ponum.Text = rd.GetString(0) Then
  18.                 ponum.BackColor = Drawing.Color.Red
  19.                 poerror.Text = "P.O. Number Already Exist"
  20.                 poerror.Visible = True
  21.                 Exit Sub
  22.             End If
  23.         End While
  24.         rd.Close()
  25.         gen()
  26.         'Dim po As createrd = New createrd
  27.  
  28.  
  29.         po.Number = ponumfinal.Text
  30.         po.Vendor = vendorbox.SelectedValue
  31.         po.Shipto = shiptobox.SelectedValue
  32.         po.Shipping = 0.0
  33.         po.Tax = 0.0
  34.  
  35.     End Sub
  36.  
  37.     Protected Sub addnew_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles addnew.Click
  38.  
  39.         If billtobox.Visible = False Then
  40.             billtobox.SelectedValue = 9
  41.         End If
  42.  
  43.         If projbox.Visible = True Then
  44.             projtxtbox.Text = projbox.SelectedValue
  45.         End If
  46.  
  47.         po.AddPOLines(qtybox.Text, billtobox.SelectedValue, descbox.Text, typebox.SelectedItem.Text, projtxtbox.Text, Convert.ToDecimal(unitpricebox.Text), Convert.ToDecimal(qtybox.Text) * Convert.ToDecimal(unitpricebox.Text))
  48.         'po.PoLine.AddPoLineRow(ponumfinal.Text, descbox.Text, qtybox.Text, typebox.SelectedItem.Text, projtxtbox.Text, Convert.ToDecimal(unitpricebox.Text), billtobox.SelectedValue, qtybox.Text * Convert.ToDecimal(unitpricebox.Text))
  49.  
  50.         pogrid.DataSource = po.POLines
  51.  
  52.         pogrid.DataBind()
  53.     End Sub
  54.  

Below are the classes.
Expand|Select|Wrap|Line Numbers
  1. Public Class Purchase_Order
  2.     Dim _polines As List(Of POLine) = New List(Of POLine)
  3.     Dim _poNumber As String = String.Empty
  4.     Dim _vendorid As Integer
  5.     Dim _Shiptoid As Integer
  6.     Dim _shipping As Decimal
  7.     Dim _tax As Decimal
  8.  
  9.     Public Property Number() As String
  10.         Get
  11.             Return _poNumber
  12.  
  13.         End Get
  14.         Set(ByVal value As String)
  15.             _poNumber = value
  16.         End Set
  17.     End Property
  18.  
  19.     Public Property Vendor() As Integer
  20.         Get
  21.             Return _vendorid
  22.  
  23.         End Get
  24.         Set(ByVal value As Integer)
  25.             _vendorid = value
  26.         End Set
  27.     End Property
  28.  
  29.     Public Property Shipto() As Integer
  30.         Get
  31.             Return _Shiptoid
  32.  
  33.         End Get
  34.         Set(ByVal value As Integer)
  35.             _Shiptoid = value
  36.         End Set
  37.     End Property
  38.     Public Property Tax() As Decimal
  39.         Get
  40.             Return _tax
  41.  
  42.         End Get
  43.         Set(ByVal value As Decimal)
  44.             _tax = value
  45.         End Set
  46.     End Property
  47.  
  48.     Public Property Shipping() As Decimal
  49.         Get
  50.             Return _Shipping
  51.  
  52.         End Get
  53.         Set(ByVal value As Decimal)
  54.             _Shipping = value
  55.         End Set
  56.     End Property
  57.  
  58.     Public Property POLines() As List(Of POLine)
  59.         Get
  60.             Return _polines
  61.         End Get
  62.         Set(ByVal value As List(Of POLine))
  63.             _polines = value
  64.         End Set
  65.     End Property
  66.  
  67.     Public Function AddPOLines(ByVal Quantity As Integer, ByVal billto As Integer, ByVal description As String, ByVal type As String, ByVal project As Integer, ByVal UnitPrice As Double, ByVal total As Double) As POLine
  68.         Dim newline As POLine = Me.AddPOLines
  69.  
  70.         newline.Quantity = Quantity
  71.         newline.Billto = billto
  72.         newline.Description = description
  73.         newline.Type = type
  74.         newline.project = project
  75.         newline.UnitPrice = UnitPrice
  76.         newline.Total = total
  77.         Return newline
  78.     End Function
  79.     'Public Function upPOLines(ByVal Quantity As Integer, ByVal billto As Integer, ByVal description As String, ByVal type As String, ByVal project As Integer, ByVal UnitPrice As Double, ByVal unittotal As Double) As POLine
  80.     '    Dim updateln As POLine = Me.upPOLines
  81.  
  82.     '    Quantity = updateln.Quantity
  83.     '    billto = updateln.Billto
  84.     '    description = updateln.Description
  85.     '    type = updateln.Type
  86.     '    project = updateln.project
  87.     '    UnitPrice = updateln.UnitPrice
  88.     '    unittotal = updateln.Total
  89.     '    Return updateln
  90.     'End Function
  91.  
  92.     Public Function AddPOLines() As POLine
  93.         Dim newline As POLine = New POLine
  94.         _polines.Add(newline)
  95.         Return newline
  96.     End Function
  97.  
  98.     'Public Function upPOLines() As POLine
  99.     '    Dim updateln As POLine = New POLine
  100.     '    _polines.Add(updateln)
  101.     '    Return updateln
  102.     'End Function
  103.  
  104. End Class
  105.  
  106.  
  107. Public Class POLine
  108.     Dim _quantity As Integer
  109.     Dim _billto As Integer
  110.     Dim _description As String
  111.     Dim _type As String
  112.     Dim _projectitem As Integer
  113.     Dim _unitprice As Decimal
  114.     Dim _total As Decimal
  115.  
  116.  
  117.     Public Property Quantity() As Integer
  118.         Get
  119.             Return _quantity
  120.         End Get
  121.         Set(ByVal value As Integer)
  122.             _quantity = value
  123.         End Set
  124.     End Property
  125.  
  126.     Public Property Billto() As Integer
  127.         Get
  128.             Return _billto
  129.         End Get
  130.         Set(ByVal value As Integer)
  131.             _billto = value
  132.         End Set
  133.     End Property
  134.  
  135.  
  136.  
  137.     Public Property Description() As String
  138.         Get
  139.             Return _description
  140.         End Get
  141.         Set(ByVal value As String)
  142.             _description = value
  143.         End Set
  144.     End Property
  145.  
  146.     Public Property Type() As String
  147.         Get
  148.             Return _type
  149.         End Get
  150.         Set(ByVal value As String)
  151.             _type = value
  152.         End Set
  153.     End Property
  154.     Public Property project() As Integer
  155.         Get
  156.             Return _projectitem
  157.         End Get
  158.         Set(ByVal value As Integer)
  159.             _projectitem = value
  160.         End Set
  161.     End Property
  162.  
  163.  
  164.     Public Property UnitPrice() As Decimal
  165.         Get
  166.             Return _unitprice
  167.         End Get
  168.         Set(ByVal value As Decimal)
  169.             _unitprice = value
  170.         End Set
  171.     End Property
  172.  
  173.     Public Property Total() As Decimal
  174.         Get
  175.             Return _total
  176.         End Get
  177.         Set(ByVal value As Decimal)
  178.             _total = value
  179.         End Set
  180.     End Property
  181.  
  182. End Class
  183.  
Thanks again!
Jun 27 '08 #1
0 909

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: relaxedrob | last post by:
Howdy All! I am still getting my head around a few base concepts. Any comments or criticisms on the below definitions would be most welcome! A function is an object. JavaScript objects have...
8
by: Thomas Mlynarczyk | last post by:
Hi! If A is an object, then "B = A;" will just assign a reference. Isn't there a simple way to create an actual copy of A and assign that to B? Greetings, Thomas
3
by: Sam Kong | last post by:
Hi group, I want to have some advice about immutable objects. I made a constructor. function Point(x, y) { this.x = x; this.y = y; }
1
by: weston | last post by:
So, the following apparently works as a method of grafting a method onto an object (using the squarefree JS shell): obj = { x: 1, inc: null } result obj.inc = function () { this.x++ } result...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.