示例#1
0
文件: Data.cs 项目: andreszb/Point
 //Gets sales for a specific date as a list.
 public static List <StringItem> Sales(this DateTime date)
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var        stringDate = date.ToLocalTime().ToString("s").Substring(2, 8);
         SalesByDay today      = new SalesByDay();
         today = (from s in db.Table <SalesByDay>() where s.Day == stringDate select s).FirstOrDefault();
         //Return list if found
         return(today != null ? today.Table : null);
     }
 }
示例#2
0
文件: Data.cs 项目: andreszb/Point
 public static String TotalOwed(this DateTime date)
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var         stringDate = date.ToLocalTime().ToString("s").Substring(2, 8);
         SalesByDay  today      = (from s in db.Table <SalesByDay>() where s.Day == stringDate select s).FirstOrDefault();
         Double      val        = today != null ? today.TotalOwed : 0;
         CultureInfo culture    = new CultureInfo("es-MX");
         return(String.Format(culture, "{0:C2}", val));
     }
 }
示例#3
0
文件: Data.cs 项目: andreszb/Point
 // Returns total from SalesByDay Table for a specific date.
 public static String Total(this DateTime date)
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var stringDate = date.ToLocalTime().ToString("s").Substring(2, 8);
         //Search for date in table
         SalesByDay today = (from s in db.Table <SalesByDay>() where s.Day == stringDate select s).FirstOrDefault();
         //Set value to total property if not null
         Double      val     = today != null ? today.Total : 0;
         CultureInfo culture = new CultureInfo("es-MX");
         //Return as string formated as currency.
         return(String.Format(culture, "{0:C2}", val));
     }
 }
示例#4
0
文件: Data.cs 项目: andreszb/Point
        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();
        }
示例#5
0
文件: Data.cs 项目: andreszb/Point
 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);
         }
     }
 }
示例#6
0
文件: Data.cs 项目: andreszb/Point
        //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();
        }