Example #1
0
        //function second- hien thi item sua

        //---backgound select item- in lại item
        static void BgSelectedItem(int selected, ref Struct.LOAIHANG item)
        {
            switch (selected)
            {
            case 1:
                BgSelected();
                Console.CursorTop  = 4;
                Console.CursorLeft = 2;
                Console.WriteLine(item.MaLH);
                BgNormal();
                Console.CursorTop  = 8;
                Console.CursorLeft = 2;
                Console.WriteLine(item.TenLH);
                BgNormal();
                Console.CursorTop  = 12;
                Console.CursorLeft = 2;
                Console.WriteLine(item.MotaLH);
                break;

            case 2:
                BgSelected();
                Console.CursorTop  = 8;
                Console.CursorLeft = 2;
                Console.WriteLine(item.TenLH);
                BgNormal();
                Console.CursorTop  = 4;
                Console.CursorLeft = 2;
                Console.WriteLine(item.MaLH);
                BgNormal();
                Console.CursorTop  = 12;
                Console.CursorLeft = 2;
                Console.WriteLine(item.MotaLH);
                break;

            case 3:
                BgSelected();
                Console.CursorTop  = 12;
                Console.CursorLeft = 2;
                Console.WriteLine(item.MotaLH);
                BgNormal();
                Console.CursorTop  = 4;
                Console.CursorLeft = 2;
                Console.WriteLine(item.MaLH);
                BgNormal();
                Console.CursorTop  = 8;
                Console.CursorLeft = 2;
                Console.WriteLine(item.TenLH);
                break;
            }
            switch (selected)
            {
            case 1:
                Console.CursorTop  = 4;
                Console.CursorLeft = 2;
                break;

            case 2:
                Console.CursorTop  = 8;
                Console.CursorLeft = 2;
                break;

            case 3:
                Console.CursorTop  = 12;
                Console.CursorLeft = 2;
                break;
            }
        }
Example #2
0
        //
        public static void SuaLH(ref ArrayList ArrayLH, ref ArrayList ArrayHH, string ChucNang, int index, int selected)
        {
            Struct.LOAIHANG item = (Struct.LOAIHANG)ArrayLH[index];
            Form.FormLoaiHang("SỬA LOẠI HÀNG");
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkYellow;
            Console.CursorTop       = 0;
            Console.CursorLeft      = 20;
            Console.WriteLine("Lựa chọn [UP/DOWN]");
            Console.CursorTop  = 0;
            Console.CursorLeft = 40;
            Console.WriteLine("Select [ENTER]");
            Console.CursorTop  = 0;
            Console.CursorLeft = 58;
            Console.WriteLine("Home [ESC]");

            Console.CursorTop       = 27;
            Console.CursorLeft      = 0;
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.WriteLine(" Crt + S để lưu lại.");
            FormEditItemLH(selected, item);
            bool loop = true;

            while (loop)
            {
                ConsoleKeyInfo input;
                input = Console.ReadKey(true);
                if ((input.Modifiers & ConsoleModifiers.Control) != 0 && input.Key == ConsoleKey.S)
                {
                    bool flagSave;
                    flagSave = Form.FormXacNhan(10, 40, 5, 40, ChucNang);
                    if (flagSave)
                    {
                        loop = false;
                        ArrayLH.RemoveAt(index);
                        ArrayLH.Insert(index, item);
                        Console.Clear();
                        SuaLoaiHang(ref ArrayLH, ref ArrayHH, index);
                        return;
                    }
                    else
                    {
                        loop = false;
                        Console.ForegroundColor = ConsoleColor.Black;
                        Console.BackgroundColor = ConsoleColor.Gray;
                        Console.Clear();
                        SuaLH(ref ArrayLH, ref ArrayHH, ChucNang, index, selected);
                    }
                }
                switch (input.Key)
                {
                case ConsoleKey.UpArrow:
                    if (selected == 1)
                    {
                        selected = 3;
                    }
                    else
                    {
                        selected--;
                    }
                    BgSelectedItem(selected, ref item);
                    break;

                case ConsoleKey.DownArrow:
                    if (selected == 3)
                    {
                        selected = 1;
                    }
                    else
                    {
                        selected++;
                    }
                    BgSelectedItem(selected, ref item);
                    break;

                case ConsoleKey.Enter:
                    Console.CursorVisible = true;
                    item = EditItem(selected, ref item);
                    selected++;
                    BgSelectedItem(selected, ref item);
                    break;

                case ConsoleKey.Escape:
                    loop = false;
                    Console.CursorVisible = false;
                    Tittle.TieuDe();
                    Select.LuaChonChinh(ref ArrayHH, ref ArrayLH, 0);
                    break;

                default:
                    break;
                }
            }
        }