Esempio n. 1
0
        private List <InvoiceRows> getTotalSalePerPop() //Metod för att ta fram total försäljning per invånare
        {
            List <InvoiceRows> totalSale = new List <InvoiceRows>();

            try
            {
                openConnection(totalSaleForEachCountry);

                float  totalSale1;
                string Country;

                while (myReader.Read())
                {
                    Country = myReader["Country"].ToString();
                    float.TryParse(myReader["TotalSalePerPopulation"].ToString(), out totalSale1);

                    InvoiceRows tempRows = new InvoiceRows(totalSale1, Country, "sss");

                    totalSale.Add(tempRows);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                conn.Close();
            }

            return(totalSale);
        }
Esempio n. 2
0
        //Hämta top respektive bot länder beroende på vilket val man gjort (valdTopBot är kopplat till sql queries ovan).
        private List <InvoiceRows> getTopCountries()
        {
            List <InvoiceRows> topCountry = new List <InvoiceRows>();

            try
            {
                openConnection(valdTopBot);

                float  unitPrice;
                string Country;

                while (myReader.Read())
                {
                    float.TryParse(myReader["Total Sales"].ToString(), out unitPrice);
                    Country = myReader["Country"].ToString();

                    InvoiceRows tempRows = new InvoiceRows(Country, unitPrice);

                    topCountry.Add(tempRows);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                conn.Close();
            }

            return(topCountry);
        }
Esempio n. 3
0
        //Hämta top respektive bot produkter beroende på vilket val man gjort (valdTopBotProd är kopplat till sql queries ovan).
        private List <InvoiceRows> getTopProduct()
        {
            List <InvoiceRows> topProduct = new List <InvoiceRows>();

            try
            {
                openConnection(valdTopBotProd);

                float  unitPrice;
                string Description;

                while (myReader.Read())
                {
                    float.TryParse(myReader["Quantity"].ToString(), out unitPrice);
                    Description = myReader["Description"].ToString();

                    InvoiceRows tempRows = new InvoiceRows(unitPrice, Description);

                    topProduct.Add(tempRows);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                conn.Close();
            }

            return(topProduct);
        }
Esempio n. 4
0
        private List <InvoiceRows> getSalesPerYear() //Metod för att ta fram total försäljning mellan två datum. Används för timelinegraf.
        {
            List <InvoiceRows> totalSales = new List <InvoiceRows>();

            try
            {
                openConnection(salesPerYear);

                float    sales;
                DateTime allDays;

                while (myReader.Read())
                {
                    DateTime.TryParse(myReader["dagar"].ToString(), out allDays);
                    float.TryParse(myReader["TotalSales"].ToString(), out sales);

                    InvoiceRows tempRows = new InvoiceRows(allDays, sales);

                    totalSales.Add(tempRows);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                conn.Close();
            }
            return(totalSales);
        }