The Codes...,VB .Net & Sql -  SalesForm.vb.
 
 
 

       
  Return


SalesForm.vb


 

 The Codes ...
      SalesForm.vb
 
 
Public Class salesForm

Inherits System.Windows.Forms.Form

Dim SumColRow As Integer

Windows Form Designer generated code

 

' Load data

Private Sub salesForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Try

'Attempt to load the dataset.

Me.LoadDataSet()

Catch eLoad As System.Exception

'Add your error handling code here.

'Display error message, if any.

System.Windows.Forms.MessageBox.Show(eLoad.Message)

End Try

 

Me.salesdset_PositionChanged()

' ToolTip control, give information the following controls

Me.ToolTip1.SetToolTip(Me.btnFirst, "First")

Me.ToolTip1.SetToolTip(Me.btnPrevious, "Previous")

Me.ToolTip1.SetToolTip(Me.btnNext, "Next")

Me.ToolTip1.SetToolTip(Me.btnLast, "Last")

Me.ToolTip1.SetToolTip(Me.btnClose, "Close")

End Sub

Public Sub LoadDataSet()

'Create a new dataset to hold the records returned from the call to FillDataSet.

'A temporary dataset is used because filling the existing dataset would

'require the databindings to be rebound.

Dim objDataSetTemp As RBT_Accounting_Net.salesdset

objDataSetTemp = New RBT_Accounting_Net.salesdset

Try

'Attempt to fill the temporary dataset.

Me.FillDataSet(objDataSetTemp)

Catch eFillDataSet As System.Exception

'Add your error handling code here.

Throw eFillDataSet

End Try

Try

grdit_sales.DataSource = Nothing

'Empty the old records from the dataset.

salesdset1.Clear()

'Merge the records into the main dataset.

salesdset1.Merge(objDataSetTemp)

grdit_sales.SetDataBinding(salesdset1, "ord_sales.relation")

Catch eLoadMerge As System.Exception

'Add your error handling code here.

Throw eLoadMerge

End Try

End Sub

Public Sub FillDataSet(ByVal dataSet As RBT_Accounting_Net.salesdset)

'Turn off constraint checking before the dataset is filled.

'This allows the adapters to fill the dataset without concern

'for dependencies between the tables.

dataSet.EnforceConstraints = False

Try

'Open the connection.

Me.SqlConnection1.Open()

'Attempt to fill the dataset through the SqlDataAdapter1.

Me.SqlDataAdapter1.Fill(dataSet)

Me.SqlDataAdapter2.Fill(dataSet)

Catch fillException As System.Exception

'Add your error handling code here.

Throw fillException

Finally

'Turn constraint checking back on.

dataSet.EnforceConstraints = True

'Close the connection whether or not the exception was thrown.

Me.SqlConnection1.Close()

End Try

End Sub

Private Sub salesdset_PositionChanged()

Dim var_oldval As Integer = Val(Me.editoldval.Text)

Me.lblNavLocation.Text = (((Me.BindingContext(salesdset1, "ord_sales").Position + 1).ToString + " of ") _

+ Me.BindingContext(salesdset1, "ord_sales").Count.ToString)

' Format

Me.editoldval.Text = Format(var_oldval, "##0.00")

' Calculate the Total of the Extension itrm

SumGrid()

' Resize

Me.editdiscount.Width = Me.edittotal.Width

Me.editdiscount.Left = Me.edittotal.Left

' Navigation controls enebled(True or False

If Me.BindingContext(salesdset1, "ord_sales").Position + 1 = 1 Then

NavigationFP(False)

NavigationNL(True)

ElseIf Me.BindingContext(salesdset1, "ord_sales").Position + 1 = Me.BindingContext(salesdset1, "ord_sales").Count Then

NavigationFP(True)

NavigationNL(False)

Else

NavigationFP(True)

NavigationNL(True)

End If

Me.lblNavLocation.Focus()

End Sub

' Enabled the controls

Private Sub NavigationFP(ByVal bval As Boolean)

Me.btnFirst.Enabled = bval

Me.btnPrevious.Enabled = bval

End Sub

' Enabled the controls

Private Sub NavigationNL(ByVal bval As Boolean)

Me.btnNext.Enabled = bval

Me.btnLast.Enabled = bval

End Sub

' Calculate the Total of the Extension itrm

Private Sub SumGrid()

Dim I As Integer

Dim Sumcolrow1 As Integer = 0

For I = 0 To Me.grdit_sales.VisibleRowCount - 2

Sumcolrow1 = Sumcolrow1 + Val(grdit_sales.Item(I, 4))

Next I

Me.edittotal.Text = Format((Sumcolrow1), "##0.00")

Me.editGtotal.Text = Format((Sumcolrow1 - Val(Me.editdiscount.Text)), "##0.00")

Dim tdf As Integer = Sumcolrow1 * Val(Me.editval_ll.Text)

Me.editGtotalll.Text = Format((Sumcolrow1 * Val(Me.editval_ll.Text)), "##0.00")

Me.editnewval.Text = Format((Val(Me.editoldval.Text) + Val(Me.editGtotal.Text)), "##0.00")

End Sub

' Navigation

Private Sub btnFirst_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFirst.Click

Me.BindingContext(salesdset1, "ord_sales").Position = 0

Me.salesdset_PositionChanged()

End Sub

' Navigation

Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click

Me.BindingContext(salesdset1, "ord_sales").Position = (Me.salesdset1.Tables("ord_sales").Rows.Count - 1)

Me.salesdset_PositionChanged()

End Sub

' Navigation

Private Sub btnPrevious_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrevious.Click

Me.BindingContext(salesdset1, "ord_sales").Position = (Me.BindingContext(salesdset1, "ord_sales").Position - 1)

Me.salesdset_PositionChanged()

End Sub

' Navigation

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click

Me.BindingContext(salesdset1, "ord_sales").Position = (Me.BindingContext(salesdset1, "ord_sales").Position + 1)

Me.salesdset_PositionChanged()

End Sub

' Close the current Form

Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click

Application.Exit()

End Sub

Private Sub SetButtons(ByVal bVal As Boolean)

btnFirst.Enabled = bVal

btnPrevious.Enabled = bVal

btnNext.Enabled = bVal

btnLast.Enabled = bVal

btnClose.Enabled = bVal

End Sub

Private Sub editord_date_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles editord_date.TextChanged

Dim eddatex As DateTime

eddatex = Me.editord_date.Text

Me.editord_date.Text = eddatex.ToShortDateString

End Sub

 


 

  Return