コード例 #1
0
        public static void DisplayStates()
        {
            List <State> States = new List <State>();

            try
            {
                States = LoadStates.LoadAllStates();
            }
            catch
            {
                Console.WriteLine("Could not load sales tax data");
            }
            if (States != null)
            {
                Console.WriteLine("List of Sales Zones");
                int i = 1;
                foreach (State state in States)
                {
                    Console.WriteLine($"{i}: State Name: {state.StateName}");
                    Console.WriteLine($"State Code: {state.StateCode}");
                    Console.WriteLine($"Tax Rate: {state.TaxRate}%");
                    Console.WriteLine("_________________________________________________");
                    i++;
                }
            }
            else
            {
                Console.WriteLine("Error displaying tax information.\nTry turning the computer off and on before contacting Contact IT");
            }
        }
コード例 #2
0
ファイル: Font.cs プロジェクト: kukuru3/Sargon
        public void StartLoad()
        {
            if (NativeFont != null)
            {
                Unload();
            }

            LoadState = LoadStates.Loading;

            try {
                NativeFont = new SFML.Graphics.Font(Path);
            } catch (Exception) {
                LoadState = LoadStates.Failed;
            }

            LoadState = LoadStates.Active;
        }
コード例 #3
0
ファイル: Font.cs プロジェクト: kukuru3/Sargon
 public void Unload()
 {
     LoadState = LoadStates.NotLoaded;
 }
コード例 #4
0
        public void CanParseStates()
        {
            List <State> States = LoadStates.LoadAllStates();

            Assert.AreEqual(States[0].StateCode, "DS");
        }
コード例 #5
0
    void SetLoadState(LoadStates loadState)
    {
        LoadState = loadState;
        switch (LoadState)
        {
        case LoadStates.Idle:
            break;

        case LoadStates.Starting:
            DEBUG.Log("Starting Game...");
            SetLoadState(LoadStates.LoadingData);
            break;

        case LoadStates.LoadingData:
            // Fetch Google Sheet Data
            if (Application.internetReachability != NetworkReachability.NotReachable)
            {
                GameData.Reload(onCallLoaded: () =>
                {
                    DEBUG.Log("Data Loaded...", Warning_Types.Good);
                    DataLoaded = true;

                    SetLoadState(LoadStates.OpeningScene);
                });
            }
            else
            {
                DEBUG.Log("Not Connected to the internet, GameData and multiplayer offline", Warning_Types.Error);
                DataLoaded = true;
                SetLoadState(LoadStates.OpeningScene);
            }
            break;

        case LoadStates.OpeningScene:
            DEBUG.Log(string.Format("Opening scene {0}...", SceneManager.GetActiveScene().name));
            SceneManager.sceneLoaded += ReloadCurrentScene;
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            break;

        case LoadStates.StartingSystems:
            SceneManager.sceneLoaded -= ReloadCurrentScene;

            DEBUG.Log("Scene Loaded...", Warning_Types.Log);
            CreateSubsystem <ObjectPool>();
            PlayerTankManager = CreateSubsystem <PlayerTankmanager>() as PlayerTankmanager;
            CreateSubsystem <UnlockManager>();
            CreateSubsystem <AudioManager>();
            CreateSubsystem <EventManager>();
            DEBUG.Log("Systems Started...", Warning_Types.Good);
            SetLoadState(LoadStates.Connecting);
            break;

        case LoadStates.Connecting:
            if (Application.internetReachability != NetworkReachability.NotReachable)
            {
                DEBUG.Log("Connecting...", Warning_Types.Log);
                PhotonNetwork.ConnectUsingSettings("v1");
            }
            else
            {
                DEBUG.Log("Network not reachable...", Warning_Types.Warning);
                SetLoadState(LoadStates.LoadingPlayer);
            }
            break;

        case LoadStates.LoadingPlayer:
            StartLevelManager();
            SetLoadState(LoadStates.Ready);
            break;

        case LoadStates.Ready:
            // App is ready, nothing further to do here
            DEBUG.Log("Ready", Warning_Types.Good);
            break;
        }
    }
コード例 #6
0
        //--------------------------------------------------------------------------------------------------------------------------------------
        public void EditOrder()
        {
            List <Product> Products = new List <Product>();

            try
            {
                Products = LoadProducts.LoadAllProducts();
            }
            catch
            {
                Console.WriteLine("Could not load product data");
            }
            List <State> States = new List <State>();

            try
            {
                States = LoadStates.LoadAllStates();
            }
            catch
            {
                Console.WriteLine("Could not load sales tax data");
            }
            string       date          = PseudoDateSelect();
            string       filename      = "Orders_" + date + ".txt"; //enusre write-ability
            string       path          = @"C:\repos\chris-williams-individual-work\FlooringMasteryV5\Data\Orders\" + filename;
            List <Order> CurrentOrders = new List <Order>();

            if (!File.Exists(path))
            {
                Console.WriteLine("Invalid date");
                Console.WriteLine("Press any key to continue");
                Console.ReadKey();
                return;
            }
            try
            {
                LoadOrders current = new LoadOrders();
                CurrentOrders = current.ParseFileData(filename);
            }
            catch
            {
                Console.WriteLine("Could not open specified file");
                return;
            }
            Console.Clear();
            Console.WriteLine($"Orders on {date}");
            Console.WriteLine("Order#, Customer name, State, product type, area, total cost");
            foreach (Order order in CurrentOrders)
            {
                Console.WriteLine($"{order.OrderNumber}, {order.CustomerName}, {order.State}, {order.Product}, {order.Area}, {order.Total:C}");
            }

            bool  GoodOrder   = false;
            Order OrderToEdit = new Order();

            while (!GoodOrder)
            {
                Console.WriteLine("Please enter the order number of the order you wish to edit");
                int   selection = UserIO.GetIntegerFromUser();
                Order chosen    = CurrentOrders.Where(o => o.OrderNumber == selection).FirstOrDefault();
                if (chosen != null)
                {
                    OrderToEdit = chosen;
                    GoodOrder   = true;
                    break;
                }
                else
                {
                    Console.WriteLine("Enter a valid order number");
                }
            }
            Console.WriteLine($"The current Customer name is {OrderToEdit.CustomerName}");
            Console.WriteLine("Enter a new name, or leave the field blank to retain the current name");
            string namechange = Console.ReadLine();  // will need this to be better, maybe seperate into change name function

            if (namechange != "")
            {
                if (namechange[0].ToString() != " ")
                {
                    OrderToEdit.CustomerName = namechange;
                    Console.WriteLine($"Customer name changed to {OrderToEdit.CustomerName}");
                }
                else
                {
                    Console.WriteLine($"Customer name reamins {OrderToEdit.CustomerName}");
                }
            }
            else
            {
                Console.WriteLine($"Customer name remains {OrderToEdit.CustomerName}");
            }
            Console.WriteLine($"The current state is {OrderToEdit.State}");

            UserIO.DisplayStates();
            Console.WriteLine("Please enter the number associated with the customer's updated state");
            string statechange = Console.ReadLine();
            State  Mystate     = null;

            if (statechange != "")
            {
                if (statechange[0].ToString() != " ")
                {
                    Mystate             = EditState(States, statechange);
                    OrderToEdit.State   = Mystate.StateCode;
                    OrderToEdit.TaxRate = Mystate.TaxRate;
                }
                else
                {
                    Console.WriteLine($"State remains {OrderToEdit.State}");
                    Mystate = GetState(OrderToEdit.State, States);
                }
            }
            else
            {
                Console.WriteLine($"State remains {OrderToEdit.State}");
                Mystate = GetState(OrderToEdit.State, States);
            }
            Console.Clear();
            UserIO.DisplayProducts();
            Console.WriteLine($"The current product selected is {OrderToEdit.Product}");
            Console.WriteLine("please enter the new product, or leave the field empty to continue");
            Product changedproduct = null;
            string  productchange  = Console.ReadLine();

            if (productchange != "")
            {
                if (productchange[0].ToString() != " ")
                {
                    bool isFinished         = false;
                    int  productchangeIndex = 0;
                    while (!isFinished)
                    {
                        bool goodInt = int.TryParse(productchange, out productchangeIndex);

                        if (goodInt)
                        {
                            changedproduct      = GetProductByIndex(productchangeIndex, Products);
                            OrderToEdit.Product = changedproduct.ProductName;
                            OrderToEdit.LaborCostPerSquareFoot = changedproduct.LaborCost;
                            OrderToEdit.CostPerSquareFoot      = changedproduct.CostperSquare;
                            Console.WriteLine($"The product has been updated to {OrderToEdit.Product} with a material cost of of {OrderToEdit.CostPerSquareFoot:C}/ft^2, \nand a labor cost of {OrderToEdit.LaborCostPerSquareFoot:C}");
                            isFinished = true;
                        }
                        else
                        {
                            Console.WriteLine($"Please enter a valid index number in the range of 1 to {Products.Count}");
                            productchange = Console.ReadLine();
                        }
                    }
                }
                else
                {
                    Console.WriteLine($"Product remains {OrderToEdit.Product}");
                    changedproduct = GetMyProduct(OrderToEdit.Product, Products);
                }
            }
            else
            {
                Console.WriteLine($"Product remains {OrderToEdit.Product}");
                changedproduct = GetMyProduct(OrderToEdit.Product, Products);
            }
            Console.WriteLine($"The current area is {OrderToEdit.Area}");
            Console.WriteLine("please enter the new area, or leave the field empty to continue");
            string areachange = Console.ReadLine();

            if (areachange != "")
            {
                if (areachange[0].ToString() != " ")
                {
                    OrderToEdit.Area = GetArea(areachange);
                    Console.WriteLine($"The new area is {OrderToEdit.Area}");
                }
                else
                {
                    Console.WriteLine($"The area remains {OrderToEdit.Area}");
                }
            }
            else
            {
                Console.WriteLine($"The area remains {OrderToEdit.Area}");
            }
            OrderToEdit.ComputOrderValues(changedproduct, Mystate);
            Console.WriteLine($"The order now stands at:\n{ OrderToEdit.CustomerName}, in {OrderToEdit.State}, for {OrderToEdit.Area}ft^2 {OrderToEdit.Product} for a total of {OrderToEdit.Total:C}");
            Console.WriteLine("Do you wish to save these these changes?");
            Console.WriteLine("enter \'N\' to discard changes or any other key to keep changes?");
            string SaveChoice = Console.ReadLine().ToUpper();

            if (SaveChoice == "N")
            {
                Console.WriteLine("Changes Discared");
                return;
            }
            else
            {
                try
                {
                    using (StreamWriter sw = new StreamWriter(path))
                    {
                        sw.WriteLine("OrderNumber,CustomerName,State,TaxRate,ProductType,Area,CostPerSquareFoot,LaborCostPerSquareFoot,MaterialCost,LaborCost,Tax,Total");
                        foreach (Order MyOrder in CurrentOrders)
                        {
                            sw.WriteLine($"{MyOrder.OrderNumber},\"{MyOrder.CustomerName}\",{MyOrder.State},{MyOrder.TaxRate},{MyOrder.Product},{MyOrder.Area},{MyOrder.CostPerSquareFoot},{MyOrder.LaborCostPerSquareFoot},{MyOrder.MaterialCost},{MyOrder.LaborCost},{MyOrder.Tax},{MyOrder.Total}");
                        }
                    }
                }
                catch
                {
                    Console.WriteLine("Could not write updated order to file");
                    return;
                }
                Console.WriteLine("Order edited");
            }
        }
コード例 #7
0
        //--------------------------------------------------------------------------------------------------------------------------------------
        public void AddOrder()
        {
            List <Product> Products = new List <Product>();

            try
            {
                Products = LoadProducts.LoadAllProducts();
            }
            catch
            {
                Console.WriteLine("Could not load product data");
            }
            List <State> States = new List <State>();

            try
            {
                States = LoadStates.LoadAllStates();
            }
            catch
            {
                Console.WriteLine("Could not load sales tax data");
            }

            int          ordernumber   = FileIO.ReturnHighestOrderNumber() + 1;
            string       date          = DateSelect();
            string       filename      = "Orders_" + date + ".txt";
            string       path          = @"C:\repos\chris-williams-individual-work\FlooringMasteryV5\Data\Orders\" + filename;
            List <Order> CurrentOrders = new List <Order>();

            if (File.Exists(path))
            {
                LoadOrders current = new LoadOrders();
                CurrentOrders = current.ParseFileData(filename);
            }
            if (!File.Exists(path))
            {
                using (StreamWriter sw = new StreamWriter(path, true))
                {
                    sw.WriteLine("OrderNumber,CustomerName,State,TaxRate,ProductType,Area,CostPerSquareFoot,LaborCostPerSquareFoot,MaterialCost,LaborCost,Tax,Total");
                }
            }
            string name = GetName();

            Console.Clear();
            Console.WriteLine("Please enter the number associated with the customer's sales zone");
            UserIO.DisplayStates();
            State state = GetStateByIndex(States);

            Console.Clear();
            UserIO.DisplayProducts();
            Product myProduct = GetProductByIndex(Products);
            decimal area      = GetArea();
            Order   MyOrder   = new Order(ordernumber, name, state, myProduct, area, date);

            Console.WriteLine($"The order for {name} in {state.StateName} is {area}ft^2 of {myProduct.ProductName}");
            Console.WriteLine($"The cost/ft^2 for material is{MyOrder.CostPerSquareFoot}, and the labor cost/ft^2 is{MyOrder.LaborCostPerSquareFoot}");
            Console.WriteLine($"Total material cost: {MyOrder.MaterialCost:C} \nTotal labor cost: {MyOrder.LaborCost:C}\nTaxes: {MyOrder.Tax:C}\nTotal cost: {MyOrder.Total:C}");
            Console.WriteLine("Do you wish to submit this order?  Enter \"n\" to discard order");
            string input = Console.ReadLine().ToUpper();

            if (input != "N")
            {
                try
                {
                    using (StreamWriter sw = new StreamWriter(path, true))
                    {
                        sw.WriteLine($"{MyOrder.OrderNumber},{MyOrder.CustomerName},{MyOrder.State},{MyOrder.TaxRate},{MyOrder.Product},{MyOrder.Area},{MyOrder.CostPerSquareFoot},{MyOrder.LaborCostPerSquareFoot},{MyOrder.MaterialCost},{MyOrder.LaborCost},{MyOrder.Tax},{MyOrder.Total}");
                    }
                }
                catch
                {
                    Console.WriteLine("System Error: order not submitted");
                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    return;
                }
            }
            else
            {
                Console.WriteLine("Order terminated");
                Console.WriteLine("Press any key to continue");
                Console.ReadKey();
                return;
            }
            Console.WriteLine("Order entry complete");
        }