void LuuFileNV_CoThongBao(DSNV DSNV) { Menu.TaoHeader(8, "Luu File"); Console.WriteLine(" 1. Co 2. Khong\n"); int y = Menu.HoiYeuCau(2, "Luu danh sach hien tai: "); if (y == 1) { if (DSNV.KiemTraFile(pathSaveFileNV) == -1) { Program.XuatMauTrang("\n >> Ban co muon tao file moi khong\n"); Console.Write(" 1. Co 2. Khong\n"); int LuaChon = Menu.HoiYeuCau(2, "Tra loi: "); if (LuaChon == 1) { DSNV.LuuFile(pathSaveFileNV); } } else if (DSNV.KiemTraFile(pathSaveFileNV) == 1) { Program.XuatMauTrang("\n File hien tai dang chua du lieu\n"); Program.XuatMauTrang("\n >> Ban co muon thay the du lieu cu khong\n"); Console.Write(" 1. Co 2. Khong\n"); int LuaChon = Menu.HoiYeuCau(2, "Tra loi: "); if (LuaChon == 1) { DSNV.LuuFile(pathSaveFileNV); } } else { DSNV.LuuFile(pathSaveFileNV); } } }
void KhoiDong(DSNV DSNV, DanhSachSK DSSK) { Console.CursorVisible = false; ThietLapUI(); KiemTraFileSave(DSNV, DSSK); Console.CursorVisible = true; }
void LuuFileNV(DSNV DSNV) { List <string> DSdem = new List <string>(); foreach (NhanVien nv in DSNV.DanhSachNV) { DSdem.Add(nv.ToStringFile()); } File.WriteAllLines(pathSaveFileNV, DSdem); tinhTrangLuuDSSK = true; }
void KiemTraFileSave(DSNV DSNV, DanhSachSK DSSK) { try { DSNV.DocFile(pathSaveFileNV); DSSK.ThemTuFile(pathSaveFileSK); } catch { Console.SetCursorPosition(42, 6); XuatMauDo(" Tai file luu that bai!"); Thread.Sleep(3000); } }
static void Main() { Program chuongTrinh = new Program(); Menu menu = new Menu(); DSNV DSNV = new DSNV(); DanhSachSK DSSK = new DanhSachSK(); chuongTrinh.KhoiDong(DSNV, DSSK); while (true) { if (!chuongTrinh.ChuyenMenu(menu)) { chuongTrinh.ChayChucNang(menu.ID, DSNV, DSSK); menu.LuiMenuID(); } } }
public void ThoatChuongTrinhCoLuu(DSNV DSNV, DanhSachSK DSSK) { try { if (!tinhTrangLuuDSNV) { LuuFileNV(DSNV); } if (!tinhTrangLuuDSSK) { LuuFileSK(DSSK); } XuatMauXanh(" Luu thanh cong!\n"); } catch { XuatMauDo(" Luu that bai!\n"); } ThongBaoKetThucChucNang("Nhan phim bat ki de thoat"); Environment.Exit(0); }
void ChayChucNang(string ID, DSNV DSNV, DanhSachSK DSSK) { if (ID[ID.Length - 1] == 'x') { ThoatChuongTrinhCoLuu(DSNV, DSSK); } Console.Clear(); Console.WriteLine(); if (ID[0] == '1') { ChayChucNangNhanVien(ID, DSNV); } else if (ID[0] == '2') { ChayChucNangSuKien(ID, DSSK); } ThongBaoKetThucChucNang("Nhan phim bat ki de tiep tuc"); }
void ChayChucNangNhanVien(string ID, DSNV DSNV) { switch (ID) { case "111": DSNV.Them(); break; case "112": DSNV.NhapDuongDanDocFile(); break; case "12": DSNV.Xoa(); break; case "13": DSNV.Sua(); break; case "141": DSNV.TimNhanVienTheoID(); break; case "142": DSNV.TimNhanVienTheoTen(); break; case "143": DSNV.TimNhanVienTheoGioiTinh(); break; case "144": DSNV.TimNhanVienTheoViTri(); break; case "151": DSNV.XuatDanhSach_ThongBao(); break; case "152": DSNV.XuatDanhSach_ChiTiet_ThongBao(); break; case "153": DSNV.XuatDanhSach_ID_TangDan(); break; case "154": DSNV.XuatDanhSach_Ten_BangChuCai(); break; case "155": DSNV.XuatDanhSach_Luong_TangDan(); break; case "16": LuuFileNV_CoThongBao(DSNV); break; default: ThongBaoChucNangKhongTonTai(); break; } KiemtraThayDoiDuLieuDSNV(ID); }