COM 350 Project 3
Signed-off-by: Amrit Panesar <apanesar-77260@student.coleman.edu>
This commit is contained in:
1 parent
1fa1ffad2a
commit
8c4ceb511d
4 files changed
+55
No files matched your search
@@ -16,11 +16,14 @@
|
|||||||
|
|
||||||
Imports System.Data.SqlClient
|
Imports System.Data.SqlClient
|
||||||
Imports System.Configuration
|
Imports System.Configuration
|
||||||
|
Imports System.Collections.Generic
|
||||||
|
|
||||||
|
|
||||||
Namespace VBWinFormDataGridView.DataGridViewPaging
|
Namespace VBWinFormDataGridView.DataGridViewPaging
|
||||||
|
|
||||||
Public Class MainForm
|
Public Class MainForm
|
||||||
|
Implements IOrderInformationRetriever
|
||||||
|
|
||||||
Private PageSize As Integer = 30
|
Private PageSize As Integer = 30
|
||||||
Private CurrentPageIndex As Integer = 1
|
Private CurrentPageIndex As Integer = 1
|
||||||
Private TotalPage As Integer
|
Private TotalPage As Integer
|
||||||
@@ -28,6 +31,7 @@ Namespace VBWinFormDataGridView.DataGridViewPaging
|
|||||||
Private conn As SqlConnection
|
Private conn As SqlConnection
|
||||||
Private adapter As SqlDataAdapter
|
Private adapter As SqlDataAdapter
|
||||||
Private command As SqlCommand
|
Private command As SqlCommand
|
||||||
|
Private dtable As DataTable
|
||||||
|
|
||||||
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||||
Me.conn = New SqlConnection(connstr)
|
Me.conn = New SqlConnection(connstr)
|
||||||
@@ -95,6 +99,7 @@ Namespace VBWinFormDataGridView.DataGridViewPaging
|
|||||||
Dim view As New DataView(dt)
|
Dim view As New DataView(dt)
|
||||||
view.Sort = "CustomerID"
|
view.Sort = "CustomerID"
|
||||||
Dim dtout As DataTable = view.ToTable()
|
Dim dtout As DataTable = view.ToTable()
|
||||||
|
Me.dtable = dtout
|
||||||
Return dtout
|
Return dtout
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@@ -131,6 +136,45 @@ Namespace VBWinFormDataGridView.DataGridViewPaging
|
|||||||
Me.GetTotalPageCount()
|
Me.GetTotalPageCount()
|
||||||
Me.dataGridView1.DataSource = GetPageData(Me.CurrentPageIndex)
|
Me.dataGridView1.DataSource = GetPageData(Me.CurrentPageIndex)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Public Function GetOrderInformationAmountTotal() As List(Of OrderInformation) Implements IOrderInformationRetriever.GetOrderInformationAmountTotal
|
||||||
|
Dim dt As DataTable = New DataTable()
|
||||||
|
command.Parameters.Clear()
|
||||||
|
command.CommandType = CommandType.Text
|
||||||
|
command.CommandText = _
|
||||||
|
"SELECT Orders.OrderID, Customers.CompanyName, SUM([Order Details].UnitPrice * [Order Details].Quantity) as Aprice" _
|
||||||
|
& "FROM [Orders]" _
|
||||||
|
& "JOIN [Customers] ON Customers.CustomerID = Orders.CustomerID" _
|
||||||
|
& "JOIN [Order Details] ON [Order Details].OrderID = Orders.OrderID" _
|
||||||
|
& "WHERE Orders.CustomerID = (SELECT TOP 1 CustomerID" _
|
||||||
|
& "FROM [Northwind].dbo.Orders" _
|
||||||
|
& "GROUP BY CustomerID" _
|
||||||
|
& "ORDER BY COUNT(*) DESC)" _
|
||||||
|
& "GROUP BY Customers.CompanyName, Orders.OrderID" _
|
||||||
|
& "ORDER BY Orders.OrderID DESC"
|
||||||
|
|
||||||
|
Try
|
||||||
|
conn.Open()
|
||||||
|
Me.adapter.SelectCommand = command
|
||||||
|
Me.adapter.Fill(dt)
|
||||||
|
Catch ex As Exception
|
||||||
|
MessageBox.Show(ex.Message)
|
||||||
|
Finally
|
||||||
|
conn.Close()
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Dim drlist As New List(Of DataRow)
|
||||||
|
For Each row As DataRow In dt.Rows
|
||||||
|
drlist.Add(CType(row, DataRow))
|
||||||
|
Next
|
||||||
|
Return drlist.Select(Function(rowin As DataRow)
|
||||||
|
Return New OrderInformation With {
|
||||||
|
.CompanyName = rowin.Item("CompanyName"),
|
||||||
|
.OrderId = rowin.Item("OrderID"),
|
||||||
|
.OrderUnitPrice = rowin.Item("Aprice")
|
||||||
|
}
|
||||||
|
End Function)
|
||||||
|
End Function
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
End Namespace
|
End Namespace
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Public Interface IOrderInformationRetriever
|
||||||
|
Function GetOrderInformationAmountTotal() As List(Of OrderInformation)
|
||||||
|
End Interface
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Public Class OrderInformation
|
||||||
|
|
||||||
|
Public Property CompanyName As String
|
||||||
|
Public Property OrderId As String
|
||||||
|
Public Property OrderUnitPrice As String
|
||||||
|
End Class
|
||||||
@@ -108,6 +108,7 @@
|
|||||||
<Compile Include="EditingControlHosting\MainForm.vb">
|
<Compile Include="EditingControlHosting\MainForm.vb">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="IOrderInformationRetriever.vb" />
|
||||||
<Compile Include="JustInTimeDataLoading\Cache.vb" />
|
<Compile Include="JustInTimeDataLoading\Cache.vb" />
|
||||||
<Compile Include="JustInTimeDataLoading\MainForm.Designer.vb">
|
<Compile Include="JustInTimeDataLoading\MainForm.Designer.vb">
|
||||||
<DependentUpon>MainForm.vb</DependentUpon>
|
<DependentUpon>MainForm.vb</DependentUpon>
|
||||||
@@ -136,6 +137,7 @@
|
|||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="OrderInformation.vb" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="CustomDataGridViewColumn\MainForm.resx">
|
<EmbeddedResource Include="CustomDataGridViewColumn\MainForm.resx">
|
||||||
|
|||||||
Reference in new issue
Block a user