Esempio n. 1
0
        public static void AddItemType()
        {
            Console.Clear();
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    Console.WriteLine(Startup.languageInterface[21]);
                    string addition = CRUDProduct.CheckIfItemExists(Console.ReadLine(), foodType);
                    if (addition != string.Empty)
                    {
                        foodType.Add(addition);
                        answer = ConsoleKey.Escape;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Esempio n. 2
0
        public static void EditProductType()
        {
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    Console.Clear();
                    for (int i = 0; i < foodType.Count; i++)
                    {
                        Console.WriteLine("{0}) {1}", i, foodType[i]);
                    }
                    Console.WriteLine(Startup.languageInterface[71]);
                    int itemToEdit = InputChecker.CheckIfInt(foodType.Count);
                    Console.WriteLine(Startup.languageInterface[21]);
                    string newName = CRUDProduct.CheckIfItemExists(Console.ReadLine(), foodType);
                    if (newName != string.Empty)
                    {
                        Console.WriteLine(Startup.languageInterface[73], foodType[itemToEdit], newName);
                        Console.WriteLine(Startup.languageInterface[0]);
                        if (InputChecker.CheckIfEnter() == ConsoleKey.Enter)
                        {
                            foodType[itemToEdit] = newName;
                        }
                        else
                        {
                            Console.WriteLine(Startup.languageInterface[34]);
                        }
                        answer = ConsoleKey.Escape;
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Esempio n. 3
0
        public static void AddItemType()
        {
            Console.Clear();
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    Console.WriteLine(Startup.languageInterface[21]);
                    var addition = CRUDProduct.CheckIfTypeExists(Console.ReadLine());
                    if (addition != string.Empty)
                    {
                        using (var context = new StoreContext())
                        {
                            var newType = new ProductTypes()
                            {
                                PropertyName = addition
                            };
                            context.ProductTypes.Add(newType);
                            context.SaveChanges();
                        }
                        answer = ConsoleKey.Escape;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Esempio n. 4
0
        public static void EditProductType()
        {
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    using (var context = new StoreContext())
                    {
                        var productTypes = context.ProductTypes.ToList();
                        Console.Clear();
                        foreach (var item in productTypes)
                        {
                            Console.WriteLine("{0}) {1}", item.PropertyId, item.PropertyName);
                        }
                        Console.WriteLine(Startup.languageInterface[71]);
                        //Check if the type exists
                        List <int> typeIds = new List <int>();
                        foreach (var item in productTypes)
                        {
                            typeIds.Add(item.PropertyId);
                        }
                        int itemToEdit = InputChecker.CheckIfInt(1, context.ProductTypes.Last().PropertyId);
                        while (!typeIds.Contains(itemToEdit))
                        {
                            Console.WriteLine(Startup.languageInterface[36]);
                            itemToEdit = InputChecker.CheckIfInt(1, context.ProductTypes.Last().PropertyId);
                        }
                        //change the name of the type
                        //Console.WriteLine("item to edit {0}", context.ProductTypes.Single(id=>id.PropertyId == itemToEdit).PropertyName);
                        Console.WriteLine(Startup.languageInterface[21]);
                        string newName = CRUDProduct.CheckIfTypeExists(Console.ReadLine());
                        if (newName != string.Empty)
                        {
                            //Console.WriteLine(itemToEdit);
                            // Console.WriteLine(context.ProductTypes.Single(id => id.PropertyId == itemToEdit).PropertyName);
                            //Console.WriteLine(Startup.languageInterface[73], context.ProductTypes.Single(id => id.PropertyId == itemToEdit).PropertyName);
                            Console.WriteLine(Startup.languageInterface[0]);
                            if (InputChecker.CheckIfEnter() == ConsoleKey.Enter)
                            {
                                var typeToEdit = context.ProductTypes.Single(id => id.PropertyId == itemToEdit);
                                //Console.WriteLine(typeToEdit.PropertyName);
                                //Console.ReadLine();
                                typeToEdit.PropertyName = newName;
                                context.SaveChanges();
                            }
                            else
                            {
                                Console.WriteLine(Startup.languageInterface[34]);
                            }
                            answer = ConsoleKey.Escape;
                        }
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            ExportAndInport creator     = new ExportAndInport();
            CRUDProduct     newProduct  = new CRUDProduct();
            List <Product>  list        = creator.ImportStoreDataFromFiles();
            SellAndRestock  transaction = new SellAndRestock();

            Console.Clear();
            ConsoleKey cont = ConsoleKey.Enter;

            while (cont == ConsoleKey.Enter)
            {
                Console.Clear();
                Console.WriteLine(languageInterface[3]);
                Console.WriteLine(languageInterface[4]);
                Console.WriteLine(languageInterface[5]);
                Console.WriteLine(languageInterface[70]);
                Console.WriteLine(languageInterface[63]);
                Console.WriteLine(languageInterface[9]);
                Console.WriteLine(languageInterface[10], 5);
                Console.Write(languageInterface[1]);

                int input = InputChecker.CheckIfInt(5);
                switch (input)
                {
                case 1:
                    Console.Clear();
                    ConsoleKey answer = ConsoleKey.Enter;
                    while (answer != ConsoleKey.Escape)
                    {
                        Console.Clear();
                        transaction.Sell(list);
                        Console.WriteLine(languageInterface[0]);
                        answer = InputChecker.CheckIfEnter();
                        Console.Clear();
                    }
                    break;

                case 2:
                    //Избиране на опция от менюто за управление на инвентара
                    Console.Clear();
                    Console.WriteLine(languageInterface[6]);
                    Console.WriteLine(languageInterface[8]);
                    Console.WriteLine(languageInterface[7]);
                    Console.WriteLine(languageInterface[74]);
                    Console.WriteLine(languageInterface[75]);
                    Console.WriteLine(languageInterface[76]);
                    Console.WriteLine(languageInterface[10], 7);
                    input = InputChecker.CheckIfInt(7);
                    switch (input)
                    {
                    case 1:
                        Console.Clear();
                        list.Add(newProduct.CreateNewProduct(list, languageInterface));
                        break;

                    case 2:
                        Console.Clear();
                        newProduct.DeleteItem(list);

                        break;

                    case 3:
                        Console.Clear();
                        newProduct.EditProduct(list);
                        break;

                    case 4:
                        Console.Clear();
                        Product.AddItemType();
                        break;

                    case 5:
                        Console.Clear();
                        Product.RemoveItemType();
                        break;

                    case 6:
                        Console.Clear();
                        Product.EditProductType();
                        break;

                    default:
                        break;
                    }
                    break;

                case 3:
                    Console.Clear();
                    transaction.DisplayProducts(list);
                    break;

                case 4:
                    Console.Clear();
                    transaction.Restock(list);

                    break;

                case 5:
                    Console.Clear();
                    ExportAndInport.ExportStoreDataToFiles(list);
                    return;

                default:
                    break;
                }
            }
        }