-
Notifications
You must be signed in to change notification settings - Fork 1
/
TransactionList.vb
108 lines (92 loc) · 3.94 KB
/
TransactionList.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Imports MySql.Data.MySqlClient
Public Class TransactionList
Private Sub progress_bar()
ToolStripProgressBar1.PerformStep()
End Sub
Dim MysqlConn As MySqlConnection
Dim COMMAND As MySqlCommand
Private Sub LoadTransactionBtn_Click(sender As Object, e As EventArgs) Handles loadTransactionBtn.Click
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString = "server=localhost; userid=root; password=''; database=wareit"
Try
MysqlConn.Open()
Dim Query As String
Query = "SELECT * FROM wareit.transactions"
COMMAND = New MySqlCommand(Query, MysqlConn)
Dim dr = COMMAND.ExecuteReader(CommandBehavior.CloseConnection)
transactionListView.Items.Clear()
Dim x As ListViewItem
Do While dr.Read = True
x = New ListViewItem(dr("transaction_no").ToString)
x.SubItems.Add(dr("transaction_date"))
x.SubItems.Add(dr("transaction_client_no"))
x.SubItems.Add(dr("transaction_po_num"))
x.SubItems.Add(dr("transaction_notes"))
x.SubItems.Add(dr("transaction_product_id"))
x.SubItems.Add(dr("transaction_qty"))
x.SubItems.Add(dr("transaction_price"))
x.SubItems.Add(dr("quantity_type"))
transactionListView.Items.Add(x)
Loop
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
progress_bar()
End Try
End Sub
Private Sub LoadChartBtn_Click(sender As Object, e As EventArgs) Handles loadChartBtn.Click
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString = "server=localhost; userid=root; password=''; database=wareit"
Dim READER As MySqlDataReader
Try
MysqlConn.Open()
Dim Query As String
Query = "SELECT * FROM wareit.products"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
While READER.Read
Chart1.Series("PRODUCT_VS_SOLD").Points.AddXY(READER.GetString("product_name"), READER.GetInt16("product_sold"))
End While
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
TransactionAdd.ShowDialog()
End Sub
Private Sub RefreshTransactionBtn_Click(sender As Object, e As EventArgs) Handles refreshTransactionBtn.Click
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString = "server=localhost; userid=root; password=''; database=wareit"
Try
MysqlConn.Open()
Dim Query As String
Query = "SELECT * FROM wareit.transactions"
COMMAND = New MySqlCommand(Query, MysqlConn)
Dim dr = COMMAND.ExecuteReader(CommandBehavior.CloseConnection)
transactionListView.Items.Clear()
Dim x As ListViewItem
Do While dr.Read = True
x = New ListViewItem(dr("transaction_no").ToString)
x.SubItems.Add(dr("transaction_date"))
x.SubItems.Add(dr("transaction_client_no"))
x.SubItems.Add(dr("transaction_po_num"))
x.SubItems.Add(dr("transaction_notes"))
x.SubItems.Add(dr("transaction_product_id"))
x.SubItems.Add(dr("transaction_qty"))
x.SubItems.Add(dr("transaction_price"))
x.SubItems.Add(dr("quantity_type"))
transactionListView.Items.Add(x)
Loop
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
progress_bar()
End Try
End Sub
End Class