Esempio n. 1
0
 public MSCurrency(MSCurrency msCurrency)
 {
     MSCurrencyType    = msCurrency.MSCurrencyType;
     MSCurrencyCode    = msCurrency.MSCurrencyCode;
     MSCurrencyNominal = msCurrency.MSCurrencyNominal;
     MSCurrencyName    = msCurrency.MSCurrencyName;
     MSCurrencyValue   = msCurrency.MSCurrencyValue;
 }
Esempio n. 2
0
        public void ConsoleAdd(int accountId, char msIO = '=')
        {
            int left = Console.CursorLeft;
            int top  = Console.CursorTop;

            MSAccountId = accountId;
            if (msIO == '+' || msIO == '-')
            {
                MSIO = msIO;
            }
            else
            {
                bool xreplace = true;
                do
                {
                    Console.SetCursorPosition(left, top);
                    Console.WriteLine("Введите тип аккаунта (+,-): ");
                    string temp = Console.ReadLine();
                    if (temp.Length > 0)
                    {
                        if (temp[0] == '+' | temp[0] == '-')
                        {
                            MSIO     = temp[0];
                            xreplace = false;
                        }
                    }
                } while (xreplace);
            }
            Console.WriteLine("Введите наименование аккаунта: ");
            MSName = Console.ReadLine();
            Console.WriteLine("Выбермте цвет аккаунта: ");
            MSColor = MSIntro.ChooseColor();
            Console.WriteLine("Введите символ аккаунта: ");
            MSImage = Console.ReadLine();
            Console.WriteLine("Введите тип валюты аккаунта: ");
            //MSCurrencyCode = Console.ReadLine();
            MSCurrencyCode = MSCurrency.ChooseCurrency(ref Program.currencies);
            if (MSCurrencyCode == "ALL")
            {
                MSMulticurrency = true;
            }
            else
            {
                MSMulticurrency = false;
            }
        }
Esempio n. 3
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();
        }
        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();
        }
        public static void ConsoleTransfer(ref List <MSTransaction> transactions, int msTransactionId)
        {
            int           tAccount2      = 0;
            MSTransaction tMSTransaction = new MSTransaction();
            int           left           = Console.CursorLeft;
            int           top            = Console.CursorTop;

            tMSTransaction.MSTransactionId = msTransactionId;

            tMSTransaction.MSIO = '-';

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

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

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

            left = Console.CursorLeft;
            top  = Console.CursorTop;
            bool xreplace = true;

            do
            {
                Console.SetCursorPosition(left, top);
                Console.WriteLine("Выберите тип валюты: ");
                string tMSCurrencyCode = MSCurrency.ChooseCurrency(ref Program.currencies);

                if (tMSCurrencyCode != "ALL")
                {
                    tMSTransaction.MSCurrencyCode = tMSCurrencyCode;
                    xreplace = false;
                }
            } while (xreplace);

            Console.WriteLine("Выберите аккаунт ввода суммы: "); //2
            if (Program.accounts.Count > 0)
            {
                tAccount2 = MSAccount.ChooseAccount(ref Program.accounts);
            }

            Console.WriteLine("Введите заметку: ");
            tMSTransaction.MSNote = Console.ReadLine();
            if (tMSTransaction.MSNote.Length == 0)
            {
                tMSTransaction.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 == " ")
            {
                tMSTransaction.MSDateTime = Program.msCompDateTime();
            }
            else
            {
                tMSTransaction.MSDateTime = DateTime.Parse(tDateTime);
            }

            transactions.Add(new MSTransaction(tMSTransaction));
            MSTransaction.SQLiteInsertTransactionInDatabase(tMSTransaction);

            tMSTransaction.MSIO = '+';

            tMSTransaction.MSAccountId = tAccount2;

            if (tMSTransaction.MSIO == '+')
            {
                if (tMSTransaction.MSValue < 0)
                {
                    tMSTransaction.MSValue *= -1;
                }
            }
            else if (tMSTransaction.MSIO == '-')
            {
                if (tMSTransaction.MSValue > 0)
                {
                    tMSTransaction.MSValue *= -1;
                }
            }

            transactions.Add(new MSTransaction(tMSTransaction));
            MSTransaction.SQLiteInsertTransactionInDatabase(tMSTransaction);

            Program.cki = default(ConsoleKeyInfo);
            Console.Clear();
        }
Esempio n. 6
0
        public List <MSCurrency> MSLoadCurrencies()
        {
            var MSCurrencyTypeList = new List <MSCurrency>();
            var msCurrencyType     = new MSCurrency();

            msCurrencyType.MSCurrencyId      = 0;
            msCurrencyType.MSCurrencyDate    = Program.msCompDateTime();
            msCurrencyType.MSCurrencyType    = "Xarici valyuta";
            msCurrencyType.MSCurrencyCode    = "AZN";
            msCurrencyType.MSCurrencyNominal = 1;
            msCurrencyType.MSCurrencyName    = "Azərbaycan manatı";
            msCurrencyType.MSCurrencyValue   = 1;

            MSCurrencyTypeList.Add(new MSCurrency(msCurrencyType));

            var xmlDoc = new XmlDocument();

            try
            {
                Console.WriteLine("Попытка загрузки валют с сервера.");
                xmlDoc.Load(msCurrencyLink); //Не возможно связться с сервером для загрузки данных о валютах!
                XmlElement xRoot = xmlDoc.DocumentElement;
                foreach (XmlNode xnode in xRoot)
                {
                    XmlNode attrType = xnode.Attributes.GetNamedItem("Type");
                    if (attrType != null)
                    {
                        msCurrencyType.MSCurrencyType = attrType.Value;
                        //Console.WriteLine(attrType.Value);
                    }
                    foreach (XmlNode childnode in xnode.ChildNodes)
                    {
                        XmlNode attrCode = childnode.Attributes.GetNamedItem("Code");
                        if (attrCode != null)
                        {
                            msCurrencyType.MSCurrencyCode = attrCode.Value;
                            //Console.WriteLine(attrCode.Value);
                        }
                        foreach (XmlNode childChildNode in childnode)
                        {
                            if (childChildNode.Name == "Nominal")
                            {
                                if (attrType.Value == "Bank metalları")
                                {
                                    msCurrencyType.MSCurrencyNominal = float.Parse("1,00");
                                    //Console.WriteLine(1);
                                }
                                else
                                {
                                    string tString = childChildNode.InnerText;
                                    int    tInt    = tString.IndexOf('.');
                                    if (tInt > 0)
                                    {
                                        msCurrencyType.MSCurrencyNominal = float.Parse(childChildNode.InnerText.Replace('.', ','));
                                    }
                                    else
                                    {
                                        msCurrencyType.MSCurrencyNominal = float.Parse(childChildNode.InnerText);
                                    }
                                    //Console.WriteLine(childChildNode.InnerText);
                                }
                            }
                            if (childChildNode.Name == "Name")
                            {
                                msCurrencyType.MSCurrencyName = childChildNode.InnerText;
                                //Console.WriteLine(childChildNode.InnerText);
                            }
                            if (childChildNode.Name == "Value")
                            {
                                msCurrencyType.MSCurrencyValue = float.Parse(childChildNode.InnerText.Replace('.', ','));
                                //Console.WriteLine(childChildNode.InnerText);
                            }
                        }
                        MSCurrencyTypeList.Add(new MSCurrency(msCurrencyType));
                    }
                }
                Console.WriteLine("Загрузка валют с сервера завершена.");
            }
            catch (System.Net.WebException)
            {
                Console.WriteLine("Не возможно связаться с сервером для загрузки данных о валютах!");
            }
            catch (Exception)
            {
                Console.WriteLine("Произошла не предвиденная ошибка!");
            }
            return(MSCurrencyTypeList);
        }
Esempio n. 7
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);
        }