public override void Copy(object ojb) { ThuNgan thuNgan = ojb as ThuNgan; ID = thuNgan.ID; HoTen = thuNgan.HoTen; NgaySinh = thuNgan.NgaySinh; MatKhau = thuNgan.MatKhau; }
public static string NhapTaoID(string table, Database database) { int i = 0; while (true) { Console.Write("nhap Id:"); string ID = Console.ReadLine(); switch (table) { case "NhanVien": if (NhanVien.Find(ID, database) == null) { return(ID); } break; case "HoaDon": if (HoaDon.Find(ID, database) == null) { return(ID); } break; case "ThucUong": if (ThucUong.Find(ID, database) == null) { return(ID); } break; case "ThuNgan": if (ThuNgan.Find(ID, database) == null) { return(ID); } break; case "Ban": if (Ban.Find(ID, database) == null) { return(ID); } break; default: break; } Console.WriteLine("Id da ton tai"); if (++i == 3) { return(string.Empty); } } }
public static void QLTN(Database database) { while (true) { Console.Clear(); ConsoleView.Menu("0:Thoat", "1:xoa", "2:them", "3:sua"); ThuNgan.PrintTable(database.ThuNgans); Console.Write("chon mode:"); string i = Console.ReadLine(); if (i == "0") { break; } if (i == "1") { string ID = NhapXoaID("ThuNgan", database); if (ID == string.Empty) { continue; } ThuNgan.Delete(Console.ReadLine(), database); } if (i == "2") { string ID = NhapXoaID("ThuNgan", database); if (ID == string.Empty) { continue; } Console.Write("nhap Ho Ten:"); string hoten = Console.ReadLine(); Console.Write("nhap MK:"); string mk = Console.ReadLine(); Console.Write("nhap ngay sinh:(nam/thang/ngay)"); DateTime dateTime = Convert.ToDateTime(Console.ReadLine()); ThuNgan.Add(new ThuNgan(ID, hoten, dateTime, mk), database); } if (i == "3") { string ID = NhapXoaID("ThuNgan", database); if (ID == string.Empty) { continue; } Console.Write("nhap Ho Ten:"); string hoten = Console.ReadLine(); Console.Write("nhap MK:"); string mk = Console.ReadLine(); Console.Write("nhap ngay sinh:(nam/thang/ngay)"); DateTime dateTime = Convert.ToDateTime(Console.ReadLine()); ThuNgan.Update(ID, new ThuNgan(ID, hoten, dateTime, mk), database); } } }
public static void TaoDuLieu(Database database) { Ban.Add(new Ban("ban01", 3, new PhanCong(), new List <HoaDon>()), database); Ban.Add(new Ban("ban02", 2, new PhanCong(), new List <HoaDon>()), database); NhanVien.Add(new NhanVien("nv01", "Minh Duc", DateTime.Now), database); NhanVien.Add(new NhanVien("nv02", "Thanh Long", DateTime.Now), database); PhanCong.Add(new PhanCong(NhanVien.Find("nv01", database), Ban.Find("ban01", database), "ca4", DateTime.Now), database); PhanCong.Add(new PhanCong(NhanVien.Find("nv02", database), Ban.Find("ban02", database), "ca4", DateTime.Now), database); QuanLy.Add(new QuanLy("ql01", "Thanh Lam", DateTime.Now, "123123"), database); ThuNgan.Add(new ThuNgan("tn01", "Hieu Vo", DateTime.Now, "123123"), database); ThucUong.Add(new ThucUong("tu01", "Bia Sai Gon", "Co Con", 100, 200000), database); ThucUong.Add(new ThucUong("tu02", "Sinh To Buoi", "Sinh To", 20, 40000), database); ThucUong.Add(new ThucUong("tu03", "cocacola", "nuoc ngot", 100, 20000), database); List <ThucUong> thucUongs = new List <ThucUong>(); thucUongs.Add(ThucUong.Find("tu01", database)); thucUongs.Add(ThucUong.Find("tu02", database)); List <ThucUong> thucUongs2 = new List <ThucUong>(); thucUongs2.Add(ThucUong.Find("tu01", database)); HoaDon.Add(new HoaDon("hd01", DateTime.Now, Ban.Find("ban01", database), NhanVien.Find("nv01", database), thucUongs), database); HoaDon.Add(new HoaDon("hd02", DateTime.Now, Ban.Find("ban02", database), NhanVien.Find("nv02", database), thucUongs2), database); }
public static string DangNhap(Database database) { Console.Clear(); string cv; string ID; string MK; int sls = 0; while (true) { Console.Write("Ban la (ql hay tn|nhap -1 de tac phan men):"); cv = Console.ReadLine(); if (cv == "-1") { return(cv); } if (cv == "ql" || cv == "tn") { break; } else { Console.WriteLine("Khong hop le"); } } if (cv == "ql") { while (true) { Console.Write("ID:"); ID = Console.ReadLine(); if (QuanLy.Find(ID, database) == null) { Console.WriteLine("ID khong ton tai"); if (++sls == 3) { return(null); } } else { break; } } while (true) { Console.Write("Mat Khau:"); MK = Console.ReadLine(); QuanLy quanLy = QuanLy.Find(ID, database); if (QuanLy.Find(ID, database).MatKhau != MK) { Console.WriteLine("Sai Mat Khau"); if (++sls == 3) { return(null); } } else { break; } } return(cv); } while (true) { Console.Write("ID:"); ID = Console.ReadLine(); if (ThuNgan.Find(ID, database) == null) { Console.WriteLine("ID khong ton tai"); if (++sls == 3) { return(null); } } else { break; } } while (true) { Console.Write("Mat Khau:"); MK = Console.ReadLine(); if (ThuNgan.Find(ID, database).MatKhau != MK) { Console.WriteLine("Sai Mat Khau"); if (++sls == 3) { return(null); } } else { break; } } return(cv); }
public static string NhapXoaID(string table, Database database) { int i = 0; string ID; while (true) { switch (table) { case "NhanVien": Console.Write("nhap Id nhan vien:"); ID = Console.ReadLine(); if (NhanVien.Find(ID, database) != null) { return(ID); } break; case "HoaDon": Console.Write("nhap Id hoa don:"); ID = Console.ReadLine(); if (HoaDon.Find(ID, database) != null) { return(ID); } break; case "ThucUong": Console.Write("nhap Id thuc uong (nhap 'stop' de dung lai):"); ID = Console.ReadLine(); if (ThucUong.Find(ID, database) != null) { return(ID); } if (ID == "stop") { return("stop"); } break; case "ThuNgan": Console.Write("nhap Id thu ngan:"); ID = Console.ReadLine(); if (ThuNgan.Find(ID, database) != null) { return(ID); } break; case "Ban": Console.Write("nhap Id ban:"); ID = Console.ReadLine(); if (Ban.Find(ID, database) != null) { return(ID); } break; default: break; } Console.WriteLine("Id khong ton tai"); if (++i == 3) { return(string.Empty); } } }
public static void Update(string oldID, ThuNgan newThuNgan, Database database) { ThuNgan thuNgan = ThuNgan.Find(oldID, database); thuNgan.Copy(newThuNgan); }
public static void Delete(string iD, Database database) { database.ThuNgans.Remove(ThuNgan.Find(iD, database)); }
public static void Add(ThuNgan thuNgan, Database database) { database.ThuNgans.Add(thuNgan); }