Showing posts with label Source Code Samples. Show all posts
Showing posts with label Source Code Samples. Show all posts

Vb.net Source Code example

Inventory Management System in VB.NET
With Source Code


Here is the sample code for Inventory Management System


Vb.net Source Code

  Public Class ledgers

    Private Sub ledgers_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If My.Computer.Screen.WorkingArea.Width <= 1024 Then
            Me.Font = New Font(Me.Font.Name, 8, FontStyle.Regular)
        End If
        LoadLedgerList()
        LoadGroups(FilterGroup)
        FilterGroup.Items.Add("*All")

    End Sub
    Sub LoadLedgerList(Optional ByVal FStr As String = "")
        With LedgerList.ColumnHeadersDefaultCellStyle
            .Alignment = DataGridViewContentAlignment.MiddleCenter
            .BackColor = Color.DarkRed
            .ForeColor = Color.Gold
            .Font = New Font(.Font.FontFamily, .Font.Size, .Font.Style Or FontStyle.Bold, GraphicsUnit.Point)
        End With

        Dim Dbf As New ADODB.Recordset
        Dim sqlstr As String = ""
        If FilterGroup.Text.Length = 0 Or FilterGroup.Text = "*All" Then
            sqlstr = "Select * from ledgerdbf"
        Else
            sqlstr = "Select * from ledgerdbf where ledgertype='" & FilterGroup.Text & "'"

        End If
        If FStr.Length > 0 Then
            sqlstr = "Select * from ledgerdbf where sname LIKE '%" & TxtSearchLedger.Text & "%'"
        End If
        Dbf.Open(sqlstr, Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
        If Dbf.RecordCount > 0 Then
            LedgerList.RowCount = Dbf.RecordCount
            Dbf.MoveFirst()
            For i As Integer = 0 To Dbf.RecordCount - 1
                With LedgerList
                    .Item("tsno", i).Value = i + 1
                    .Item("tname", i).Value = Dbf.Fields("sname").Value
                    .Item("tgroup", i).Value = Dbf.Fields("ledgertype").Value
                    .Item("taddress", i).Value = Dbf.Fields("street").Value
                    .Item("tcity", i).Value = Dbf.Fields("city").Value
                    .Item("tphone", i).Value = Dbf.Fields("Phone").Value
                    If Dbf.Fields("Ldebit").Value > 0 Then
                        .Item("topbal", i).Value = FormatNumber(Dbf.Fields("Ldebit").Value, 2).ToString & " Dr"
                    Else
                        .Item("topbal", i).Value = FormatNumber(Dbf.Fields("Lcredit").Value, 2).ToString & " Cr"
                    End If
                    .Item("tcurbal", i).Value = GetCurrentBalanceValue(Dbf.Fields("sname").Value).ToString
                End With
                Dbf.MoveNext()
            Next
        Else
            LedgerList.RowCount = 0
        End If
        Dbf.Close()
    End Sub
    Private Sub BtnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNew.Click
        Dim k As New LedgerCreate
        k.ShowDialog()
        k = Nothing
        LoadLedgerList()
    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        If LedgerList.SelectedRows.Count > 0 Then
            'If LedgerList.Item("tname", LedgerList.CurrentRow.Index).Value.ToString = DefCashAccount Then
            'Exit Sub
            'End If
            Dim k As New LedgerCreate(LedgerList.Item("tname", LedgerList.CurrentRow.Index).Value.ToString)
            k.ShowDialog()
            LoadLedgerList()
            k = Nothing
        Else
            MsgBox("Please select the Ledger Row from The List       ")
        End If
    End Sub

    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClose.Click
        Me.Dispose()
    End Sub

    Private Sub UserButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserButton2.Click
        If LedgerList.SelectedRows.Count = 0 Then
            Exit Sub
        End If
        If LedgerList.Item("tname", LedgerList.CurrentRow.Index).Value.ToString = DefCashAccount Then
            Exit Sub
        End If
        If IsLedgerDeleteble(LedgerList.Item("tname", LedgerList.CurrentRow.Index).Value.ToString) = False Or IsLedgerIsActive(LedgerList.Item("tname", LedgerList.CurrentRow.Index).Value.ToString) = True Then
            MsgBox("The Selected Ledger Is not Possible to Delete While Tranascation are Still There ", MsgBoxStyle.Critical)
        Else
            If MsgBox("DO You want to Delete the Selected Ledger (Y/N)?             ", MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2) = MsgBoxResult.Yes Then
                Dim Dbf As New ADODB.Recordset
                Dbf.Open("delete * from ledgerdbf where sname='" & LedgerList.Item("tname", LedgerList.CurrentRow.Index).Value.ToString & "'", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
                Dbf.Open("delete * from ledgerbook where ledgername='" & LedgerList.Item("tname", LedgerList.CurrentRow.Index).Value.ToString & "' and transcode = 0", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
                LoadLedgerList()
            End If
        End If
    End Sub
    Private Sub FilterGroup_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FilterGroup.SelectedIndexChanged
        LoadLedgerList()
    End Sub
    Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
        If LedgerList.SelectedRows.Count = 0 Then
            Exit Sub
        End If
        Dim AlterLedgerFrm As New LedgerReportFrom(LedgerList.Item("tname", LedgerList.CurrentRow.Index).Value.ToString)
        My.Application.DoEvents()
        AlterLedgerFrm.SuspendLayout()
        AlterLedgerFrm.MdiParent = MainForm
        AlterLedgerFrm.Dock = DockStyle.Fill
        AlterLedgerFrm.Show()
        AlterLedgerFrm.WindowState = FormWindowState.Maximized
        AlterLedgerFrm.BringToFront()
        AlterLedgerFrm.ResumeLayout()
    End Sub


    Private Sub LedgerList_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles LedgerList.CellDoubleClick
        If LedgerList.SelectedRows.Count > 0 Then
            If MsgBox("Do you want to Modify  ?", MsgBoxStyle.YesNo + MsgBoxStyle.Information) = MsgBoxResult.Yes Then
                Dim k As New LedgerCreate(LedgerList.Item("tname", LedgerList.CurrentRow.Index).Value.ToString)
                k.ShowDialog()
                LoadLedgerList()
                k = Nothing
            End If
        Else
            MsgBox("Please select the Ledger Row from The List       ")
        End If
    End Sub

    Private Sub TxtSearchLedger_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtSearchLedger.TextChanged
        LoadLedgerList(TxtSearchLedger.Text)

    End Sub

    Private Sub btnReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReport.Click
        Me.Cursor = Cursors.WaitCursor
        My.Application.DoEvents()
        ShowLedgerAccounts.SuspendLayout()
        ShowLedgerAccounts.MdiParent = MainForm
        ShowLedgerAccounts.Dock = DockStyle.Fill
        ShowLedgerAccounts.Show()
        ShowLedgerAccounts.WindowState = FormWindowState.Maximized
        ShowLedgerAccounts.BringToFront()
        ShowLedgerAccounts.ResumeLayout()
        Me.Cursor = Cursors.Arrow
    End Sub
End Class

For POS System in VB.NET Source Code

: Please Contact : 
Sureshjyothijv@gmail.com