示例#1
0
文件: Menu.cs 项目: bar-tek/wallet
        public void AddPurchace()
        {
            decimal amount;

            do
            {
                Console.Write("Wprowadź poprawną kwotę: ");
            } while(!decimal.TryParse(Console.ReadLine(), NumberStyles.Any, new CultureInfo("en-US"), out amount));

            Console.Write("Wprowadź nazwę: ");
            string name = Console.ReadLine();

            Console.Write("Wprowadź kategorię: ");
            string   categoryName = Console.ReadLine();
            Category category     = _manager.GetOrCreateCategory(categoryName);

            var purchace = new Purchace()
            {
                Date     = DateTime.Now,
                Amount   = amount,
                Name     = name,
                Category = category
            };

            _manager.AddPurchace(purchace);
            _manager.Save();
        }
示例#2
0
        private void Read()
        {
            foreach (var line in File.ReadLines(purchacePath))
            {
                string[] props = line.Split(',');

                DateTime date         = DateTime.Parse(props[0]);
                decimal  amount       = Convert.ToDecimal(props[1], new CultureInfo("en-US"));
                string   name         = props[2];
                string   categoryName = props[3];
                Category category     = GetOrCreateCategory(categoryName);

                Purchace purchace = new Purchace()
                {
                    Date     = date,
                    Amount   = amount,
                    Name     = name,
                    Category = category
                };
                Purchaces.Add(purchace);
            }
        }
示例#3
0
 public void AddPurchace(Purchace purchace)
 {
     Purchaces.Add(purchace);
 }