Ejemplo n.º 1
0
        public ICollection <AmountOwed> totalAmountOwed()
        {
            Dictionary <long, AmountOwed> customersDictionary = new Dictionary <long, AmountOwed>();

            MySqlDataReader rdr = SQLCalls.ExecuteQuery(SQLQueries.Queries["getAllCustomers"]);

            while (rdr.Read())
            {
                long customerID = long.Parse(rdr[0].ToString());
                if (!customersDictionary.ContainsKey(customerID))
                {
                    customersDictionary.Add(customerID, new AmountOwed
                    {
                        customer = new Customer
                        {
                            CustomerId   = long.Parse(rdr[0].ToString()),
                            CustomerName = rdr[1].ToString()
                        },
                        amountOwed = int.Parse(rdr[3].ToString()) * int.Parse(rdr[2].ToString())
                    });
                }
                else
                {
                    customersDictionary[customerID].amountOwed += int.Parse(rdr[3].ToString()) * int.Parse(rdr[2].ToString());
                }
            }
            SQLCalls.CloseConnectionAndReader();
            return(customersDictionary.Values);
        }
Ejemplo n.º 2
0
        private bool doesProductExist(long productID)
        {
            string doesCustomerExistString = string.Format(SQLQueries.Queries["doesProductExist"], productID);

            MySqlDataReader rdr = SQLCalls.ExecuteQuery(doesCustomerExistString);

            while (rdr.Read())
            {
                //    Debug.WriteLine(rdr[0].ToString());
                if (rdr[0].ToString().Equals(productID.ToString()))
                {
                    SQLCalls.CloseConnectionAndReader();
                    return(true);
                }
            }
            SQLCalls.CloseConnectionAndReader();
            return(false);
        }