Ejemplo n.º 1
0
        public void suaphong()
        {
            Console.Clear();
            Console.WriteLine("SUA THONG TIN PHONG");
            List <Phongkt> list = pbll.LPhong();
            string         map;

            Console.Write("Nhap ma san pham can sua:");
            map = Console.ReadLine();
            int i = 0;

            for (i = 0; i < list.Count; ++i)
            {
                if (list[i].Maph == map)
                {
                    break;
                }
            }

            if (i < list.Count)
            {
                Phongkt p = new Phongkt(list[i]);
                Console.Write("Nhap ten day:");
                string day = Console.ReadLine();
                if (!string.IsNullOrEmpty(day))
                {
                    p.Tenday = day;
                }
                Console.Write("Nhap so luong nguoi o moi");
                int sno = int.Parse(Console.ReadLine());
                if (sno > 0)
                {
                    p.Dango = sno;
                }
                Console.WriteLine("Tinh trang phong");
                string ttp = Console.ReadLine();
                if (!string.IsNullOrEmpty(ttp))
                {
                    p.Tinhtrang = ttp;
                }
                pbll.suaphong(p);
            }
            else
            {
                Console.WriteLine("Khong ton tai ma san pham nay");
            }

            gd.pain("ẤN TAB ĐỂ QUAY LẠI MENU PHÒNG", 20, 47);
            ConsoleKeyInfo kt = Console.ReadKey();

            switch (kt.Key)
            {
            case ConsoleKey.F2: Console.Clear(); suaphong(); break;

            case ConsoleKey.Tab: Console.Clear(); menuphong(); break;

            default:
                return;
            }
        }
Ejemplo n.º 2
0
        public Phongkt PH(string p)
        {
            p = congcu.catxau(p);
            string[] tmp = p.Split("#");
            Phongkt  t   = new Phongkt(tmp[0], tmp[1], int.Parse(tmp[2]), int.Parse(tmp[3]), tmp[4]);

            return(t);
        }
Ejemplo n.º 3
0
        public void themphong(Phongkt p)
        {
            StreamWriter fwrite = File.AppendText(ptxtflie);

            fwrite.WriteLine();
            fwrite.Write(p.Maph + "#" + p.Tenday + "#" + p.Soluongmax + "#" + p.Dango + "#" + p.Tinhtrang);
            fwrite.Close();
        }
Ejemplo n.º 4
0
        public void writefile(string filename, Phongkt t)
        {
            FileStream   fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);

            sw.Write(Phong(t));
            sw.Close();
            fs.Close();
        }
Ejemplo n.º 5
0
 public void themphong(Phongkt p)
 {
     if (!string.IsNullOrEmpty(p.Maph))
     {
         pdal.themphong(p);
     }
     else
     {
         throw new Exception("du lieu sai");
     }
 }
Ejemplo n.º 6
0
        public void themphong(Phongkt p)
        {
            list <Phongkt> ph = PDAL.readlist("Data/Phong.txt");
            Node <Phongkt> tg = ph.Head;

            p.Tenday = congcu.chuanhoaxau(p.Tenday);
            p.Maph   = congcu.chuanhoaxau(p.Maph);
            p.Maph   = congcu.chuanhoaxau(p.Maph);
            ph.addhead(p);
            PDAL.writelist("Data/Phong.txt", ph);
        }
Ejemplo n.º 7
0
        public void timphong()
        {
            Console.WriteLine();
            List <Phongkt> list = pbll.LPhong();

            gd.pain("TÌM KIẾM THÔNG TIN PHÒNG", 35, 3);
            string maph; gd.pain("Nhập mã phòng cần tìm :", 20, 5);

            do
            {
                gd.ve(49, 5); maph = Console.ReadLine();
            } while (string.IsNullOrEmpty(maph));
            int i;

            for (i = 0; i < list.Count; i++)
            {
                if (list[i].Maph == maph)
                {
                    break;
                }
            }
            if (i < list.Count)
            {
                Phongkt ph = new Phongkt(list[i]);
                Console.WriteLine("\n\n");
                Console.WriteLine("THÔNG TIN PHÒNG  MUỐN TÌM");
                gd.pain("MÃ PHÒNG :", 14, 13); gd.ve(34, 13); Console.WriteLine(list[i].Maph);
                gd.pain("TÊN DÃY  :", 14, 15);; gd.ve(34, 15); Console.WriteLine(list[i].Tenday);
                gd.pain("SỐ LƯỢNG TỐI ĐA:", 14, 17);; gd.ve(34, 17); Console.WriteLine(list[i].Soluongmax);
                gd.pain("ĐANG Ở HIỆN TẠI:", 14, 19); gd.ve(34, 19); Console.WriteLine(list[i].Dango);
                gd.pain("TÌNH TRẠNG:", 14, 21); gd.ve(34, 21); Console.WriteLine(list[i].Tinhtrang);
            }
            else
            {
                Console.WriteLine("không tồn tại mã phòng này");
            }
timhd:
            gd.pain("ẤN TAB ĐỂ QUAY LẠI MENU PHÒNG ", 20, 47);
            ConsoleKeyInfo kt = Console.ReadKey();

            switch (kt.Key)
            {
            case ConsoleKey.Tab: Console.Clear(); menuphong(); break;

            default:
                Console.WriteLine("sai thao tác! mời nhập lại");
                goto timhd;
            }
        }
Ejemplo n.º 8
0
        public void xoaphong()
        {
            Console.WriteLine("XOA THONG TIN PHONG");
            List <Phongkt> list = pbll.LPhong();
            string         map;

            Console.Write("nhập mã phòng muốn xóa");
            map = Console.ReadLine();
            int i = 0;

            for (i = 0; i < list.Count; ++i)
            {
                if (list[i].Maph == map)
                {
                    break;
                }
            }

            if (i < list.Count)
            {
                Phongkt p = new Phongkt(list[i]);
                pbll.xoaphong(map);
            }
            else
            {
                Console.WriteLine("Khong ton tai ma san pham nay");
            }
xoaphong:
            gd.pain("ẤN TAB ĐỂ QUAY LẠI MENU PHÒNG", 20, 47);
            ConsoleKeyInfo kt = Console.ReadKey();

            switch (kt.Key)
            {
            case ConsoleKey.F2: Console.Clear(); xoaphong(); break;

            case ConsoleKey.Tab: Console.Clear(); menuphong(); break;

            default:
                Console.WriteLine("sai thao tác! mời nhập lại");
                goto xoaphong;
            }
        }
Ejemplo n.º 9
0
        public Phongkt timtheoma(string maphong)
        {
            list <Phongkt> ph = PDAL.readlist("Data/Phong.txt");
            Node <Phongkt> tg = ph.Head;
            Phongkt        p  = new Phongkt();

            while (tg != null)
            {
                if (tg.Data.Maph == maphong)
                {
                    p = tg.Data;
                    break;
                }
                else
                {
                    tg = tg.Link;
                }
            }
            return(p);
        }
Ejemplo n.º 10
0
        public List <Phongkt> timphong(Phongkt p)
        {
            List <Phongkt> list = LPhong();
            List <Phongkt> tim  = new List <Phongkt>();

            if (string.IsNullOrEmpty(p.Maph) && string.IsNullOrEmpty(p.Tenday))
            {
                tim = list;
            }
            if (!string.IsNullOrEmpty(p.Maph))
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].Maph.IndexOf(p.Maph) >= 0)
                    {
                        tim.Add(new Phongkt(list[i]));
                    }
                }
            }
            return(tim);
        }
Ejemplo n.º 11
0
        public void suaphong(Phongkt p)
        {
            int            i;
            List <Phongkt> list = LPhong();

            for (i = 0; i < list.Count; i++)
            {
                if (list[i].Maph == p.Maph)
                {
                    break;
                }
            }
            if (i < list.Count)
            {
                list.RemoveAt(i);
                list.Add(p);
                pdal.Update(list);
            }
            else
            {
                throw new Exception("khong ton tai phong nay");
            }
        }
Ejemplo n.º 12
0
        public void themt()
        {
            Phongkt ph = new Phongkt();

            for (int i = 11; i < 25; ++i)
            {
                gd.pain("║", 7, i);
                gd.pain("║", 92, i);
            }
            gd.pain("╔════════════════════════════════════════════════════════════════════════════════════╗", 7, 10);
            gd.pain("╠═══════════════════════════════╬════════════════════════════════════════════════════╣", 7, 13);
            gd.pain("╠═══════════════════════════════╦════════════════════════════════════════════════════╣", 7, 16);
            gd.pain("╠═══════════════════════════════╦════════════════════════════════════════════════════╣", 7, 19);
            gd.pain("╠═══════════════════════════════╦════════════════════════════════════════════════════╣", 7, 22);

            for (int i = 11; i < 25; ++i)
            {
                gd.pain("║", 39, i);
            }
            gd.pain("╚═══════════════════════════════╩════════════════════════════════════════════════════╝", 7, 25);
            maph : gd.pain("", 60, 9);;
            try
            {
                Console.SetCursorPosition(9, 12); Console.WriteLine("Nhập mã phòng");

                Console.SetCursorPosition(50, 12); ph.Maph = Console.ReadLine();
            }
            catch
            {
                Console.SetCursorPosition(20, 40); Console.WriteLine("khong co thong tin mi nhap lai");
                goto maph;
            }

            tenday : gd.pain("", 50, 15);
            try
            {
                Console.SetCursorPosition(9, 15); Console.WriteLine("Nhập ten day");
                Console.SetCursorPosition(50, 15); ph.Tenday = Console.ReadLine();
            }
            catch
            {
                Console.SetCursorPosition(20, 40); Console.WriteLine("khong co thong tin mi nhap lai");
                goto tenday;
            }
            slmax : gd.pain("", 50, 18);
            try
            {
                Console.SetCursorPosition(9, 18); Console.WriteLine("Nhập sl hoc sinh max");
                Console.SetCursorPosition(50, 18); ph.Soluongmax = int.Parse(Console.ReadLine());
            }
            catch
            {
                Console.SetCursorPosition(20, 40); Console.WriteLine("không có dữ liệu hoặc dữ liệu là chữ,mời nhập lại");
                goto slmax;
            }
            dango : gd.pain("", 50, 21);
            try
            {
                Console.SetCursorPosition(9, 21); Console.WriteLine("Nhập sl hoc sinh đang ở");
                Console.SetCursorPosition(50, 21); ph.Dango = int.Parse(Console.ReadLine());
            }
            catch
            {
                Console.SetCursorPosition(20, 40); Console.WriteLine("không có dữ liệu hoặc dữ liệu là chữ,mời nhập lại");
                goto dango;
            }
            tinhtrang : gd.pain("", 50, 24);
            try
            {
                Console.SetCursorPosition(9, 24); Console.WriteLine("Cho biết trạng thái của  phòng");
                Console.SetCursorPosition(50, 24); ph.Tinhtrang = Console.ReadLine();
            }
            catch
            {
                Console.SetCursorPosition(20, 40); Console.WriteLine("không có dữ liệu ,mời nhập lại");
                goto tinhtrang;
            }
            pbll.themphong(ph);
            Console.SetCursorPosition(40, 30);
            gd.pain("F1", 20, 27); gd.pain("THÊM VÀ NHẬP TIẾP", 30, 27);
            gd.pain("F2", 20, 28); gd.pain("HIỆN THÔNG TIN", 30, 28);
            gd.pain("F3", 20, 29); gd.pain("TRỞ LẠI", 30, 29);
            Console.SetCursorPosition(40, 30);
            ConsoleKeyInfo kt = Console.ReadKey();

n:
            switch (kt.Key)
            {
            case ConsoleKey.F1: pbll.themphong(ph); Console.Clear(); themt(); Console.Clear(); break;

            case ConsoleKey.F2: Console.Clear(); hien(); break;

            case ConsoleKey.F3: Console.Clear(); menuphong(); break;

            default:
                Console.WriteLine("sai thao tác!!! mời nhập lại"); Console.SetCursorPosition(40, 30);
                goto n;
            }
        }
Ejemplo n.º 13
0
        public void suaphong()
        {
            Console.Clear();
            Console.WriteLine("SỬA THÔNG TIN PHÒNG");
            List <Phongkt> list = pbll.LPhong();
            string         map;

            Console.Write("Nhập mã phòng cần sửa:");
            map = Console.ReadLine();
            int i = 0;

            for (i = 0; i < list.Count; ++i)
            {
                if (list[i].Maph == map)
                {
                    break;
                }
            }

            if (i < list.Count)
            {
                Phongkt p = new Phongkt(list[i]);
                Console.Write("Nhậpp tên dãy:");
                string day = Console.ReadLine();
                if (!string.IsNullOrEmpty(day))
                {
                    p.Tenday = day;
                }
                Console.Write("Nhap so luong nguoi o moi");
                int sno = int.Parse(Console.ReadLine());
                if (sno > 0)
                {
                    p.Dango = sno;
                }
                Console.WriteLine("Tinh trang phong");
                string ttp = Console.ReadLine();
                if (!string.IsNullOrEmpty(ttp))
                {
                    p.Tinhtrang = ttp;
                }
                pbll.suaphong(p);
            }
            else
            {
                Console.WriteLine("Không tồn tại mã phòng này");
            }
suaphong:
            gd.pain("ẤN TAB ĐỂ QUAY LẠI MENU PHÒNG", 20, 47);
            ConsoleKeyInfo kt = Console.ReadKey();

            switch (kt.Key)
            {
            case ConsoleKey.F2: Console.Clear(); suaphong(); break;

            case ConsoleKey.Tab: Console.Clear(); menuphong(); break;

            default:
                Console.WriteLine("sai thao tác! mời nhập lại");
                goto suaphong;
            }
        }
Ejemplo n.º 14
0
 public string Phong(Phongkt t)
 {
     return(t.Maph + "#" + t.Tenday + "#" + t.Soluongmax + "#" + t.Dango + "#" + t.Tinhtrang);
 }
Ejemplo n.º 15
0
        public void themt()
        {
            Phongkt ph = new Phongkt();

            for (int i = 11; i < 25; ++i)
            {
                gd.pain("║", 7, i);
                gd.pain("║", 92, i);
            }
            gd.pain("╔════════════════════════════════════════════════════════════════════════════════════╗", 7, 10);
            gd.pain("╠═══════════════════════════════╬════════════════════════════════════════════════════╣", 7, 13);
            gd.pain("╠═══════════════════════════════╦════════════════════════════════════════════════════╣", 7, 16);
            gd.pain("╠═══════════════════════════════╦════════════════════════════════════════════════════╣", 7, 19);
            gd.pain("╠═══════════════════════════════╦════════════════════════════════════════════════════╣", 7, 22);
            for (int i = 11; i < 25; ++i)
            {
                gd.pain("║", 39, i);
            }
            gd.pain("╚═══════════════════════════════╩════════════════════════════════════════════════════╝", 7, 25);
            List <Phongkt> lkt = pbll.LPhong();

kt:
            do
            {
                gd.ve(9, 12); Console.WriteLine("Nhập mã phòng");
                gd.ve(50, 12); ph.Maph = Console.ReadLine();
                for (int i = 0; i < lkt.Count; i++)
                {
                    if (ph.Maph == lkt[i].Maph)
                    {
                        break;
                    }
                    {
                        gd.ve(30, 30); Console.WriteLine("da ton tai ma phong xin kiem tra lai"); goto kt;
                    }
                }
            } while (string.IsNullOrEmpty(ph.Maph));
            do
            {
                gd.ve(9, 15); Console.WriteLine("Nhập tên dãy");
                gd.ve(50, 15); ph.Tenday = Console.ReadLine();
            } while (string.IsNullOrEmpty(ph.Tenday));
            slmax : gd.pain("", 50, 18);
            try
            {
                gd.ve(9, 18); Console.WriteLine("Nhập sl hoc sinh max");
                gd.ve(50, 18); ph.Soluongmax = int.Parse(Console.ReadLine());
            }
            catch
            {
                gd.ve(20, 40); Console.WriteLine("không có dữ liệu hoặc dữ liệu là chữ,mời nhập lại");
                goto slmax;
            }
            dango : gd.pain("", 50, 21);
            try
            {
                gd.ve(9, 21); Console.WriteLine("Nhập sl hoc sinh đang ở");
                gd.ve(50, 21); ph.Dango = int.Parse(Console.ReadLine());
            }
            catch
            {
                gd.ve(20, 40); Console.WriteLine("không có dữ liệu hoặc dữ liệu là chữ,mời nhập lại");
                goto dango;
            }
            do
            {
                gd.ve(9, 24); Console.WriteLine("Cho biết tình trạng phòng");
                gd.ve(50, 24); ph.Tinhtrang = Console.ReadLine();
            } while (string.IsNullOrEmpty(ph.Tinhtrang));

            pbll.themphong(ph);
            Console.SetCursorPosition(40, 30);
            gd.pain("F1", 20, 27); gd.pain("THÊM VÀ NHẬP TIẾP", 30, 27);
            gd.pain("F2", 20, 28); gd.pain("HIỆN THÔNG TIN", 30, 28);
            gd.pain("F3", 20, 29); gd.pain("TRỞ LẠI", 30, 29);
            Console.SetCursorPosition(40, 30);
n:
            ConsoleKeyInfo kt = Console.ReadKey();

            switch (kt.Key)
            {
            case ConsoleKey.F1: Console.Clear(); themt(); Console.Clear(); break;

            case ConsoleKey.F2: Console.Clear(); hien(); break;

            case ConsoleKey.F3: Console.Clear(); menuphong(); break;

            default:
                Console.WriteLine("sai thao tác!!! mời nhập lại"); Console.SetCursorPosition(40, 30);
                goto n;
            }
        }