Hello everyone,
I'm a try and learn type of guy and developed a code for an invoicing program. What i want to learn is if this type of coding i ok for standarts . Eventually it works but i want to kno if it's suitable for an invoicing software.
The code is as follows :
MainSales is the main table of sales which holds info of general invoice information.
sales fk of main sales with cascade update and delete constraints which hold detail info like prodct name vs.
Can't wait to hear your opinions.
Thanks for taking time to read and review this post in advance.
Newbie
Sertaç from Turkiye...
I'm a try and learn type of guy and developed a code for an invoicing program. What i want to learn is if this type of coding i ok for standarts . Eventually it works but i want to kno if it's suitable for an invoicing software.
The code is as follows :
Code:
Public Class Form1
Dim productrow As DataTableDataSet.ProductRow
Dim mainsalesrow As DataTableDataSet.MainSalesRow
Dim salesrow As DataTableDataSet.SalesRow
Private recurrence As Integer = -1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.MainSalesTableAdapter.Fill(Me.DataTableDataSet.MainSales)
Me.ProductTableAdapter.Fill(Me.DataTableDataSet.Product)
Me.SalesTableAdapter.Fill(Me.DataTableDataSet.Sales)
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
Dim index As Integer = DataTableDataSet.Product.Rows.IndexOf(DataTableDataSet.Product.Select([String].Format("ProductName like '{0}%'", TextBox1.Text)).FirstOrDefault())
If index >= 0 Then
productrow = CType(DataTableDataSet.Product.Rows(index), DataTable_vs.DataTableDataSet.ProductRow)
LabelControl1.Text = productrow.ProductName
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'MessageBox.Show(salesrow.Quantity.ToString)
'If IsDBNull(salesrow.Quantity) Then
' salesrow.Quantity = 0
'End If
fillline()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
TableAdapterManager.UpdateAll(DataTableDataSet)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
'MainSalesBindingSource.AddNew()
mainsalesrow = DataTableDataSet.MainSales.NewMainSalesRow
mainsalesrow.total = 0
DataTableDataSet.MainSales.Rows.Add(mainsalesrow)
MainSalesBindingSource.MoveLast()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
TableAdapterManager.UpdateAll(DataTableDataSet)
MainSalesTableAdapter.Update(DataTableDataSet)
End Sub
Private Sub fillline()
For i As Integer = 0 To GridView1.RowCount - 1
Dim product As String = productrow.ProductName.ToString()
If product = GridView1.GetRowCellValue(i, colProduct).ToString Then
recurrence = i
End If
Next
If recurrence = -1 Then
salesrow = DataTableDataSet.Sales.NewSalesRow
Else
Dim index As Integer = SalesBindingSource.Find("Product", productrow.ProductName)
salesrow = CType(DataTableDataSet.Sales.Rows(index), DataTable_vs.DataTableDataSet.SalesRow)
End If
salesrow.Product = productrow.ProductName
If (salesrow.IsNull("Quantity")) <> Nothing Then
salesrow.Quantity = 1
Else
salesrow.Quantity = CDec(GridView1.GetFocusedRowCellValue(colQuantity))
End If
salesrow.Price = productrow.Price
salesrow.LineTotal = salesrow.Quantity * salesrow.Price
salesrow.Taxtotalı = ((salesrow.Quantity * salesrow.Price) * productrow.TaxRate) / 100
salesrow.GeneralTotal = salesrow.LineTotal + salesrow.Taxtotalı
salesrow.AnaId = mainsalesrow.Id
If recurrence = -1 Then
DataTableDataSet.Sales.Rows.Add(salesrow)
Else
recurrence = -1
End If
For i As Integer = 0 To GridView1.RowCount - 1
mainsalesrow.total = 0
mainsalesrow.total += CDec(GridView1.GetRowCellValue(i, colGeneralTotal))
Next
End Sub
Private Sub GridView1_CellValueChanged(sender As Object, e As Gridview1.CellValueChangedEventArgs) Handles GridView1.CellValueChanged
productrow.Price = CDec(GridView1.GetFocusedRowCellValue(colPrice))
fillline()
End Sub
End Class
sales fk of main sales with cascade update and delete constraints which hold detail info like prodct name vs.
Can't wait to hear your opinions.
Thanks for taking time to read and review this post in advance.
Newbie
Sertaç from Turkiye...