0

I have written some code in the btnCheckStockStatus which prints out a list of stock items that need re-ordering based on whether the re-order level is greater than the current quantity, at the moment this code works successfully. I am now trying to write code so when i press the 'btnPrintStockStatus' its prints out what is in the btnCheckStockStatus, i tried to come up with some stuff but nothings really come close the the correct solution, any help or advice would be greatful!

Private Sub btnCheckStockStatus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckStockStatus.Click

        Dim increment As Integer = 0
        Dim quantity, reorderlevel As Integer
        Dim name As String

        MaxRows = KiwicyclesDataSet.Stock_Control.Rows.Count

        Dim reorderitems As String = ""

        For increment = 0 To MaxRows - 1

            quantity = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Quantity")
            reorderlevel = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Re-Order Level")
            name = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Model")

            If reorderlevel >= quantity Then
                reorderitems = reorderitems & name & vbCrLf
            Else
            End If
        Next

        MsgBox("The following items need to be restocked:" & vbCrLf & ReOrderItems)

    End Sub


    Private Sub btnPrintStockStatus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintStockStatus.Click
        PrintDocument1.Print()

    End Sub


    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage


        Dim increment As Integer = 0
        Dim quantity, reorderlevel As Integer
        Dim name As String

        MaxRows = KiwicyclesDataSet.Stock_Control.Rows.Count

        Dim reorderitems As String = ""
        For increment = 0 To MaxRows - 1

            quantity = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Quantity")
            reorderlevel = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Re-Order Level")
            name = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Model")

            If reorderlevel >= quantity Then
                reorderitems = reorderitems & name & vbCrLf
            Else
            End If
        Next






        Dim nameofpart
        Dim x, y As Integer
        Dim fontheight As Integer
        Dim index As Integer
        Dim myfont As New Font("Times New Roman", 12, FontStyle.Regular)
        fontheight = myfont.GetHeight(e.Graphics)

        x = 50
        y = 100
        nameofpart = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Model")
        e.Graphics.DrawString(nameofpart, myfont, Brushes.Black, x, y)
        y = y + fontheight

        e.Graphics.DrawString("", myfont, Brushes.Black, x, y)
        y = y + fontheight
        x = 100

        'For index = 0 to 
        '
        'e.Graphics.DrawString("", myfont, Brushes.Black, x, y)
        'y = y + fontheight
        'next index


    End Sub

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by __avd
0

Sorry, I'm not quite following the problem. My understanding from your description is that your have a problem with printing.

Suggestion : You could use CrystalReport or MicrosoftReport services.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.