Expand|Select|Wrap|Line Numbers
- Dim po As New Purchase_Order
- Protected Sub submitponum_Click(ByVal sender As Object, ByVal e As EventArgs) Handles submitponum.Click
- If ponum.Text.ToString = "" Then
- ponum.BackColor = Drawing.Color.Red
- poerror.Text = "This Can't Be Blank"
- poerror.Visible = True
- Exit Sub
- End If
- Dim params(0) As SqlClient.SqlParameter
- params(0) = New SqlClient.SqlParameter()
- params(0).Value = ponum.Text
- params(0).ParameterName = "@ponum"
- Dim rd As SqlClient.SqlDataReader = Data.SqlHelper.ExecuteReader(ConnString, "dbo.ponum", params)
- While rd.Read
- If ponum.Text = rd.GetString(0) Then
- ponum.BackColor = Drawing.Color.Red
- poerror.Text = "P.O. Number Already Exist"
- poerror.Visible = True
- Exit Sub
- End If
- End While
- rd.Close()
- gen()
- 'Dim po As createrd = New createrd
- po.Number = ponumfinal.Text
- po.Vendor = vendorbox.SelectedValue
- po.Shipto = shiptobox.SelectedValue
- po.Shipping = 0.0
- po.Tax = 0.0
- End Sub
- Protected Sub addnew_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles addnew.Click
- If billtobox.Visible = False Then
- billtobox.SelectedValue = 9
- End If
- If projbox.Visible = True Then
- projtxtbox.Text = projbox.SelectedValue
- End If
- 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))
- '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))
- pogrid.DataSource = po.POLines
- pogrid.DataBind()
- End Sub
Below are the classes.
Expand|Select|Wrap|Line Numbers
- Public Class Purchase_Order
- Dim _polines As List(Of POLine) = New List(Of POLine)
- Dim _poNumber As String = String.Empty
- Dim _vendorid As Integer
- Dim _Shiptoid As Integer
- Dim _shipping As Decimal
- Dim _tax As Decimal
- Public Property Number() As String
- Get
- Return _poNumber
- End Get
- Set(ByVal value As String)
- _poNumber = value
- End Set
- End Property
- Public Property Vendor() As Integer
- Get
- Return _vendorid
- End Get
- Set(ByVal value As Integer)
- _vendorid = value
- End Set
- End Property
- Public Property Shipto() As Integer
- Get
- Return _Shiptoid
- End Get
- Set(ByVal value As Integer)
- _Shiptoid = value
- End Set
- End Property
- Public Property Tax() As Decimal
- Get
- Return _tax
- End Get
- Set(ByVal value As Decimal)
- _tax = value
- End Set
- End Property
- Public Property Shipping() As Decimal
- Get
- Return _Shipping
- End Get
- Set(ByVal value As Decimal)
- _Shipping = value
- End Set
- End Property
- Public Property POLines() As List(Of POLine)
- Get
- Return _polines
- End Get
- Set(ByVal value As List(Of POLine))
- _polines = value
- End Set
- End Property
- 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
- Dim newline As POLine = Me.AddPOLines
- newline.Quantity = Quantity
- newline.Billto = billto
- newline.Description = description
- newline.Type = type
- newline.project = project
- newline.UnitPrice = UnitPrice
- newline.Total = total
- Return newline
- End Function
- '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
- ' Dim updateln As POLine = Me.upPOLines
- ' Quantity = updateln.Quantity
- ' billto = updateln.Billto
- ' description = updateln.Description
- ' type = updateln.Type
- ' project = updateln.project
- ' UnitPrice = updateln.UnitPrice
- ' unittotal = updateln.Total
- ' Return updateln
- 'End Function
- Public Function AddPOLines() As POLine
- Dim newline As POLine = New POLine
- _polines.Add(newline)
- Return newline
- End Function
- 'Public Function upPOLines() As POLine
- ' Dim updateln As POLine = New POLine
- ' _polines.Add(updateln)
- ' Return updateln
- 'End Function
- End Class
- Public Class POLine
- Dim _quantity As Integer
- Dim _billto As Integer
- Dim _description As String
- Dim _type As String
- Dim _projectitem As Integer
- Dim _unitprice As Decimal
- Dim _total As Decimal
- Public Property Quantity() As Integer
- Get
- Return _quantity
- End Get
- Set(ByVal value As Integer)
- _quantity = value
- End Set
- End Property
- Public Property Billto() As Integer
- Get
- Return _billto
- End Get
- Set(ByVal value As Integer)
- _billto = value
- End Set
- End Property
- Public Property Description() As String
- Get
- Return _description
- End Get
- Set(ByVal value As String)
- _description = value
- End Set
- End Property
- Public Property Type() As String
- Get
- Return _type
- End Get
- Set(ByVal value As String)
- _type = value
- End Set
- End Property
- Public Property project() As Integer
- Get
- Return _projectitem
- End Get
- Set(ByVal value As Integer)
- _projectitem = value
- End Set
- End Property
- Public Property UnitPrice() As Decimal
- Get
- Return _unitprice
- End Get
- Set(ByVal value As Decimal)
- _unitprice = value
- End Set
- End Property
- Public Property Total() As Decimal
- Get
- Return _total
- End Get
- Set(ByVal value As Decimal)
- _total = value
- End Set
- End Property
- End Class