//---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; } }
// form propestise find public static void FormCommonFind(string Tittle, int index) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); string blank = " "; string boder = "|"; int hang = 10; int cot = 25; int left = 40; int top = 5; for (int i = 1; i < hang; i++) { if (i == 1 || i == 2 || i == 3) { Console.BackgroundColor = ConsoleColor.Cyan; } else { Console.BackgroundColor = ConsoleColor.White; } Console.CursorTop = top + i - 1; Console.CursorLeft = left - 1; Console.Write(boder); for (int j = 1; j < cot; j++) { Console.CursorTop = top + i - 1; Console.CursorLeft = left + j - 1; Console.Write(blank); } Console.Write(boder); Console.WriteLine(); } Console.CursorTop = top + 1; Console.CursorLeft = left + 2; Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.Cyan; Console.Write("{0}?", Tittle); Console.CursorLeft = 0; Console.CursorTop = 0; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" Để thoát chon ESC"); // chuc năng trong tim kiem Arch_HH(1); ArrayList ArrayHH = Program.DuLieuMauHangHoa(); ArrayList ArrayLH = Program.DuLieuMauLoaiHang(); int selected = OptionFind(); if (Tittle == "Hàng Hóa") { if (selected == 1) { //sửa Console.Clear(); Edit.SuaHH(ref ArrayHH, ref ArrayLH, "Edit HH", selected, 1); } if (selected == 2) { //xóa Console.Clear(); Delete.XoaHH(ref ArrayHH, ref ArrayLH, "Delete HH", selected); } if (selected == -1) { //back main Program.AppMain(); } } if (Tittle == "Loại Hàng") { if (selected == 1) { //sửa Console.Clear(); EditLH.SuaLH(ref ArrayLH, ref ArrayHH, "Edit HH", selected, 1); } if (selected == 2) { //xóa Console.Clear(); DeleteLH.XoaLH(ref ArrayLH, ref ArrayHH, "Delete HH", selected, 1); } if (selected == -1) { //back main Program.AppMain(); } } // lựa chon chưc nang }
// 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; } } }