コード例 #1
0
        public static void TransferMenu(Rect rect, bool is_recived, List <string> Categories)
        {
            if (Program.me.Cards.Count > 0)
            {
                string str_price = Window.Draw_Read_Line(new Rect(rect.left + 2, rect.top + 2, rect.width / 2 - 4, 2), "Enter price");
                if (new Regex(@"^\d+$").Match(str_price).Success)
                {
                    string   str_tag  = Window.Draw_Read_Line(new Rect(rect.left + 2, rect.top + 6, rect.width / 2 - 4, 2), "Enter tag");
                    DateTime dateTime = DateTime.Now;
                    if (Window.Draw_Bool(new Rect(rect.left + 2, rect.top + 9, rect.width / 2 - 4, 10), "Do you want to change data"))
                    {
                        if (DateTime.TryParse(Window.Draw_Read_Line(new Rect(rect.left + 2, rect.top + 21, rect.width / 2 - 4, 2), "Set Data as (MM/DD/YYYY)"), out DateTime new_time))
                        {
                            dateTime = new_time;
                        }
                        else
                        {
                            Errors.Add("Data not correct!");
                            return;
                        }
                    }
                    int category = Window.Draw_Choose(new Rect(rect.left + rect.width / 2, rect.top, rect.width / 2 + 1, rect.height), Categories.Concat(new List <string>()
                    {
                        "Add New"
                    }));
                    if (category == Categories.Count)
                    {
                        Window.Clear(new Rect(rect.left + rect.width / 2, rect.top, rect.width / 2 + 1, rect.height / 2 + 1));
                        Window.Draw(rect);
                        Categories.Add(Window.Draw_Read_Line(new Rect(rect.left + rect.width / 2 + 2, rect.top + 2, rect.width / 2 - 4, 2), "Enter name of new category"));
                    }
                    Window.Clear(new Rect(rect.left + rect.width / 2 + 1, rect.top + 1, rect.width / 2 - 2, rect.height - 2));
                    int cur = Window.Draw_Choose(new Rect(rect.left + rect.width / 2, rect.top, rect.width / 2 + 1, rect.height), Program.CurrencyCategories);
                    Window.Clear(new Rect(rect.left + rect.width / 2 + 1, rect.top + 1, rect.width / 2 - 2, rect.height - 2));
                    int       card = Window.Draw_Choose(new Rect(rect.left + rect.width / 2, rect.top, rect.width / 2 + 1, rect.height), Program.me.GetCardNames());
                    Transfers item = new Transfers(card, new Currency(int.Parse(str_price), cur), str_tag, category, is_recived, dateTime);
                    Program.transfers.Add(item);
                    if (Program.min < item.dateTime && item.dateTime < Program.max)
                    {
                        Program.FilteringTransfers.Add(item);
                    }

                    Transfers.Reset();
                }
                else
                {
                    Errors.Add("Price not correct!");
                }
            }
            else
            {
                Errors.Add("You dont have a card!");
            }
        }
コード例 #2
0
ファイル: Accaunt.cs プロジェクト: Aykhan27/Bank_Management
        public void EditCard(Rect rect)
        {
            Window.Draw(rect);
            switch (Window.Draw_Choose(rect.ChangeWidth(-rect.width / 2 - 1), Program.CardCategories))
            {
            case 0:
                string str_name = Window.Draw_Read_Line(new Rect(rect.left + rect.width / 2 + 2, rect.top + 2, rect.width / 2 - 3, 2), "Enter Card Name");
                int    cur      = Window.Draw_Choose(new Rect(rect.left + rect.width / 2 + 2, rect.top + 6, rect.width / 2 - 3, rect.height - 6 - 1), Program.CurrencyCategories);
                Cards.Add(new Card(new Currency(0, cur), str_name));
                break;

            case 1:
                Window.Clear(new Rect(rect.left + 1, rect.top + 1, rect.width / 2 - 2, rect.height / 2 - 2));
                switch (Window.Draw_Choose(rect.ChangeWidth(-rect.width / 2 - 1), Program.CardEditCategories))
                {
                case 0:
                    Window.Clear(new Rect(rect.left + 1, rect.top + 1, rect.width / 2 - 2, rect.height / 2 - 2));
                    int index = Window.Draw_Choose(rect.ChangeWidth(-rect.width / 2 - 1), GetCardNames());
                    Cards[index].Name = Window.Draw_Read_Line(new Rect(rect.left + rect.width / 2 + 2, rect.top + 2, rect.width / 2 - 4, 2), "Enter Card Name");
                    break;

                case 1:
                    Window.Clear(new Rect(rect.left + 1, rect.top + 1, rect.width / 2 - 2, rect.height / 2 - 2));
                    index = Window.Draw_Choose(rect.ChangeWidth(-rect.width / 2 - 1), GetCardNames());
                    int to_currency = Window.Draw_Choose(new Rect(rect.left + rect.width / 2 + 1, rect.top, rect.width / 2, rect.height), Program.CurrencyCategories);
                    Currency.ConvertMoney(ref Cards[index].Balance, to_currency);
                    break;
                }
                break;

            case 2:
                if (Cards.Count > 0)
                {
                    int index = Window.Draw_Choose(rect.ChangeLeft(rect.width / 2 + 1).ChangeWidth(-rect.width / 2 - 1), GetCardNames());
                    Cards.RemoveAt(index);
                    for (int i = 0; i < Program.transfers.Count; i++)
                    {
                        if (Program.transfers[i].Cardid == index)
                        {
                            Program.transfers.RemoveAt(i--);
                        }
                    }
                    Program.FilteringTransfers = Program.transfers.Where(x => Program.min <= x.dateTime && x.dateTime < Program.max).ToList();
                    Transfers.Reset();
                }
                else
                {
                    Errors.Add("You dont have a card!");
                }
                break;
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Aykhan27/Bank_Management
        static void Addtransfers()
        {
            Random random = new Random();                                                                                                                                                                ////

            for (int i = 0; i < count; i++)
            {
                bool t = random.Next(0, 100) > 55 ? true : false;
                transfers.Add(new Transfers(0, new Currency(random.Next(1, 2000), random.Next(1, Currency.CurrencyNames.Count)), random.Next(1, 2000).ToString(), random.Next(0, t ? Categories.Count : MoneyCategories.Count), t, DateTime.Now.AddDays(random.Next(-365, 365))));
                if (transfers[i].Is_Received)
                {
                    me.Expense          += transfers[i].Price;
                    me.Cards[0].Balance -= transfers[i].Price;
                }
                else
                {
                    me.Income           += transfers[i].Price;
                    me.Cards[0].Balance += transfers[i].Price;
                }
            }
            FilteringTransfers = transfers.Where(x => min <= x.dateTime && x.dateTime < max).ToList();
            Transfers.Reset();
        }
コード例 #4
0
        public static void ScrollMenu(Rect rect)
        {
            if (Program.FilteringTransfers.Count > 0)
            {
                Window.Draw(rect);

                for (int choose = 0, start = 0, end = Program.FilteringTransfers.Count > rect.height - 1 ? rect.height - 1 : Program.FilteringTransfers.Count; true;)
                {
                    for (int i = start; i < end; i++)
                    {
                        Transfers item = Program.FilteringTransfers[i];
                        Console.SetCursorPosition(rect.left + 1, rect.top + 1 + (i - start));
                        Console.Write(item);
                        Console.ResetColor();
                        if (i == choose)
                        {
                            Console.Write(" <--         \b\b\b\b\b\b\b\b");
                            Console.Write(i + 1);
                        }
                        else
                        {
                            Console.Write("                      ");
                        }
                    }
                    Console.SetCursorPosition(0, 0);
                    Console.Write($"ch={choose} s={start} e={end}");
                    switch (Console.ReadKey(true).Key)
                    {
                    case ConsoleKey.DownArrow:
                        if (choose + 1 < Program.FilteringTransfers.Count())
                        {
                            if (++choose >= end)
                            {
                                start++;
                                end++;
                            }
                        }
                        break;

                    case ConsoleKey.UpArrow:
                        if (choose > 0)
                        {
                            if (--choose < start)
                            {
                                start--;
                                end--;
                            }
                        }
                        break;

                    case ConsoleKey.RightArrow:
                        for (int i = 0; i < 10; i++)
                        {
                            if (choose + 1 < Program.FilteringTransfers.Count())
                            {
                                if (++choose >= end)
                                {
                                    start++;
                                    end++;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        break;

                    case ConsoleKey.LeftArrow:
                        for (int i = 0; i < 10; i++)
                        {
                            if (choose > 0)
                            {
                                if (--choose < start)
                                {
                                    start--;
                                    end--;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        break;

                    case ConsoleKey.Enter:
                        Window.Clear(rect);
                        SetTransfer(rect, Program.FilteringTransfers.ElementAt(choose));
                        return;

                    case ConsoleKey.Escape:
                        return;
                    }
                }
            }
            else
            {
                Errors.Add("You dont have a transfers!");
            }
        }
コード例 #5
0
ファイル: Transfers.cs プロジェクト: Aykhan27/Bank_Management
 public static void Reset(int index = -1)
 {
     if (Program.FilteringTransfers.Count > 0)
     {
         Transfers _this = Program.FilteringTransfers[Program.FilteringTransfers.Count - 1];
         if (maxPrice == null || index == 0)
         {
             maxPrice = Program.FilteringTransfers.Max(x => x.Price.ToString().Length);
         }
         else if (index == -1)
         {
             int lenght = _this.Price.ToString().Length;
             if (lenght > maxPrice.Value)
             {
                 maxPrice = lenght;
             }
         }
         if (maxTag == null || index == 1)
         {
             maxTag = Program.FilteringTransfers.Max(x => x.Tag.Length);
         }
         else if (index == -1)
         {
             int lenght = _this.Tag.Length;
             if (lenght > maxTag.Value)
             {
                 maxTag = lenght;
             }
         }
         if (maxTime == null || index == 2)
         {
             maxTime = Program.FilteringTransfers.Max(x => x.dateTime.ToShortDateString().Length);
         }
         else if (index == -1)
         {
             int lenght = _this.dateTime.ToShortDateString().Length;
             if (lenght > maxTime.Value)
             {
                 maxTime = lenght;
             }
         }
         if (maxCategory == null || index == 3)
         {
             maxCategory = Program.FilteringTransfers.Max(x => (x.Is_Received ? Program.Categories : Program.MoneyCategories)[x.Category].Length);
         }
         else if (index == -1)
         {
             int lenght = (_this.Is_Received ? Program.Categories : Program.MoneyCategories)[_this.Category].Length;
             if (lenght > maxCategory.Value)
             {
                 maxCategory = lenght;
             }
         }
     }
     else
     {
         maxCard     = null;
         maxCategory = null;
         maxPrice    = null;
         maxTag      = null;
         maxTime     = null;
     }
     if (Program.me.Cards.Count > 0)
     {
         if (maxCard == null || index == 4)
         {
             maxCard = Program.me.Cards.Max(x => x.Name.Length);
         }
         else if (index == -2)
         {
             Card _this  = Program.me.Cards[Program.me.Cards.Count - 1];
             int  lenght = _this.Name.Length;
             if (lenght > maxCard.Value)
             {
                 maxCard = lenght;
             }
         }
     }
     else
     {
         maxCard = null;
     }
 }