Esempio n. 1
0
 public static void QLHDTN(Database database)
 {
     while (true)
     {
         Console.Clear();
         ConsoleView.Menu("0:Thoat", "1:them", "2:Thuc uong da dc trong hoa don");
         HoaDon.PrintTable(database);
         Console.Write("chon mode:");
         string i = Console.ReadLine();
         if (i == "0")
         {
             break;
         }
         if (i == "1")
         {
             string id = NhapTaoID("HoaDon", database);
             if (id == string.Empty)
             {
                 continue;
             }
             string idban = NhapXoaID("Ban", database);
             if (idban == string.Empty)
             {
                 continue;
             }
             string idnv = NhapXoaID("NhanVien", database);
             if (idnv == string.Empty)
             {
                 continue;
             }
             List <ThucUong> thucUongs = new List <ThucUong>();
             string          idTu      = "";
             while (true)
             {
                 idTu = NhapXoaID("ThucUong", database);
                 if (idTu == string.Empty)
                 {
                     continue;
                 }
                 if (idTu == "stop")
                 {
                     break;
                 }
                 thucUongs.Add(ThucUong.Find(idTu, database));
             }
             HoaDon.Add(new HoaDon(id, DateTime.Now, Ban.Find(idban, database), NhanVien.Find(idnv, database), thucUongs), database);
         }
         if (i == "2")
         {
             string id = NhapXoaID("HoaDon", database);
             if (id == string.Empty)
             {
                 continue;
             }
             HoaDon hoaDon = HoaDon.Find(id, database);
             hoaDon.ThucUongs.ForEach(t => Console.WriteLine("-matu:{0}  |ten:{1} |loai:{2}", t.ID, t.TenThucUong, t.LoaiThuocUong));
             Console.Read();
         }
     }
 }
Esempio n. 2
0
 public static void Add(HoaDon hoaDon, Database database)
 {
     database.HoaDons.Add(hoaDon);
     Ban.Find(hoaDon.Ban.MaBan, database).HoaDons.Add(hoaDon);
     NhanVien.Find(hoaDon.NhanVien.GetID(), database).HoaDons.Add(hoaDon);
     hoaDon.ThucUongs.ForEach(t => ThucUong.Find(t.ID, database).HoaDons.Add(hoaDon));
     hoaDon.ThucUongs.ForEach(t => ThucUong.Find(t.ID, database).SoLuong--);
 }
Esempio n. 3
0
        public static void Delete(string ID, Database database)
        {
            var hoadon = Find(ID, database);

            database.HoaDons.Remove(hoadon);
            Ban.Find(hoadon.Ban.MaBan, database).HoaDons.Remove(hoadon);
            NhanVien.Find(hoadon.NhanVien.GetID(), database).HoaDons.Remove(hoadon);
            hoadon.ThucUongs.ForEach(t => ThucUong.Find(t.ID, database).HoaDons.Remove(hoadon));
        }
Esempio n. 4
0
        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);
                }
            }
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public static void QLPC(Database database)
        {
            while (true)
            {
                Console.Clear();
                ConsoleView.Menu("0:Thoat", "1:xoa", "2:them", "3:sua");
                PhanCong.PrintTable(database.PhanCongs);
                Console.Write("chon mode:");
                string i = Console.ReadLine();
                if (i == "0")
                {
                    break;
                }
                if (i == "1")
                {
                    string idnv = NhapXoaID("NhanVien", database);
                    if (idnv == string.Empty)
                    {
                        continue;
                    }
                    string idb = NhapXoaID("Ban", database);
                    if (idb == string.Empty)
                    {
                        continue;
                    }
                    if (PhanCong.Find(idnv, idb, database) == null)
                    {
                        continue;
                    }
                    PhanCong.Delete(idnv, idb, database);
                }
                if (i == "2")
                {
                    string ID = NhapXoaID("NhanVien", database);
                    if (ID == string.Empty)
                    {
                        continue;
                    }
                    string idban = NhapXoaID("Ban", database);
                    if (idban == string.Empty)
                    {
                        continue;
                    }
                    if (Ban.Find(idban, database).PhanCong.NhanVien != null)
                    {
                        Console.WriteLine("Ban Nay Da Co NV Phu Trach");
                        Console.Read();
                        continue;
                    }
                    if (PhanCong.Find(ID, idban, database) != null)
                    {
                        Console.WriteLine("Da Ton Tai Phan Cong Nay");
                        Console.Read();
                        continue;
                    }

                    Console.Write("Nhap ca lam");
                    string ca = Console.ReadLine();
                    PhanCong.Add(new PhanCong(NhanVien.Find(ID, database), Ban.Find(idban, database), ca, DateTime.Now), database);
                }
                if (i == "3")
                {
                    string ID = NhapXoaID("NhanVien", database);
                    if (ID == string.Empty)
                    {
                        continue;
                    }
                    string idban = NhapXoaID("Ban", database);
                    if (idban == string.Empty)
                    {
                        continue;
                    }
                    if (PhanCong.Find(ID, idban, database) == null)
                    {
                        Console.WriteLine("Khong ton tai phan khong nay");
                        Console.Read();
                        continue;
                    }
                    Console.Write("nhap ca lam:");
                    string ca = Console.ReadLine();
                    PhanCong.Update(ID, idban, new PhanCong(NhanVien.Find(ID, database), Ban.Find(idban, database), ca, DateTime.Now), database);
                }
            }
        }
Esempio n. 7
0
        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);
                }
            }
        }
Esempio n. 8
0
 public static void Delete(string maNV, string maBan, Database database)
 {
     database.PhanCongs.Remove(Find(maNV, maBan, database));
     NhanVien.Find(maNV, database).PhanCongs.Remove(Find(maNV, maBan, database));
     Ban.Find(maBan, database).PhanCong = null;
 }
Esempio n. 9
0
 public static void Add(PhanCong phanCong, Database database)
 {
     database.PhanCongs.Add(phanCong);
     NhanVien.Find(phanCong.NhanVien.GetID(), database).PhanCongs.Add(phanCong);
     Ban.Find(phanCong.Ban.MaBan, database).PhanCong = phanCong;
 }