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 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 void Update(string oldID, ThuNgan newThuNgan, Database database) { ThuNgan thuNgan = ThuNgan.Find(oldID, database); thuNgan.Copy(newThuNgan); }
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 Delete(string iD, Database database) { database.ThuNgans.Remove(ThuNgan.Find(iD, database)); }