Esempio n. 1
0
        public void DeleteFromSalesByDayAsDebt()
        {
            SalesByDay today = SalesByDay.Today();

            string[] AllItems = today.ItemsString.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < AllItems.Length; i++)
            {
                if (AllItems[i].Contains(Description))
                {
                    AllItems[i]       = AllItems[i].DecreaseByOne();
                    today.ItemsString = string.Join("\n", AllItems);
                    today.TotalOwed  -= Price;
                    today.UpdateInTable();
                    return;
                }
            }
            today.ItemsString += "\n1\t" + Price + "\t" + Description;
            today.TotalOwed   -= Price;
            today.UpdateInTable();
        }
Esempio n. 2
0
 public static SalesByDay Today()
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         String today = DateTime.Now.ToLocalTime().ToString("s").Substring(2, 8);
         new SalesByDay();
         var query = (from s in db.Table <SalesByDay>() where s.Day == today select s).FirstOrDefault();
         if (query == null)
         {
             SalesByDay newDay = new SalesByDay()
             {
                 Day = today, ItemsString = String.Empty, Total = 0, TotalOwed = 0
             };
             db.Insert(newDay);
             return(SalesByDay.Today());
         }
         else
         {
             return(query);
         }
     }
 }
Esempio n. 3
0
        //Adds the current item to today's row from SalesByDay table.
        public void AddToSalesByDay()
        {
            //Get today's row
            SalesByDay today = SalesByDay.Today();

            //Separate items
            string[] AllItems = today.ItemsString.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < AllItems.Length; i++)
            {
                //Look for this item in array of items. If found, increase current item by one, rejoin and update table.
                if (AllItems[i].Contains(Description))
                {
                    AllItems[i]       = AllItems[i].IncreaseByOne();
                    today.ItemsString = string.Join("\n", AllItems);
                    today.Total      += Price;
                    today.UpdateInTable();
                    return;
                }
            }
            //If not found, set the value to this item's info and update.
            today.ItemsString += "\n1\t" + Price + "\t" + Description;
            today.Total       += Price;
            today.UpdateInTable();
        }