Пример #1
0
        public static void updateProductsData()
        {
            var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "product.txt");

            File.WriteAllText(filePath, String.Empty);
            foreach (var item in products)
            {
                var cipherText = CryptManager.encryptText(item);
                using (StreamWriter outputFile = new StreamWriter(filePath, true))
                {
                    outputFile.WriteLine(cipherText);
                }
            }
        }
Пример #2
0
        public static void saveOrder(Order order)
        {
            var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ordersData.txt");
            //order.taxPrice = (order.totalPrice * order.tax);
            //order.servicePrice = (order.totalPrice + order.taxPrice) * order.service;
            string orderHeader = order.date.ToString() + "*" + order.tarabyza + "*" + order.price.ToString() + "*" + order.discount.ToString() + "*" + order.taxPrice + "*" + order.servicePrice + "*" + order.totalPrice.ToString();
            string orderDrinks = "";

            foreach (var drink in order.drinks.Values)
            {
                orderDrinks += drink.name + "*" + drink.price + "*" + drink.amount.ToString() + "*";
            }
            orderDrinks = orderDrinks.Remove(orderDrinks.Length - 1, 1);
            orderDrinks = CryptManager.encryptText(orderDrinks);
            orderHeader = CryptManager.encryptText(orderHeader);
            using (StreamWriter outputFile = new StreamWriter(filePath, true))
            {
                outputFile.WriteLine(orderHeader);
                outputFile.WriteLine(orderDrinks);
            }
        }
Пример #3
0
        public static void updateUserData()
        {
            var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "loginData.txt");

            File.WriteAllText(filePath, String.Empty);
            for (int i = 0; i < users.Count(); i++)
            {
                string userData = "";
                userData += users[i].userName + "*";
                userData += users[i].password + "*";
                userData += users[i].name + "*";
                userData += users[i].adminAccess.ToString();
                userData  = CryptManager.encryptText(userData);
                using (StreamWriter outputFile = new StreamWriter(filePath, true))
                {
                    outputFile.WriteLine(userData);
                }
            }

            loadUsersData();
        }
Пример #4
0
        public static void updateMenuData()
        {
            var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "drinks.txt");

            File.WriteAllText(filePath, String.Empty);



            foreach (var item in menu)
            {
                string userData = item.Key + "*";
                foreach (var drink in item.Value)
                {
                    userData += drink.name + "*";
                    userData += drink.price + "*";
                }
                userData = userData.Remove(userData.Length - 1, 1);
                userData = CryptManager.encryptText(userData);
                using (StreamWriter outputFile = new StreamWriter(filePath, true))
                {
                    outputFile.WriteLine(userData);
                }
            }
        }