예제 #1
0
        public void addCustomer(string customerFirstName, string customerLastName)
        {
            string customerName      = customerFirstName.Trim() + " " + customerLastName.Trim();
            string addCustomerString = string.Format(SQLQueries.Queries["customer"], customerName);

            SQLCalls.ExecuteNonQuery(addCustomerString);
        }
예제 #2
0
        public string addOrder(long customerID, long productID, int count)
        {
            string addOrderString = string.Format(SQLQueries.Queries["order"], customerID, productID, count);

            if (doesCustomerExist(customerID))
            {
                if (doesProductExist(productID))
                {
                    SQLCalls.ExecuteNonQuery(addOrderString);
                    return("Success!");
                }
                else
                {
                    SQLCalls.CloseConnectionAndReader();
                    return("Product Doesn't Exist");
                    //    Debug.WriteLine("Product Doesn't Exist");
                }
            }
            else
            {
                SQLCalls.CloseConnectionAndReader();
                return("Customer Doesn't Exist");
                //    Debug.WriteLine("Customer Doesn't Exist");
            }
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
0
        public void addProduct(string productName, int productPrice)
        {
            string addProductString = string.Format(SQLQueries.Queries["product"], productName, productPrice);

            SQLCalls.ExecuteNonQuery(addProductString);
        }