private static void InitieraDatabas() { if (DBHandler.InitDatabase()) { // Skapa tabeller DBHandler.CreateTable("Purchases", "ID INTEGER NOT NULL UNIQUE ", "ItemId INTEGER NOT NULL", "StoreId INTEGER NOT NULL", "Price REAL NOT NULL", "Date TEXT NOT NULL", @"PRIMARY KEY(""ID"" AUTOINCREMENT)"); DBHandler.CreateTable("Stores", "ID INTEGER NOT NULL UNIQUE", "Name TEXT NOT NULL", @"PRIMARY KEY(""ID"" AUTOINCREMENT)"); DBHandler.CreateTable("Items", "ID INTEGER NOT NULL UNIQUE", "Name TEXT NOT NULL", @"PRIMARY KEY(""ID"" AUTOINCREMENT)"); // Skapa butiker StoreHandler.InsertStore("Coop", "Ica", "Netto", "Lidl", "Bokus", "Adlibris", "SF Bokhandeln", "Kjell och Co", "Knas Ohlson", "Elgiganten", "H&M"); // Skapa varor ItemHandler.InsertItem("Mjölk", "Kattmat", "ASUS Laptop", "Bröd", "Knäckebröd", "USB hub", "Bok"); // Skapa demoinköp med slumpvalda datum PurchaseHandler.InsertPurchase("Coop", "Mjölk", 17.0, GetRandomDate()); PurchaseHandler.InsertPurchase("Coop", "Smör", 26.0, GetRandomDate()); PurchaseHandler.InsertPurchase("Coop", "Ost", 99.0, GetRandomDate()); PurchaseHandler.InsertPurchase("Ica", "Bröd", 16.0, GetRandomDate()); PurchaseHandler.InsertPurchase("Ica", "Mjölk", 17.0, GetRandomDate()); PurchaseHandler.InsertPurchase("Ica", "Pålägg", 22.0, GetRandomDate()); PurchaseHandler.InsertPurchase("Netto", "Mjölk", 17.0, GetRandomDate()); PurchaseHandler.InsertPurchase("Netto", "Bröd", 16.0, GetRandomDate()); PurchaseHandler.InsertPurchase("Adlibris", "Bok", 175, GetRandomDate()); PurchaseHandler.InsertPurchase("Adlibris", "Bok", 234, GetRandomDate()); PurchaseHandler.InsertPurchase("Bokus", "Bok", 127, GetRandomDate()); PurchaseHandler.InsertPurchase("Bokus", "Bok", 36, GetRandomDate()); PurchaseHandler.InsertPurchase("Netto", "Knäckabröd", 19, GetRandomDate()); PurchaseHandler.InsertPurchase("Netto", "Mjölk", 19, GetRandomDate()); PurchaseHandler.InsertPurchase("Kjell och Co", "USB Hub", 256, GetRandomDate()); PurchaseHandler.InsertPurchase("Knas Ohlson", "Glödlampa", 79, GetRandomDate()); } }
// Called when buy button is clicked for a ball void OnShopItemBtnClicked(int itemIndex) { PurchaseHandler ph = new PurchaseHandler(); //Debug.Log("Item Index : "+itemIndex); // Mark the item Purchased if (ph.hasEnoughCoins(BallShopItemList[itemIndex].price)) { ph.useCoins(BallShopItemList[itemIndex].price); BallShopItemList[itemIndex].isPurchased = true; // Add the Ball to the list //purchasedBallsList.Add(BallShopItemList[itemIndex].isPurchased); purchasedBallsList[itemIndex] = BallShopItemList[itemIndex].isPurchased; // Disable the button buyButton = ShopScrollView.GetChild(itemIndex).GetChild(3).GetComponent <Button>(); buyButton.interactable = false; // Set the text as purchased buyButton.transform.GetChild(0).GetComponent <Text>().text = "PURCHASED"; buyButton.gameObject.SetActive(false); savePurchasedBalls(itemIndex); //configureButton(itemIndex); OnEquipButtonClicked(itemIndex); } else { //noCoinsAnim.SetTrigger("noCoins"); Debug.Log("Not Enough Coins"); } }
private void SupplyOrderReport_Load(object sender, EventArgs e) { var supplyOrders = new PurchaseHandler().GetPurchases(); SupplyOrderBindingSource.DataSource = supplyOrders; reportViewer.RefreshReport(); }
public void Setup() { _mockChangeCalculator = MockRepository.GenerateMock <IChangeCalculator>(); _mockVendingMachineRepository = MockRepository.GenerateMock <IVendingMachineRepository>(); _fixture = new Fixture(); _sut = new PurchaseHandler(_mockChangeCalculator, _mockVendingMachineRepository); }
// Start is called before the first frame update void Start() { purchaseHandler = PurchaseHandler.instance; upgradeHandler = UpgradeHandler.instance; tooltip = Tooltip.instance; formatter = NumberFormatter.instance; upgradeHandler.UnlockUpgrades(1); }
public AddPurchaseDialog() { // Set up variables and properties prior to initialization _purchaseHandler = new PurchaseHandler(); Purchase = new Purchase(); SupplierSource = new SupplierHandler().GetSuppliers(); ItemSource = new ProductHandler().GetItems(); InitializeComponent(); Logger.Info("AddPurchaseDialog Loaded successfully"); }
public void SetReferences () { player = Player.instance; multi = Multiplier.instance; autoclicker = Autoclicker.instance; progressBar = ProgressBarHandler.instance; upgradeHandler = UpgradeHandler.instance; clicker = Clicker.instance; purchaseHandler = PurchaseHandler.instance; numberFormatter = NumberFormatter.instance; tooltip = Tooltip.instance; image = GetComponent<Image>(); }
void OnShopItemBtnClicked(int itemIndex) { PurchaseHandler ph = new PurchaseHandler(); // Mark the item purchased if (ph.hasEnoughCoins(ObstacleShopItemList[itemIndex].price)) { ph.useCoins(ObstacleShopItemList[itemIndex].price); ObstacleShopItemList[itemIndex].isPurchased = true; // Add the obstacle to the purchased list //purchasedObstaclesList.Add(ObstacleShopItemList[itemIndex].isPurchased); purchasedObstaclesList[itemIndex] = ObstacleShopItemList[itemIndex].isPurchased; // Disable the button buyButton = ShopScrollView.GetChild(itemIndex).GetChild(3).GetComponent <Button>(); buyButton.interactable = false; // Set the text as Purchased; buyButton.transform.GetChild(0).GetComponent <Text>().text = "PURCHASED"; buyButton.gameObject.SetActive(false); savePurchasedObstacles(itemIndex); OnEquipButtonClicked(itemIndex); } else { //noCoinsAnim.SetTrigger("noCoins"); Debug.Log("Not Enough Coins"); } /*if (PurchaseHandler.instance.hasEnoughCoins(ObstacleShopItemList[itemIndex].price)) { * PurchaseHandler.instance.useCoins(ObstacleShopItemList[itemIndex].price); * //Debug.Log("Item Index : "+itemIndex); * // Mark the item Purchased * ObstacleShopItemList[itemIndex].isPurchased = true; * // Disable the button * buyButton = ShopScrollView.GetChild(itemIndex).GetChild(3).GetComponent<Button>(); * buyButton.interactable = false; * // Set the text as purchased * buyButton.transform.GetChild(0).GetComponent<Text>().text = "PURCHASED"; * } * else { * noCoinsAnim.SetTrigger("noCoins"); * Debug.Log("You don't have Enough Coins!!"); * }*/ }
public SupplierDuePurchasesWindow(Supplier supplier) { _purchaseHandler = new PurchaseHandler(); var supplierHandler = new SupplierHandler(); if (string.IsNullOrEmpty(supplier.Name)) { supplier = supplierHandler.GetSuppliers(supplier.Id).SingleOrDefault(); } if (supplier == null) { throw new ArgumentNullException(nameof(supplier), @"Supplier Id is null"); } DuePurchases = _purchaseHandler.GetPurchases(supplier.Id, false); InitializeComponent(); SupplierIdTextBox.Text = supplier.Id.ToString(); NameTextBox.Text = supplier.Name; }
/// <summary> /// Main metoden /// </summary> /// <param name="args"></param> internal static void Main() { // Definiera databasfilen Settings.Database = @".\Purchases.db"; // Kolla om databasen finns, om ny databas skapats fyll på med demoinformation InitieraDatabas(); // Flagga för att veta om den ska fortsätta att fråga bool KeepAsking; do { Console.WriteLine("Mata in Butik, Vara, Pris, Datum (åååå-mm-dd) (ej nödvändig fält)"); Console.WriteLine("Tom rad avslutar inmatningarna"); // Fråga användaren om data var input = Console.ReadLine(); // Kolla om inputvärdet innehåller text KeepAsking = input.Length > 0; if (KeepAsking) { // Dela upp användarens kommaseparerade input var split = InputHandler.HandleInput(input); // Om längden är mindre än 2 då har användaren inte angett rätt mängd data if (split.Length > 2) { // Hämta butikens namn från input var store = split[0].Trim(); // Hämta varans namn från input var item = split[1].Trim(); // Hämta varans pris från input och omvandla till double double.TryParse(split[2].Trim(), out double price); // Sätt standarddatum (idag) var date = DateTime.Now.ToString("yyyy-MM-dd"); // Kolla om datum har angetts if (split.Length == 4) { // försök att omvandla datumet i textform till datum if (DateTime.TryParse(split[3], out DateTime newDate)) { // omvandla datumet till föredragen format date = newDate.ToString("yyyy-MM-dd"); } } // Spara inköpet PurchaseHandler.InsertPurchase(store, item, price, date); } else { // Informera användaren att datan är felaktig Console.WriteLine("Du angav felaktig data"); Console.WriteLine(" --> " + split[0]); Console.WriteLine(); } } // Forsätt så länge som användaren vill } while (KeepAsking); // Rensa skärmen Console.Clear(); // Visa statistik Console.WriteLine("Statistik"); Console.WriteLine($"Antal köpta varor {PurchaseHandler.GetAmountOfPurchases()}"); Console.WriteLine($"Totalt kostade det {PurchaseHandler.GetSumOfAllPurchases()} kr"); Console.WriteLine("Totalt för butiker"); // Hämta lista på butiker och hur mycket pengar som spenderats där var purchases = PurchaseHandler.GetPurchasesValueByStore(); foreach (DataRow row in purchases) { Console.WriteLine($"{row["Name"]} - {row["Summa"]}:-"); // Bonuskod! Ej nödvändigt men kul att göra // Hämta lista på alla varor från en butik var items = ItemHandler.GetItemsByStore(row["Name"].ToString()); foreach (DataRow item in items) { // Hämta namn på varan och se till att en är minst 15 tecken långt var name = item["Name"].ToString().PadLeft(15); // Hämta priset på varan och se till att den är minst 5 tecken långt var price = (item["Price"].ToString() + ":-").PadRight(5); // Skriv ut information och datum Console.WriteLine($" {name} - {price} {item["Date"]}"); } // Lägg till en tomrad mellan varje butik Console.WriteLine(); } // Lägg till tomrad för att debuggerns meddelande inte ska förstöra den snygga outputen Console.WriteLine(); }
private void Awake() { GV = GameObject.FindGameObjectWithTag("GameController").GetComponent <GlobalVariables>(); buy = GameObject.FindGameObjectWithTag("GameController").GetComponent <PurchaseHandler>(); btn = this.GetComponent <Button>(); }
void Start() { //totalCoinsText = GameObject.FindWithTag("totalCoinsTextStore").GetComponent<Text>(); instance = this; totalCoins = PlayerPrefs.GetInt("Total Coins"); }
public PurchaseHandlerTest() { _requestManger = new Mock <IRequestManger>(); _purchaseHandler = new PurchaseHandler(_requestManger.Object); }
public PurchaseHistoryWindow() { _purchaseHandler = new PurchaseHandler(); PurchaseSource = _purchaseHandler.GetPurchases(); InitializeComponent(); }
private void Awake() { instance = this; }