Пример #1
0
        static void Main(string[] args)
        {
            int maxWidth = 80, maxheight = 25;
            Console.SetWindowSize(maxWidth, maxheight);
            Console.SetBufferSize(maxWidth, maxheight);

            if (MSCurrency.CheckURL(MSCurrency.msCurrencyLink))
                currencies = currency.MSLoadCurrencies();
            else
            {
                if (true) //File exist
                {
                    if (true) //Table exist
                    {
                        if (true) //Value exist
                        {
                            MSSaveLoad.SQLiteLoadCurrenciesFromDatabase();
                        }
                    }
                }
            }
            //if (currencies.Count != 1)
            //{
            //    MSSaveLoad.SQLiteLoadCurrenciesFromDatabase();
            //}
            if (!File.Exists(Program.curFile))
            {
                MSSaveLoad.CreateDatabase();
                MSSaveLoad.InsertStandartValue();
            }
            MSSaveLoad.SQLiteLoadAccountsFromDatabase();
            MSSaveLoad.SQLiteLoadCategoriesFromDatabase();
            MSSaveLoad.SQLiteLoadTransactionsFromDatabase();

            Console.Title = "Money Supervisor - Управление деньгами - Pullara nəzarət";
            Console.OutputEncoding = Encoding.Unicode;
            Console.InputEncoding = Encoding.Unicode;

            MSLanguage.CreateDictionary(ref dictionary);

            MSIntro.Show();
            MSMainMenyu();
        }
Пример #2
0
        public static void CreateDictionary(ref Dictionary <string, MSLanguage> dictionary)
        {
            MSLanguage phrase1 = new MSLanguage
            {
                RUS = "Новая категория",
                AZE = "Yeni kateqoriya",
                ENG = "New category",
                KOR = "새 카테고리"
            };

            dictionary.Add("newcategory", phrase1);

            MSLanguage phrase2 = new MSLanguage
            {
                RUS = "Новый счёт",
                AZE = "Yeni hesab",
                ENG = "New account",
                KOR = "새 계정"
            };

            dictionary.Add("newaccount", phrase2);

            MSLanguage phrase3 = new MSLanguage
            {
                RUS = "",
                AZE = "",
                ENG = "",
                KOR = ""
            };

            dictionary.Add("", phrase3);

            MSLanguage phrase4 = new MSLanguage
            {
                RUS = "",
                AZE = "",
                ENG = "",
                KOR = ""
            };

            dictionary.Add(" ", phrase4);
        }
Пример #3
0
        static void MSMainMenyu()
        {
            Console.Clear();
            maxWidth = 40; maxheight = 25;
            Console.SetWindowSize(maxWidth, maxheight);
            Console.SetBufferSize(maxWidth, maxheight);
            
            bool xreplace = true;
            int i = 0;
            do
            {
                string str = "Добро пожаловать!";
                if (i >= maxWidth - str.Length)
                {
                    Console.SetCursorPosition(maxWidth - str.Length,0);
                    for (int j = 0; j < str.Length; j++)
                    {
                        Console.Write(" ");
                    }
                    i = 0;
                } 
                
                Console.SetCursorPosition(i - 1 < 0 ? i >= maxWidth-str.Length ? 0 : 0 : i - 1, 0);
                Console.Write("                  ");
                Console.SetCursorPosition(i++ < maxWidth - str.Length ? i : 0, 0);
                Console.Write(str);
                Thread.Sleep(333);
                
                if (Console.KeyAvailable)
                {
                    cki = Console.ReadKey();
                }
                Console.SetCursorPosition(0, 3);

                Console.SetCursorPosition(0, 1);
                Console.WriteLine($"1. {dictionary["newaccount"].RetLang(staticLanguage)} ");
                Console.SetCursorPosition(0, 2);
                Console.WriteLine($"2. {dictionary["newcategory"].RetLang(staticLanguage)} ");

                switch (cki.KeyChar)
                {
                    case '1':
                        Console.Clear();
                        AddAccount();
                        cki = default(ConsoleKeyInfo);
                        MSMainMenyu();
                        break;
                    case '2':
                        Console.Clear();
                        AddCategory();
                        cki = default(ConsoleKeyInfo);
                        MSMainMenyu();
                        break;
                    default:
                        break;
                }

                switch (cki.Key)
                {
                    case ConsoleKey.Tab:
                        if (++menyuId > maxMenyuId-1) menyuId = 0;
                        break;
                    case ConsoleKey.RightArrow:
                        if (++menyuId > maxMenyuId-1) menyuId = maxMenyuId-1;
                        break;
                    case ConsoleKey.LeftArrow:
                        if (--menyuId < 0) menyuId = 0;
                        break;
                    case ConsoleKey.DownArrow:
                        if (++menyuId > maxMenyuId-1) menyuId = maxMenyuId-1;
                        break;
                    case ConsoleKey.UpArrow:
                        if (--menyuId < 0) menyuId = 0;
                        break;
                    case ConsoleKey.Enter:
                        Program.cki = default(ConsoleKeyInfo);
                        Console.Clear();
                        int tTranCount = 0;
                        switch (menyuId)
                        {
                            case 0: //+
                                transactionSymbol = '+';
                                if (accounts.Count == 0)
                                {
                                    Console.WriteLine("В базе не найдены счёта.");
                                    Console.WriteLine("Создайте новый счёт.");
                                    Program.AddAccount();
                                }
                                if (categories.Count == 0)
                                {
                                    Console.WriteLine("В базе не найдены котегории.");
                                    Console.WriteLine("Создайте новую котегорию.");
                                    Program.AddCategory();
                                }
                                tTranCount = transactions.Count;
                                bool xReplaceTrCount = true;
                                do
                                {
                                    tTranCount++;
                                    if (!transactions.Exists(x => x.MSTransactionId == tTranCount))
                                    {
                                        xReplaceTrCount = false;
                                        transaction.ConsoleAdd(tTranCount, transactionSymbol);
                                    }
                                } while (xReplaceTrCount);
                                transactions.Add(new MSTransaction(transaction));
                                MSTransaction.SQLiteInsertTransactionInDatabase(transaction);
                                goto case 99;
                                //break;
                            case 1: //-
                                transactionSymbol = '-';
                                if (accounts.Count == 0)
                                {
                                    Console.WriteLine("В базе не найдены счёта.");
                                    Console.WriteLine("Создайте новый счёт.");
                                    Program.AddAccount();
                                }
                                if (categories.Count == 0)
                                {
                                    Console.WriteLine("В базе не найдены котегории.");
                                    Console.WriteLine("Создайте новую котегорию.");
                                    Program.AddCategory();
                                }
                                tTranCount = transactions.Count;
                                do
                                {
                                    tTranCount++;
                                    transaction.ConsoleAdd(tTranCount, transactionSymbol);
                                } while (transactions.Exists(x => x.MSTransactionId == tTranCount));
                                transactions.Add(new MSTransaction(transaction));
                                MSTransaction.SQLiteInsertTransactionInDatabase(transaction);
                                goto case 99;
                                //break;
                            case 2: //=
                                transactionSymbol = '=';
                                if (accounts.Count < 2)
                                {
                                    Console.WriteLine("В базе не достаточно счётов.");
                                    Console.WriteLine("Создайте новый счёт.");
                                    Program.AddAccount();
                                }
                                if (categories.Count == 0)
                                {
                                    Console.WriteLine("В базе не найдены котегории.");
                                    Console.WriteLine("Создайте новую котегорию.");
                                    Program.AddCategory();
                                }
                                MSTransaction.ConsoleTransfer(ref transactions, categories.Count + 1);
                                goto case 99;
                                //break;
                            case 3: //param
                                transactionSymbol = '=';
                                bool xReplace = true;
                                do
                                {
                                    Console.Clear();
                                    Console.WriteLine($"1. {dictionary["newaccount"].RetLang(staticLanguage)} ");
                                    Console.WriteLine($"2. {dictionary["newcategory"].RetLang(staticLanguage)} ");
                                    Console.WriteLine($"3. Выберите язык программы: ");
                                    Console.WriteLine($"4. Сброс базы данных: ");
                                    Console.WriteLine($"5. Выгрузка в CSV файл: ");
                                    Console.WriteLine($"6. Просмотреть все транзакции: ");
                                    Console.WriteLine($"7. Назад: ");
                                    
                                    cki = Console.ReadKey();
                                    //Console.WriteLine($"2. {dictionary["newcategory"].RetLang(staticLanguage)} ");
                                    switch (cki.KeyChar)
                                    {
                                        case '1':
                                            Console.Clear();
                                            Console.WriteLine($"1. {dictionary["newaccount"].RetLang(staticLanguage)} ");
                                            Program.AddAccount();
                                            break;
                                        case '2':
                                            Console.Clear();
                                            Console.WriteLine($"2. {dictionary["newcategory"].RetLang(staticLanguage)} ");
                                            Program.AddCategory();
                                            break;
                                        case '3':
                                            Console.Write($"3. Выберите язык программы: ");
                                            staticLanguage = MSLanguage.ChooseLanguage();
                                            Console.WriteLine("Язык изменён.");
                                            Program.cki = Console.ReadKey();
                                            break;
                                        case '4':
                                            Console.WriteLine($"4. Сброс базы данных: ");
                                            MSSaveLoad.CreateDatabase();
                                            MSSaveLoad.InsertStandartValue();
                                            currency = new MSCurrency();
                                            currencies = new List<MSCurrency>();
                                            account = new MSAccount();
                                            accounts = new List<MSAccount>();
                                            category = new MSCategory();
                                            categories = new List<MSCategory>();
                                            transaction = new MSTransaction();
                                            transactions = new List<MSTransaction>();
                                            break;
                                        case '5':
                                            Console.WriteLine($"5. Выгрузка в CSV файл: ");
                                            MSTransaction.SQLiteOutputTransactionsInCSV(transactions);
                                            break;
                                        case '6':
                                            Console.WriteLine($"6. Просмотреть все транзакции: ");
                                            Console.Clear();
                                            MSTransaction.ShowAllTransaction(transactions);
                                            Console.ReadKey();
                                            Console.Clear();
                                            break;
                                        case '7':
                                            xReplace = false;
                                            break;
                                        default:
                                            break;
                                    }
                                    cki = default(ConsoleKeyInfo);
                                } while (xReplace);
                                Console.Clear();
                                break;
                            case 4: //help
                                maxWidth = 80; maxheight = 25;
                                Console.SetWindowSize(maxWidth, maxheight);
                                Console.SetBufferSize(maxWidth, maxheight);
                                Console.WriteLine(">> Money Supervisor << предназначена для ведения записей о Ваших доходах и расходах");
                                MSIntro.Show();
                                Console.Clear();
                                maxWidth = 40; maxheight = 25;
                                Console.SetWindowSize(maxWidth, maxheight);
                                Console.SetBufferSize(maxWidth, maxheight);
                                break;
                            case 99:
                                Console.WriteLine("Информация добавлена.");
                                Program.cki = Console.ReadKey();
                                Program.cki = default(ConsoleKeyInfo);
                                Console.Clear();
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
                
                cki = default(ConsoleKeyInfo);

                MSIntro.Plus(menyuId, 5, 5, ConsoleColor.Green, ConsoleColor.Black);
                MSIntro.Minus(menyuId, 15, 5, ConsoleColor.Red, ConsoleColor.Black);
                MSIntro.Transfer(menyuId, 25, 5, ConsoleColor.Blue, ConsoleColor.Black);
                MSIntro.NotFound(menyuId, maxWidth - 14, maxheight - 5, ConsoleColor.Magenta, ConsoleColor.Black);
                MSIntro.Param(menyuId, 1, maxheight - 5, ConsoleColor.Yellow, ConsoleColor.Black);
                Console.SetCursorPosition(0,11);
                MSStatistics.Show(ref accounts, ref categories, ref transactions);

                //Console.WriteLine($"3. {dictionary[" "].RetLang(staticLanguage)} ");
                //Console.WriteLine($"4. {dictionary[" "].RetLang(staticLanguage)} ");
                //Console.WriteLine($"5. {dictionary[" "].RetLang(staticLanguage)} ");
                //Console.WriteLine($"6. {dictionary[" "].RetLang(staticLanguage)} ");
                //Console.ReadKey();
            } while (xreplace);
        }