diff --git a/COM350/Project3/COM350-Summary.docx b/COM350/Project3/COM350-Summary.docx new file mode 100644 index 0000000..2a96ca4 Binary files /dev/null and b/COM350/Project3/COM350-Summary.docx differ diff --git a/COM350/Project3/VBWinFormDataGridView/DataGridViewPaging/MainForm.vb b/COM350/Project3/VBWinFormDataGridView/DataGridViewPaging/MainForm.vb index e62ab0c..e6b1e1b 100644 --- a/COM350/Project3/VBWinFormDataGridView/DataGridViewPaging/MainForm.vb +++ b/COM350/Project3/VBWinFormDataGridView/DataGridViewPaging/MainForm.vb @@ -16,11 +16,14 @@ Imports System.Data.SqlClient Imports System.Configuration +Imports System.Collections.Generic Namespace VBWinFormDataGridView.DataGridViewPaging Public Class MainForm + Implements IOrderInformationRetriever + Private PageSize As Integer = 30 Private CurrentPageIndex As Integer = 1 Private TotalPage As Integer @@ -28,6 +31,7 @@ Namespace VBWinFormDataGridView.DataGridViewPaging Private conn As SqlConnection Private adapter As SqlDataAdapter 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 Me.conn = New SqlConnection(connstr) @@ -95,6 +99,7 @@ Namespace VBWinFormDataGridView.DataGridViewPaging Dim view As New DataView(dt) view.Sort = "CustomerID" Dim dtout As DataTable = view.ToTable() + Me.dtable = dtout Return dtout End Function @@ -131,6 +136,45 @@ Namespace VBWinFormDataGridView.DataGridViewPaging Me.GetTotalPageCount() Me.dataGridView1.DataSource = GetPageData(Me.CurrentPageIndex) 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 Namespace \ No newline at end of file diff --git a/COM350/Project3/VBWinFormDataGridView/IOrderInformationRetriever.vb b/COM350/Project3/VBWinFormDataGridView/IOrderInformationRetriever.vb new file mode 100644 index 0000000..08bf2f6 --- /dev/null +++ b/COM350/Project3/VBWinFormDataGridView/IOrderInformationRetriever.vb @@ -0,0 +1,3 @@ +Public Interface IOrderInformationRetriever + Function GetOrderInformationAmountTotal() As List(Of OrderInformation) +End Interface diff --git a/COM350/Project3/VBWinFormDataGridView/OrderInformation.vb b/COM350/Project3/VBWinFormDataGridView/OrderInformation.vb new file mode 100644 index 0000000..990b672 --- /dev/null +++ b/COM350/Project3/VBWinFormDataGridView/OrderInformation.vb @@ -0,0 +1,6 @@ +Public Class OrderInformation + + Public Property CompanyName As String + Public Property OrderId As String + Public Property OrderUnitPrice As String +End Class diff --git a/COM350/Project3/VBWinFormDataGridView/VBWinFormDataGridView.vbproj b/COM350/Project3/VBWinFormDataGridView/VBWinFormDataGridView.vbproj index ce23db1..ab3ba49 100644 --- a/COM350/Project3/VBWinFormDataGridView/VBWinFormDataGridView.vbproj +++ b/COM350/Project3/VBWinFormDataGridView/VBWinFormDataGridView.vbproj @@ -108,6 +108,7 @@ Form + MainForm.vb @@ -136,6 +137,7 @@ Settings.settings True + diff --git a/COM390/Project 1/Project 1.sln b/COM390/Project 1/Project 1.sln new file mode 100644 index 0000000..0f87b9b --- /dev/null +++ b/COM390/Project 1/Project 1.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project 1", "Project 1\Project 1.vcxproj", "{332CB208-C9B0-4066-BC48-62652C0A5ED5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {332CB208-C9B0-4066-BC48-62652C0A5ED5}.Debug|Win32.ActiveCfg = Debug|Win32 + {332CB208-C9B0-4066-BC48-62652C0A5ED5}.Debug|Win32.Build.0 = Debug|Win32 + {332CB208-C9B0-4066-BC48-62652C0A5ED5}.Release|Win32.ActiveCfg = Release|Win32 + {332CB208-C9B0-4066-BC48-62652C0A5ED5}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/COM390/Project 1/Project 1/Project 1.vcxproj b/COM390/Project 1/Project 1/Project 1.vcxproj new file mode 100644 index 0000000..b25836a --- /dev/null +++ b/COM390/Project 1/Project 1/Project 1.vcxproj @@ -0,0 +1,84 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {332CB208-C9B0-4066-BC48-62652C0A5ED5} + Win32Proj + Project1 + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/COM390/Project 1/Project 1/Project 1.vcxproj.filters b/COM390/Project 1/Project 1/Project 1.vcxproj.filters new file mode 100644 index 0000000..6827613 --- /dev/null +++ b/COM390/Project 1/Project 1/Project 1.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/COM390/Project 1/Project 1/main.c b/COM390/Project 1/Project 1/main.c new file mode 100644 index 0000000..2429951 --- /dev/null +++ b/COM390/Project 1/Project 1/main.c @@ -0,0 +1,39 @@ +#include +#include +#include + +const char* HELLO ="I love Porgramming in C\n"; +const char* TOKENS = " "; +const int TOKENINDEX = 1; // insert name after token 0 + +char name[256], out[256]; +char* token, nextToken = NULL; + +int main(int argc, char** argv) { + + printf("%s\n:", "Please enter your name"); + gets_s(name, sizeof(name)); + + strcpy(out, HELLO); + + token = strtok_s(out, TOKENS, &nextToken); + + for (int i = 0; token != NULL; i++) { + if (i == TOKENINDEX) { + printf(", %s,", name); + } + + if (i == 0) { + printf("%s", token); + } else { + printf(" %s", token); + } + + token = strtok_s(NULL, TOKENS, &nextToken); + } + + printf("\n%s\n", "Press any key to continue. . ."); + _getch(); + + return 0; +} \ No newline at end of file