Ejemplo n.º 1
0
        public static void AppMain()
        {
            Console.CursorVisible = false;
            ArrayList ArrayHH = DuLieuMauHangHoa();
            ArrayList ArrayLH = DuLieuMauLoaiHang();

            Console.OutputEncoding = Encoding.Unicode;
            Console.InputEncoding  = Encoding.Unicode;
            Tittle.TieuDe();
            Select.LuaChonChinh(ref ArrayHH, ref ArrayLH, 0);
        }
Ejemplo n.º 2
0
        // điều hướng
        public static void DieuHuong(ref ArrayList ArrayHH, ref ArrayList ArrayLH)
        {
            Console.CursorTop  = 5;
            Console.CursorLeft = 40;
            Console.WriteLine("Để quay lại trang chính chọn BACKSPACE");
            Console.CursorTop  = 6;
            Console.CursorLeft = 40;
            Console.WriteLine("Để thêm sản phẩm mới chọn ENTER");
            Console.CursorTop  = 7;
            Console.CursorLeft = 40;
            Console.WriteLine("Để thoát chon ESC");
            Console.CursorTop  = 8;
            Console.CursorLeft = 40;
            ConsoleKeyInfo input;

            input = Console.ReadKey(true);
            switch (input.Key)
            {
            case ConsoleKey.Escape:
                break;

            case ConsoleKey.Enter:
                Console.CursorVisible   = true;
                Console.BackgroundColor = ConsoleColor.Gray;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.Clear();
                ThemHangHoa(ref ArrayHH, ref ArrayLH);
                break;

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

            default:
                Console.CursorVisible = false;
                DieuHuong(ref ArrayHH, ref ArrayLH);
                break;
            }
        }
Ejemplo n.º 3
0
        public static void TimKiemHangHoa(ArrayList ArrayHH, ArrayList ArrayLH)
        {
            Console.CursorVisible = true;
            string    keySearch = " ";
            ArrayList ArrayFind = new ArrayList();

            ArrayFind.Clear();
            Form.FormTimKiem("TÌM KIẾM HÀNG HÓA!");
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkYellow;
            Console.CursorTop       = 4;
            Console.CursorLeft      = 2;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BackgroundColor = ConsoleColor.White;
            keySearch = Console.ReadLine();
            ArrayFind = FindHH(ArrayHH, keySearch);
            HienThiHangHoaTimKiem(ArrayFind, ArrayLH, "Danh sách hàng hóa");
            Console.CursorTop  = 4;
            Console.CursorLeft = 2;
            ConsoleKeyInfo input;

            input = Console.ReadKey(true);
            switch (input.Key)
            {
            case ConsoleKey.Escape:

                Console.CursorVisible = false;
                Tittle.TieuDe();
                Select.LuaChonChinh(ref ArrayHH, ref ArrayLH, 0);
                break;

            case ConsoleKey.Enter:
                Console.CursorVisible = false;
                Console.Clear();
                TimKiemHangHoa(ArrayHH, ArrayLH);
                break;
            }
        }
Ejemplo n.º 4
0
        // sửa lại thêm laoij hang
        public static void ThemLoaiHang(ref ArrayList ArrayLH, ref ArrayList ArrayHH)
        {
            Console.CursorVisible = false;
            Form.FormLoaiHang("THÊM LOẠI HÀNG");
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BackgroundColor = ConsoleColor.DarkYellow;
            Console.CursorTop       = 0;
            Console.CursorLeft      = 0;
            Console.WriteLine("THÊM LOẠI HÀNG |");
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("--------------*");
            Console.CursorTop       = 0;
            Console.CursorLeft      = 37;
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(" Nhập [ENTER] ");
            Console.CursorTop       = 0;
            Console.CursorLeft      = 56;
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(" Home [ESC] ");
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.ForegroundColor = ConsoleColor.Black;
            ConsoleKeyInfo input;

            input = Console.ReadKey(true);
            if (input.Key == ConsoleKey.Escape)
            {
                Program.AppMain();
            }
            else
            {
                Console.CursorVisible = true;
                Console.CursorTop     = 0;
                Console.CursorLeft    = 37;
                Console.WriteLine("               ");
                Console.CursorTop  = 0;
                Console.CursorLeft = 56;
                Console.WriteLine("                ");
                Struct.LOAIHANG LH;
                Add.InputHH(1, 2, "");
                LH.MaLH = Console.ReadLine();
                Add.InputHH(2, 2, "");
                LH.TenLH = Console.ReadLine();
                Add.InputHH(3, 2, "");
                LH.MotaLH = Console.ReadLine();
                bool flag;
                flag = Form.FormXacNhan(10, 40, 5, 40, "Save LH");
                if (flag)
                {
                    ArrayLH.Add(LH);
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("Bạn đã lưu thành công!");
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Tittle.TieuDe();
                    Select.LuaChonChinh(ref ArrayHH, ref ArrayLH, 4);
                }
                else
                {
                    Console.BackgroundColor = ConsoleColor.Gray;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Console.Clear();
                    ThemLoaiHang(ref ArrayLH, ref ArrayHH);
                }
            }
        }
Ejemplo n.º 5
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;
                }
            }
        }
Ejemplo n.º 6
0
        public static void ThemHangHoa(ref ArrayList ArrayHH, ref ArrayList ArrayLH)
        {
            Console.CursorVisible = false;
            Form.FormHangHoa("THÊM HÀNG HÓA");
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BackgroundColor = ConsoleColor.DarkYellow;
            Console.CursorTop       = 0;
            Console.CursorLeft      = 0;
            Console.WriteLine(" THÊM HÀNG HÓA |");
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("--------------*");
            Console.CursorTop       = 0;
            Console.CursorLeft      = 37;
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(" Nhập [ENTER] ");
            Console.CursorTop       = 0;
            Console.CursorLeft      = 56;
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(" Home [ESC] ");
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.ForegroundColor = ConsoleColor.Black;
            ConsoleKeyInfo input;

            input = Console.ReadKey(true);
            if (input.Key == ConsoleKey.Escape)
            {
                Program.AppMain();
            }
            else
            {
                Console.CursorVisible = true;
                Console.CursorTop     = 0;
                Console.CursorLeft    = 37;
                Console.WriteLine("                 ");
                Console.CursorTop  = 0;
                Console.CursorLeft = 56;
                Console.WriteLine("                  ");
                Struct.HOANGHOA SP;
                InputHH(1, 2, "Mã hàng hóa:");
                SP.MaHH = Console.ReadLine();
                InputHH(2, 2, "Tên hàng hóa:");
                SP.TenHH = Console.ReadLine();
                int ngay = 0, thang = 0, nam = 0;
                NhapNgayThangNam(ref ngay, ref thang, ref nam, 3, 1);
                SP.HanDung.Ngay         = ngay;
                SP.HanDung.Nam          = nam;
                SP.HanDung.Thang        = thang;
                Console.BackgroundColor = ConsoleColor.Gray;
                Console.ForegroundColor = ConsoleColor.Black;
                InputHH(4, 2, "Công ty sản xuất:                               ");
                SP.CtySX = Console.ReadLine();
                InputHH(5, 1, "Năm xản xuât");
                int namSX = 0;
                Console.CursorLeft = 2;
                SP.NamSX           = NhapInt(namSX, "Năm Sản Xuất", 20, 2);
                Add.InputHH(6, 2, "Loại hàng hóa:      ");
                SP.LoaiHang = Console.ReadLine();
                bool flag;
                flag = Form.FormXacNhan(10, 40, 5, 40, "Save HH");
                if (flag)
                {
                    ArrayHH.Add(SP);
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("Bạn đã lưu thành công!");
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Tittle.TieuDe();
                    Select.LuaChonChinh(ref ArrayHH, ref ArrayLH, 0);
                }
                else
                {
                    Console.BackgroundColor = ConsoleColor.Gray;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Console.Clear();
                    ThemHangHoa(ref ArrayHH, ref ArrayLH);
                }
            }
        }
Ejemplo n.º 7
0
        //---switch dieu huong
        static void inputSeclect(ref ArrayList ArrayHH, ref ArrayList ArrayLH, int stt, int select, string ChucNang)
        {
            ConsoleKeyInfo input;

            input = Console.ReadKey(true);
            int top = 0;

            if (ChucNang == "Find HH")
            {
                top = 6;
            }
            switch (input.Key)
            {
            case ConsoleKey.UpArrow:
                if (select == 0)
                {
                    HienThi(ArrayHH, stt, select, top);
                    inputSeclect(ref ArrayHH, ref ArrayLH, stt, select, ChucNang);
                }
                else
                {
                    select--;
                    HienThi(ArrayHH, stt, select, top);
                    inputSeclect(ref ArrayHH, ref ArrayLH, stt, select, ChucNang);
                }
                return;

            case ConsoleKey.DownArrow:
                if (select == ArrayHH.Count - 1)
                {
                    HienThi(ArrayHH, stt, select, top);
                    inputSeclect(ref ArrayHH, ref ArrayLH, stt, select, ChucNang);
                }
                else
                {
                    select++;
                    HienThi(ArrayHH, stt, select, top);
                    inputSeclect(ref ArrayHH, ref ArrayLH, stt, select, ChucNang);
                }
                return;

            case ConsoleKey.Enter:
                switch (ChucNang)
                {
                case "Delete HH":
                    Console.CursorVisible = false;
                    Delete.XoaHH(ref ArrayHH, ref ArrayLH, ChucNang, select);
                    return;

                case "Edit HH":
                    Console.CursorVisible = true;
                    Console.Clear();
                    Edit.SuaHH(ref ArrayHH, ref ArrayLH, ChucNang, select, 1);
                    return;
                    // case "Find HH":
                    //  Form.FormCommonFind("Hang hoa");
                    //  return;
                }
                return;

            case ConsoleKey.Escape:
                Console.CursorVisible = false;
                Tittle.TieuDe();
                int index = 0;
                if (ChucNang == "Delete HH")
                {
                    index = 2;
                }
                if (ChucNang == "Edit HH")
                {
                    index = 1;
                }
                Select.LuaChonChinh(ref ArrayHH, ref ArrayLH, index);
                break;

            default:
                inputSeclect(ref ArrayHH, ref ArrayLH, stt, select, ChucNang);
                break;
            }
        }
Ejemplo n.º 8
0
        //
        public static void inputSeclectFind(ArrayList ArrayHH, ArrayList ArrayLH, int stt, int select, string ChucNang)
        {
            ConsoleKeyInfo input;
            int            top = 0;

            if (ChucNang == "Find HH" || ChucNang == "Find LH" || ChucNang == "Find")
            {
                top = 6;
            }
            while (true)
            {
                input = Console.ReadKey(true);
                switch (input.Key)
                {
                case ConsoleKey.UpArrow:
                    if (select == 0)
                    {
                        HienThi(ArrayHH, stt, select, top); break;
                    }
                    else
                    {
                        select--;
                        HienThi(ArrayHH, stt, select, top); break;
                    }

                case ConsoleKey.DownArrow:
                    if (select == ArrayHH.Count - 1)
                    {
                        HienThi(ArrayHH, stt, select, top); break;
                    }
                    else
                    {
                        select++;
                        HienThi(ArrayHH, stt, select, top); break;
                    }

                case ConsoleKey.Enter:
                    switch (ChucNang)
                    {
                    case "Delete HH":
                        Console.CursorVisible = false;
                        Delete.XoaHH(ref ArrayHH, ref ArrayLH, ChucNang, select);
                        return;

                    case "Edit HH":
                        Console.CursorVisible = true;
                        Console.Clear();
                        Edit.SuaHH(ref ArrayHH, ref ArrayLH, ChucNang, select, 1);
                        return;

                    case "Find HH":
                        Console.CursorVisible = true;
                        Form.FormCommonFind("Hàng Hóa", select);
                        return;

                    case "Find LH":
                        return;
                    }
                    return;

                case ConsoleKey.Escape:
                    Console.CursorVisible = false;
                    Tittle.TieuDe();
                    ArrayHH = Program.DuLieuMauHangHoa();
                    ArrayLH = Program.DuLieuMauLoaiHang();
                    Select.LuaChonChinh(ref ArrayHH, ref ArrayLH, 3);
                    break;

                default:
                    inputSeclect(ref ArrayHH, ref ArrayLH, stt, select, ChucNang);
                    break;
                }
            }
        }