Exemplo n.º 1
0
        public void ConsoleAdd(int msTransactionId, char msIO)
        {
            int left = Console.CursorLeft;
            int top  = Console.CursorTop;

            MSTransactionId = msTransactionId;
            //bool xreplace = true;
            //do
            //{
            //    Console.SetCursorPosition(left, top);
            //    Console.WriteLine("Введите тип транзакции (+,-): ");
            //    string temp = Console.ReadLine();
            //    if (temp[0] == '+' | temp[0] == '-')
            //    {
            //        MSIO = temp[0];
            MSIO = msIO;
            //        xreplace = false;
            //    }
            //} while (xreplace);

            string insertSumm = "Введите значение (сумма): ";

            Console.WriteLine(insertSumm);
            left = Console.CursorLeft;
            top  = Console.CursorTop;
            //string tReadLine = "";
            do
            {
                Console.SetCursorPosition(left, top);
                if (MSValue > 0)
                {
                    string str = Convert.ToString(MSValue);
                    for (int i = 0; i < str.Length; i++)
                    {
                        Console.WriteLine(" ");
                    }
                }
                Console.SetCursorPosition(left, top);
                //    tReadLine = Console.ReadLine();
                //    float.TryParse(tReadLine, out float tMSValue);
                //    MSValue = tMSValue;
                MSValue = Program.MSReadDouble();
            } while (!(MSValue > 0));
            if (MSIO == '+')
            {
                if (MSValue < 0)
                {
                    MSValue *= -1;
                }
            }
            else if (MSIO == '-')
            {
                if (MSValue > 0)
                {
                    MSValue *= -1;
                }
            }
            Console.SetCursorPosition(insertSumm.Length + 1, top - 1);
            Console.WriteLine($"{MSValue:f2}");
            Program.cki = default(ConsoleKeyInfo);

            Console.WriteLine("Выберите тип валюты: ");
            MSCurrencyCode = MSCurrency.ChooseCurrency(ref Program.currencies);

            Console.WriteLine("Выберите аккаунт: ");
            if (Program.accounts.Count > 0)
            {
                MSAccountId = MSAccount.ChooseAccount(ref Program.accounts);
            }

            Console.WriteLine("Выберите категорию: ");
            if (Program.categories.Count > 0)
            {
                MSCategoryId = MSCategory.ChooseCategory(ref Program.categories, MSAccountId);
            }

            Console.WriteLine("Введите заметку: ");
            MSNote = Console.ReadLine();
            if (MSNote.Length == 0)
            {
                MSNote = " ";
            }

            Console.WriteLine("Введите дату и время\n(DD.MM.YYYY hh.mm.ss): "); Console.Write($" {Program.msCompDateTime()}");
            int xtop = Console.CursorTop;

            Console.SetCursorPosition(0, xtop + 1);
            string tDateTime = Console.ReadLine();

            if (tDateTime.Length == 0 | tDateTime == " ")
            {
                MSDateTime = Program.msCompDateTime();
            }
            else
            {
                MSDateTime = DateTime.Parse(tDateTime);
            }
            if (MSCurrencyCode == "ALL")
            {
                MSMulticurrency = true;
            }
            else
            {
                MSMulticurrency = false;
            }
            Program.cki = default(ConsoleKeyInfo);
            Console.Clear();
        }