By GokiSoft.com| 09:41 01/11/2021|
C Sharp

[Assignment] Bài tập ôn luyên tổng quát C# - Lập Trình C# - Lập Trình C Sharp

Đề 1: Tạo ứng dụng calculator bằng giao diện (Winform Application) gồm các chức năng sau

- Tạo máy tính gồm các chức năng cơ bản

- Lưu lại toàn bộ lịch sử đã thực hiện các phép tính vào file hoặc CSDL

Đề 2 : Tạo ứng dụng quản lý khách sạn (Dùng console hoặc Winform -> tuỳ chọn)

Note : Form sẽ đc nhiều điểm hơn

Gồm các chức năng

- Thêm/Sửa/Xoá KS

- Thêm sửa xoá khách hàng

- Quản lý đặt phòng

- Tìm kiếm.


Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

hoangduyminh [T1907A]
hoangduyminh

2020-06-04 07:18:11

https://gitlab.com/duyminh27102001/assiment


nguyễn văn huy [T1907A]
nguyễn văn huy

2020-06-04 06:39:37



using System;
using System.Collections.Generic;
using System.Text;

namespace khachsan
{
    class tong
    {
        
        public string cmnd { get; set; }

        public string hotelID { get; set; }

        public string roomCode { get; set; }

        public tong()
        {

        }
        public void display()
        {
            Console.WriteLine("  {0} , {1} , {2}",  cmnd, hotelID, roomCode);
        }
        public void input(List<khachsan> sanlist, List<khachhang> khachlist, List<string> id)
        {
            
            inputCMND(khachlist);
            inputHotelID(sanlist, id);
        }
        private void inputCMND(List<khachhang> khachlist)
        {
            bool dk = false;
            Console.WriteLine("Id: ");
            string find = Console.ReadLine();
            foreach (var thao in khachlist)
            {
                if (find.Equals(thao.cmnd))
                {
                    cmnd = find;
                    dk = true;
                    break;
                }
            }
            if (!dk)
            {
                Console.WriteLine("nhập thông tin khach hang");
               khachhang hang = new khachhang();
                hang.input(find);
                khachlist.Add(hang);
                cmnd = hang.cmnd;
            }

        }
        private void inputHotelID(List<khachsan> sanlist, List<string> id)
        {
            bool dk = false;
            Console.WriteLine("ID : ");
            string find = Console.ReadLine();
            foreach (var thao in sanlist)
            {
                if (find.Equals(thao.hotelID))
                {
                    hotelID = find;
                    dk = true;
                    break;
                }
            }
            if (!dk)
            {
                Console.WriteLine("nhập thông tin khach san : ");
                khachsan hote = new khachsan();
                hote.input();
                hotelID = hote.hotelID;
                sanlist.Add(hote);
            }
            foreach (var thao in sanlist)
            {
                if (hotelID.Equals(thao.hotelID))
                {
                    findRoom(thao);
                }
            }


        }

        private void findRoom(khachsan hotel)
        {
            bool dk = true;
            while (dk)
            {
                foreach (phong item in hotel.rooms)
                {
                    item.display();
                }
                Console.WriteLine("momo : ");
                string check;
                check = Console.ReadLine();
                foreach (phong thao in hotel.rooms)
                {
                    if (check.Equals(thao.roomCode))
                    {
                        roomCode = check;
                        dk = false;
                        break;
                    }
                }
                if (dk)
                {
                    Console.WriteLine("ma phong sai !!");
                }
            }
        }

        
    }
}
>>>>>>>
using System;
using System.Collections.Generic;
using System.Text;

namespace khachsan
{
    class phong
    {
        public string roomName { get; set; }
        public int floorNumber { get; set; }
        public int maxPerson { get; set; }
        public int price { get; set; }
        public string roomCode { get; set; }

        public phong()
        {

        }
        public phong(string roomName, int floorNumber, int maxPerson, int price, string roomCode)
        {
            this.floorNumber = floorNumber;
            this.maxPerson = maxPerson;
            this.price = price;
            this.roomCode = roomCode;
            this.roomName = roomName;
        }
        public void input(List<string> vs)
        {
            inputRoomName();
            inputfloorNumber();
            inputmaxPerson();
            inputprice();
            inputRoomCode(vs);
        }
        private void inputfloorNumber()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("tang  : ");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    floorNumber = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }
        private void inputmaxPerson()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("so nguoi toi da : ");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    maxPerson = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }

        private void inputprice()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("gia phong 1 ngay : ");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    price = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }
        bool checkInt(string s)
        {
            bool check = true;
            foreach (char item in s)
            {
                if (item < 48 || item > 57)
                {
                    check = false;
                    break;
                }

            }
            return check;
        }
        private void inputRoomCode(List<string> vs)
        {
            bool ischeck = false;
            for (; ischeck == false;)
            {
                Console.WriteLine("ma phong : ");
                roomCode = Console.ReadLine();
                foreach (string str in vs)
                {
                    if (roomCode.Equals(str))
                    {
                        Console.WriteLine("Sai !!");
                        ischeck = true;
                        break;
                    }
                }
                if (!ischeck && string.IsNullOrEmpty(roomCode) == false)
                {
                    vs.Add(roomCode);
                    ischeck = true;
                    break;
                }
                else
                {
                    Console.WriteLine("Nooo !!");
                    ischeck = false;
                }
            }
        }
        private void inputRoomName()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("ten phong : ");
                roomName = Console.ReadLine();
                if (string.IsNullOrEmpty(roomName) == false)
                {
                    ischeck = false;
                }
            }

        }
        public void display()
        {
            Console.WriteLine("roomName : {0} , numberFloor : {1} , maxPerson : {2} , Price : {3} , roomCode : {4}", roomName, floorNumber, maxPerson, price, roomCode);

        }
    }
}
>>>>>
using System;
using System.Text;

namespace khachsan
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            menu noo = new menu();
            int c;
            do
            {
                menu();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        noo.Hotel();
                        break;
                    case 2:
                       noo.Customer();
                        break;
                    case 3:
                        noo.book();
                        break;
                    case 4:
                        noo.Searching();
                        break;

                    case 5:
                        Console.WriteLine("Thoát !!");
                        break;


                    default:
                        Console.WriteLine("Lỗi !!");
                        break;
                }

            } while (c != 5);
        }
        static void menu()
        {
            Console.WriteLine("1.Khách sạn");
            Console.WriteLine("2.khách hàng");
            Console.WriteLine("3.Đặt Phòng");
            Console.WriteLine("4.Tìm kiếm");
            Console.WriteLine("5.Thoát !");
            Console.WriteLine("Chọn : ");
        
    }
    }
}
>>>>>
using System;
using System.Collections.Generic;
using System.Text;

namespace khachsan
{
    class menu
    {
        List<tong> tonglist = new List<tong>();
        List<khachsan> sanlist = new List<khachsan>();
        List<khachhang> khachlist = new List<khachhang>();
        List<string> id = new List<string>();
        public void Searching()
        {
            int choose;
            do
            {
                menuSearch();
                choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Console.WriteLine("HotelId : ");
                        string str = Console.ReadLine();
                        bool isCheck = false;
                        foreach (var thao in sanlist)
                        {
                            if (thao.hotelID.Equals(str))
                            {
                                thao.Display();
                                isCheck = true;
                                break;
                            }
                        }
                        if (!isCheck)
                        {
                            Console.WriteLine("Hotel is not Exit !!");
                        }
                        break;
                    case 2:
                        Console.WriteLine("HotelId : ");
                        str = Console.ReadLine();
                        isCheck = false;
                        foreach (var thao in khachlist)
                        {
                            if (thao.cmnd.Equals(str))
                            {
                                thao.display();
                                isCheck = true;
                                break;
                            }
                        }
                        if (!isCheck)
                        {
                            Console.WriteLine("Customer is not Exit !!");
                        }
                        break;
                    case 3:
                        Console.WriteLine("Id ks : ");
                        str = Console.ReadLine();
                        isCheck = false;
                        foreach (var thao in sanlist)
                        {
                            if (thao.hotelID.Equals(str))
                            {
                                foreach (phong room in thao.rooms)
                                {
                                    room.display();
                                }
                                isCheck = true;
                                break;
                            }
                        }
                        if (!isCheck)
                        {
                            Console.WriteLine(" Exit !!");
                        }
                        break;
                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;
                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 4);
        }
        public void book()
        {

            int c;
            do
            {
                menuBooking();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        tong toong = new tong();
                        toong.input(sanlist, khachlist, id);
                        tonglist.Add(toong);
                        break;
                    case 2:
                        foreach (var thao in tonglist)
                        {
                            thao.display();
                        }
                        break;
                    case 3:
                        showRoomByDate();
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 4);
        }
        public void showRoomByDate(List<tong> tonglist, List<khachsan> sanlist)
        {
            if (sanlist.Count == 0)
            {
                Console.WriteLine("khong co data!!!");
                return;
            }
            khachsan currentHotel = null;
            for (; ; )
            {
                foreach (khachsan hotel in sanlist)
                {
                    Console.WriteLine("Ma KS: {0}, Ten KS: {1}", hotel.hotelID, arg1: hotel.name);
                }
                Console.WriteLine("Enter hotelID : ");
                string hotelID = Console.ReadLine();
                foreach (khachsan hotel in sanlist)
                {
                    if (hotel.hotelID.Equals(hotelID))
                    {
                        currentHotel = hotel;
                        break;
                    }
                }
                if (currentHotel != null)
                {
                    break;
                }
                Console.WriteLine("(Not Found) Nhap lai: ");
            }
            if (currentHotel.rooms.Count == 0)
            {
                Console.WriteLine("khong co data!!!");
                return;
            }

            

            foreach (var room in currentHotel.rooms)
            {
                List<tong> current = new List<tong>();

                foreach (var bo in tonglist)
                {
                    if (bo.hotelID.Equals(currentHotel.hotelID) && bo.roomCode.Equals(room.roomCode))
                    {
                        current.Add(bo);
                    }
                }
                bool isFind = false;
               
                if (!isFind)
                {
                    Console.WriteLine("Room No: {0}, Room Name: {1}", room.roomCode, room.roomName);
                }

            }

        }
        public void Customer()
        {

            khachsan customer = new khachsan();

            int c;
            do
            {
                menuCustomer();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        customer.addCustomer(khachlist, id);
                        break;
                    case 2:
                        customer.editCustomer(khachlist);
                        break;
                    case 3:
                        customer.deleteCustomer(khachlist);
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 4);
        }

        public void Hotel()
        {


            khachsan hotel = new khachsan();
            int choose;
            do
            {
                menuHotel();
                choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        hotel.addHotel(sanlist, id);
                        break;
                    case 2:
                        hotel.editHotel(sanlist, id);
                        break;
                    case 3:
                        hotel.deleteCustomer(sanlist, id);
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (choose != 4);

        }
        private void menuHotel()
        {
            Console.WriteLine("1.them ks");
            Console.WriteLine("2.sua ks");
            Console.WriteLine("3.xoa ks");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("5.Choose : ");
        }
        private void menuCustomer()
        {
            Console.WriteLine("1.them kh");
            Console.WriteLine("2.sua kh");
            Console.WriteLine("3.xoa kh");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("5.Choose : ");
        }
        private void menuBooking()
        {
            Console.WriteLine("1.them tong");
            Console.WriteLine("2.mo tong");
            Console.WriteLine("3.lo het");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("Choose : ");
        }
        private void menuSearch()
        {
            Console.WriteLine("1.tim ks");
            Console.WriteLine("2.tim kh");
            Console.WriteLine("3.tim phong");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("5.Choose : ");
        }
    }
}
>>>>>
using System;
using System.Collections.Generic;
using System.Text;

namespace khachsan
{
    class khachsan
    {
        internal object hotelID;
        internal IEnumerable<phong> phongs;
        internal int name;

        public void addCustomer(List<khachhang>khachlist, List<string> id)
        {
            khachhang khach = new khachhang();
            khach.input(id);
            khachlist.Add(khach);
        }
        public void editCustomer(List<khachhang> khachlist)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("nhap id de chinh sua>> ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (khachhang cus in khachlist)
                {
                    if (str.Equals(cus.cmnd))
                    {
                        cus.input(str);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("Sai !!");
                }


            }
        }
        public void input()
        {
            Console.WriteLine("nhap tenid:");
            hotelID = Console.ReadLine();
            Console.WriteLine("nhap name");
            name = Int32.Parse(Console.ReadLine());
        }
        public void Display()
        {
            Console.WriteLine("{0},{1},", hotelID, name);
        }

        public void deleteCustomer(List<khachsan> sanlist, List<khachhang> khachlist)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Enter PersonalID to delete : ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (khachhang cus in khachlist)
                {
                    if (str.Equals(cus.cmnd))
                    {
                        khachlist.Remove(cus);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("PersonalID is Not exist !!");
                }


            }
        }

        
    }
}
>>>>>
using System;
using System.Collections.Generic;
using System.Text;

namespace khachsan
{
    class khachhang
    {
        public string cmnd { get; set; }
        public string name { get; set; }
        public string gender { get; set; }
        public string address { get; set; }
        public khachhang()
        {

        }
        public khachhang(string cmnd, string name, string gender, string address)
        {
            this.address = address;
            this.cmnd = cmnd;
            this.gender = gender;
            this.name = name;
        }
        public void input(List<string> cmt)
        {
            inputCmnd(cmt);
            input(cmnd);
        }
        public void input(string cmnd)
        {
            this.cmnd = cmnd;
            inputName();
            inputGender();
            inputaddress();
        }
        bool checkInt(string s)
        {
            bool check = true;
            foreach (char item in s)
            {
                if (item < 18|| item > 40)
                {
                    check = false;
                    break;
                }

            }
            return check;
        }

        private void inputCmnd(List<string> vs)
        {
            bool ischeck = false;
            for (; ischeck == false;)
            {
                Console.WriteLine("nhap cmt : ");
                cmnd = Console.ReadLine();
                foreach (string str in vs)
                {
                    if (cmnd.Equals(str))
                    {
                        Console.WriteLine(" exist !!");
                        ischeck = true;
                        break;
                    }
                }
                if (!ischeck && string.IsNullOrEmpty(cmnd) == false)
                {
                    vs.Add(cmnd);
                    ischeck = true;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                    ischeck = false;
                }
            }
        }
        private void inputGender()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Gender : ");
                gender = Console.ReadLine();
                if (string.IsNullOrEmpty(gender) == false)
                {
                    ischeck = false;
                }
            }

        }
        private void inputaddress()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Address : ");
                address = Console.ReadLine();
                if (string.IsNullOrEmpty(address) == false)
                {
                    ischeck = false;
                }
            }

        }
        private void inputName()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Name : ");
                name = Console.ReadLine();
                if (string.IsNullOrEmpty(name) == false)
                {
                    ischeck = false;
                }
            }

        }
        public void display()
        {
            Console.WriteLine(" {0} , {1} ,  {3} ,  {4}", cmnd, name, gender, address);
        }

        
    }
}



Thành Lâm [T1907A]
Thành Lâm

2020-06-04 05:40:04



using System;
using System.Text;

namespace Hotel
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("====================Ứng Dụng Quản Lý Khách Sạn===============");
            Bookking();
            Hotel();
            Room();
            Customer();
            string repeat = null;
            int option;
            do
            {
                Console.WriteLine("1.Thêm Khách Sạn");
                Console.WriteLine("2.Sửa Khách Sạn");
                Console.WriteLine("3.Xóa Khách Sạn");
                Console.WriteLine("4.Thêm Khách Hàng ");
                Console.WriteLine("5.Sửa Khách Hàng");
                Console.WriteLine("6.Xóa Khách Hàng");
                Console.WriteLine("7.Quản lý đặt Phòng");
                Console.WriteLine("8.Tìm Kiếm");
                option = Int32.Parse(Console.ReadLine());
                switch (option)
                {
                    case 1:
                        Hotel();
                        break;
                    case 2:
                        break;
                    case 3:
                        break;
                    case 4:
                        Customer();
                        break;
                    case 5:
                        break;
                    case 6:
                        break;
                    case 7:
                        Bookking();
                        break;
                    case 8:
                        break;
                    default:
                        Console.WriteLine("Bạn nhập chưa đúng yêu cầu.");
                        break;
                }
                Console.WriteLine("Bạn có muốn tiếp tục không ? y/n");
                repeat = Console.ReadLine();
            } while (repeat.Equals("y") == true);
        }

        static void Bookking()
        {
            Booking1 bookking = new Booking1();
            bookking.input();
            bookking.display();

        }
        static void Hotel()
        {
            Hotell hotell = new Hotell();
            hotell.input();
            hotell.display();
        }

        static void Room()
        {
            Room room = new Room();
            room.input();
            room.display();

        }

        static void Customer()
        {
            Customer customer = new Customer();
            customer.input();
            customer.display();
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Hotel
{
    class Room
    {
        private string _idroom;
        public string Idroom {
            get
            {
                return _idroom;
            }
            set
            {
                if(value.Length > 4)
                {
                    this._idroom = value;
                }
            }
        }
        public string Nameroom { get; set; }
        private int _numroom;
        public int Numroom {
            get
            {
                return _numroom;
            }
            set
            {
                if(value > 0)
                {
                    this._numroom = value;
                }
            }
        }
        private int _numbed;
        public int Numbed {
            get
            {
                return _numbed;
            }
            set
            {
                if(value > 0 )
                {
                    this._numbed = value;
                }else
                {
                    Console.WriteLine("Bạn nhập số giường chưa đúng.");
                }
            }
        }
        private int _money;
        public int Money {
            get
            {
                return _money;
            }
            set
            {
                if (value > 0)
                {
                    this._money = value;
                }
            }
        }


        public void input()
        {
            Console.WriteLine("Nhập Tên Phòng: ");
            Nameroom = Console.ReadLine();
            Console.WriteLine("Nhập số phòng: ");
            Numroom = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Nhập số giường của phòng: ");
            Numbed = Int32.Parse(Console.ReadLine());

        }

        public void display()
        {
            Console.WriteLine("Tên Phòng: {0}\n Mã Số Phòng: {1}\n Số giường trong phòng: {2}", Nameroom, Numroom, Numbed);
        }

    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Hotel
{
    class Hotell
    {
        private string _idhotel;

        public string Idhotel {
            get
            {
                return _idhotel;
            }
            set
            {
                if (value.Length > 5 && value.Length < 10)
                {
                    this._idhotel = value;
                }
            }
        }
        public string Namehotel { get; set; }
        public string Addresshotel { get; set; }
        private int _yearhotel;
        public int Yearhotel {
            get
            {
                return _yearhotel;
            }
            set
            {
                if(value > 0)
                {
                    this._yearhotel = value;
                }
            }
        }
        private int _starhotel;
        public int Starhotel {
            get
            {
                return _starhotel;
            }
            set
            {
                if(value > 0 && value < 6)
                {
                    this._starhotel = value;
                }
            }
        }

        public void input()
        {
            Console.WriteLine("Nhập ID của Khách Sạn (5-10 ký tự): ");
            Idhotel = Console.ReadLine();
            Console.WriteLine("Nhập tên khách sạn: ");
            Namehotel = Console.ReadLine();
            Console.WriteLine("Nhập địa chỉ khách sạn: ");
            Addresshotel = Console.ReadLine();
            Console.WriteLine("Nhập năm thành lập Khách Sạn: ");
            Yearhotel = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Nhập sao của khách sạn: ");
            Starhotel = Int32.Parse(Console.ReadLine());

        }

        public void display()
        {
            Console.WriteLine("Tên Khách Sạn: {0}\n Địa Chỉ Khách Sạn: {1}\n Năm Thành Lập Khách Sạn: {2}\n Sao của Khách Sạn: {3}", Namehotel, Addresshotel, Yearhotel, Starhotel);
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Hotel
{
    class Booking1
    {
        public string Searhotel { get; set; }
        public string Searroom { get; set; }
        public string Checkin { get; set; }
        public string Checkout { get; set; }
        private int _money;
        public int Money {
            get
            {
                return _money;
            }
            set
            {
                if(value > 0)
                {
                    this._money = value;
                }
            }
        }

        public void input()
        {
            Console.WriteLine("Bạn Muốn Tìm Khách Sạn Dựa trên địa điểm nào? ");
            Searhotel = Console.ReadLine();
            Console.WriteLine("Phòng Bạn muốn?");
            Searroom = Console.ReadLine();
            Console.WriteLine("Ngày bắt đầu: dd/mm/yy");
            Checkin = Console.ReadLine();
            Console.WriteLine("Ngày trả phòng: dd/mm/yy");
            Checkout = Console.ReadLine();

        }

        public void display()
        {
            Console.WriteLine("Địa điểm: {0}\n Ngày bắt đầu: {1}\n Ngày trả phòng:{2}", Searhotel, Checkin, Checkout);
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Hotel
{
    class Customer
    {
        public string Fullname { get; set; }
        private string _gender;
        public string Gender {
            get
            {
                return _gender;
            }
            set
            {
                if (value.Equals("Nam") || value.Equals("Nu") || value.Equals("Không"))
                {
                    this._gender = value;
                }
            }
        }
        public string Address { get; set; }
        private int _address;
        public int Age {
            get
            {
                return _address;
            }
            set
            {
                if(value > 18)
                {
                    this._address = value;
                }
            }
        }
        private string _cmnd;
        public string Cmnd {
            get
            {
                return _cmnd;
            }
            set
            {
                if (value.Length > 10 && value.Length<= 12)
                {
                    this._cmnd = value;
                }
            }
        }

        public void input()
        {
            Console.WriteLine("Nhập tên của bạn: ");
            Fullname = Console.ReadLine();
            Console.WriteLine("Nhập địa chỉ của bạn: ");
            Address = Console.ReadLine();
            Console.WriteLine("Nhập tuổi của bạn: ");
            Age = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Nhập CMND của bạn (Nhập số): ");
            Cmnd = Console.ReadLine();
        }

        public void display()
        {
            Console.WriteLine("Tên: {0}\n Địa chỉ: {1}\n Tuổi: {2}\n CMND: {3}", Fullname, Address, Age, Cmnd);
        }
    }
}




Đỗ Văn Huấn [T1907A]
Đỗ Văn Huấn

2020-06-04 02:06:10

https://github.com/huandv21-8/Java/tree/master/WindowsFormsApp1/WindowsFormsApp1

Làm máy tính bằng C# và lưu dữ liệu trên MySQL



Phí Văn Long [T1907A]
Phí Văn Long

2020-06-03 16:07:46

https://github.com/philong192001/ASS.git

Assignment - winform quản lí khách sạn kết nối CSDL SQL Sever


Phan Bạch Tùng Dương [T1907A]
Phan Bạch Tùng Dương

2020-06-03 15:40:22

https://drive.google.com/file/d/1qcPmAbava_wRZDBADxVe-n1oZMI7vVrz/view?usp=sharing

e ko đẩy đc lên git thầy ơi T_T


Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-06-03 14:46:25



using System;
using System.Collections.Generic;
using System.Text;

namespace AssignmentQliks
{
    class Book
    {
        public DateTime checkin { get; set; }
        public DateTime checkout { get; set; }
        public string cmnd { get; set; }

        public string hotelID { get; set; }

        public string roomCode { get; set; }

        public Book()
        {

        }
        public void display()
        {
            Console.WriteLine("CheckIn : {0} , CheckOut : {1} , Cmnd : {2} , HotelID : {3} , roomID : {4}", checkin, checkout, cmnd, hotelID, roomCode);
        }
        public void input(List<Hotel> hotels, List<Customer> customers, List<string> ids)
        {
            string strDatetime = null;
            while (string.IsNullOrEmpty(strDatetime))
            {
                Console.WriteLine("Ngay book (dd/mm/YYYY): ");
                strDatetime = Console.ReadLine();
                checkin = DateTime.ParseExact(strDatetime, "dd/MM/yyyy", null);
            }
            strDatetime = null;
            while (string.IsNullOrEmpty(strDatetime))
            {
                Console.WriteLine("Ngay tra phong (dd/mm/YYYY): ");
                strDatetime = Console.ReadLine();
                checkout = DateTime.ParseExact(strDatetime, "dd/MM/yyyy", null);
            }
            inputCMND(customers);
            inputHotelID(hotels, ids);
        }
        private void inputCMND(List<Customer> customers)
        {
            bool dk = false;
            Console.WriteLine("Enter PersonID : ");
            string find = Console.ReadLine();
            foreach (var item in customers)
            {
                if (find.Equals(item.cmnd))
                {
                    cmnd = find;
                    dk = true;
                    break;
                }
            }
            if (!dk)
            {
                Console.WriteLine("nhập thông tin Customer");
                Customer customer = new Customer();
                customer.input(find);
                customers.Add(customer);
                cmnd = customer.cmnd;
            }

        }
        private void inputHotelID(List<Hotel> hotels, List<string> ids)
        {
            bool dk = false;
            Console.WriteLine("Enter hotelID : ");
            string find = Console.ReadLine();
            foreach (var item in hotels)
            {
                if (find.Equals(item.hotelID))
                {
                    hotelID = find;
                    dk = true;
                    break;
                }
            }
            if (!dk)
            {
                Console.WriteLine("nhập thông tin hotel : ");
                Hotel hotel = new Hotel();
                hotel.input(ids);
                hotelID = hotel.hotelID;
                hotels.Add(hotel);
            }
            foreach (var item in hotels)
            {
                if (hotelID.Equals(item.hotelID))
                {
                    findRoom(item);
                }
            }


        }

        private void findRoom(Hotel hotel)
        {
            bool dk = true;
            while (dk)
            {
                foreach (Room item in hotel.rooms)
                {
                    item.display();
                }
                Console.WriteLine("Enter roomCode to book : ");
                string check;
                check = Console.ReadLine();
                foreach (Room item in hotel.rooms)
                {
                    if (check.Equals(item.roomCode))
                    {
                        roomCode = check;
                        dk = false;
                        break;
                    }
                }
                if (dk)
                {
                    Console.WriteLine("ma phong sai !!");
                }
            }
        }

        internal static void inpu(List<Hotel> hotels, List<Customer> customers, List<string> ids)
        {
            throw new NotImplementedException();
        }

        internal static void Add(Action book)
        {
            throw new NotImplementedException();
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace AssignmentQliks
{
    class Room
    {
        public string roomName { get; set; }
        public int floorNumber { get; set; }
        public int maxPerson { get; set; }
        public int price { get; set; }
        public string roomCode { get; set; }

        public Room()
        {

        }
        public Room(string roomName, int floorNumber, int maxPerson, int price, string roomCode)
        {
            this.floorNumber = floorNumber;
            this.maxPerson = maxPerson;
            this.price = price;
            this.roomCode = roomCode;
            this.roomName = roomName;
        }
        public void input(List<string> vs)
        {
            inputRoomName();
            inputfloorNumber();
            inputmaxPerson();
            inputprice();
            inputRoomCode(vs);
        }
        private void inputfloorNumber()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("tang  : ");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    floorNumber = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }
        private void inputmaxPerson()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("so nguoi toi da : ");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    maxPerson = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }

        private void inputprice()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("gia phong 1 ngay : ");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    price = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }
        bool checkInt(string s)
        {
            bool check = true;
            foreach (char item in s)
            {
                if (item < 48 || item > 57)
                {
                    check = false;
                    break;
                }

            }
            return check;
        }
        private void inputRoomCode(List<string> vs)
        {
            bool ischeck = false;
            for (; ischeck == false;)
            {
                Console.WriteLine("ma phong : ");
                roomCode = Console.ReadLine();
                foreach (string str in vs)
                {
                    if (roomCode.Equals(str))
                    {
                        Console.WriteLine("PersonalID is exist !!");
                        ischeck = true;
                        break;
                    }
                }
                if (!ischeck && string.IsNullOrEmpty(roomCode) == false)
                {
                    vs.Add(roomCode);
                    ischeck = true;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                    ischeck = false;
                }
            }
        }
        private void inputRoomName()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("ten phong : ");
                roomName = Console.ReadLine();
                if (string.IsNullOrEmpty(roomName) == false)
                {
                    ischeck = false;
                }
            }

        }
        public void display()
        {
            Console.WriteLine("roomName : {0} , numberFloor : {1} , maxPerson : {2} , Price : {3} , roomCode : {4}", roomName, floorNumber, maxPerson, price, roomCode);

        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace AssignmentQliks
{
    class Hotel
    {
        internal object hotelID;
        internal IEnumerable<Room> rooms;
        internal int name;

        public void addCustomer(List<Customer> customers, List<string> ids)
        {
            Customer customer = new Customer();
            customer.input(ids);
            customers.Add(customer);
        }
        public void editCustomer(List<Customer> customers)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Enter PersonalID to edit : ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (Customer cus in customers)
                {
                    if (str.Equals(cus.cmnd))
                    {
                        cus.input(str);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("PersonalID is Not exist !!");
                }


            }
        }

        internal void Display()
        {
            throw new NotImplementedException();
        }

        public void deleteCustomer(List<Hotel> hotels, List<Customer> customers)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Enter PersonalID to delete : ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (Customer cus in customers)
                {
                    if (str.Equals(cus.cmnd))
                    {
                        customers.Remove(cus);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("PersonalID is Not exist !!");
                }


            }
        }

        internal void addHotel(List<Hotel> hotels, List<string> ids)
        {
            throw new NotImplementedException();
        }

        internal void deleteCustomer(List<Hotel> hotels, List<string> ids)
        {
            throw new NotImplementedException();
        }

        internal void editHotel(List<Hotel> hotels, List<string> ids)
        {
            throw new NotImplementedException();
        }
    }
}



using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace AssignmentQliks
{
    class FunctionMennu
    {
        public FunctionMennu()
        {

        }
        List<Book> bookings = new List<Book>();
        List<Hotel> hotels = new List<Hotel>();
        List<Customer> customers = new List<Customer>();
        List<string> ids = new List<string>();
        public void Searching()
        {
            int choose;
            do
            {
                menuSearch();
                choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Console.WriteLine("HotelId : ");
                        string str = Console.ReadLine();
                        bool isCheck = false;
                        foreach (var item in hotels)
                        {
                            if (item.hotelID.Equals(str))
                            {
                                item.Display();
                                isCheck = true;
                                break;
                            }
                        }
                        if (!isCheck)
                        {
                            Console.WriteLine("Hotel is not Exit !!");
                        }
                        break;
                    case 2:
                        Console.WriteLine("HotelId : ");
                        str = Console.ReadLine();
                        isCheck = false;
                        foreach (var item in customers)
                        {
                            if (item.cmnd.Equals(str))
                            {
                                item.display();
                                isCheck = true;
                                break;
                            }
                        }
                        if (!isCheck)
                        {
                            Console.WriteLine("Customer is not Exit !!");
                        }
                        break;
                    case 3:
                        Console.WriteLine("HotelId : ");
                        str = Console.ReadLine();
                        isCheck = false;
                        foreach (var item in hotels)
                        {
                            if (item.hotelID.Equals(str))
                            {
                                foreach (Room room in item.rooms)
                                {
                                    room.display();
                                }
                                isCheck = true;
                                break;
                            }
                        }
                        if (!isCheck)
                        {
                            Console.WriteLine("Hotel is not Exit !!");
                        }
                        break;
                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;
                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 4);
        }
        public void book()
        {

            int c;
            do
            {
                menuBooking();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        Book booking = new Book();
                        Book.input(hotels, customers, ids);
                        Book.Add(book);
                        break;
                    case 2:
                        foreach (var item in book)
                        {
                            item.display();
                        }
                        break;
                    case 3:
                        showRoomByDate(bookings, hotels);
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 4);
        }
        public void showRoomByDate(List<Book> books, List<Hotel> hotels)
        {
            if (hotels.Count == 0)
            {
                Console.WriteLine("khong co data!!!");
                return;
            }
            Hotel currentHotel = null;
            for (; ; )
            {
                foreach (Hotel hotel in hotels)
                {
                    Console.WriteLine("Ma KS: {0}, Ten KS: {1}", hotel.hotelID, arg1: hotel.name);
                }
                Console.WriteLine("Enter hotelID : ");
                string hotelID = Console.ReadLine();
                foreach (Hotel hotel in hotels)
                {
                    if (hotel.hotelID.Equals(hotelID))
                    {
                        currentHotel = hotel;
                        break;
                    }
                }
                if (currentHotel != null)
                {
                    break;
                }
                Console.WriteLine("(Not Found) Nhap lai: ");
            }
            if (currentHotel.rooms.Count == 0)
            {
                Console.WriteLine("khong co data!!!");
                return;
            }

            Console.WriteLine("Ngay CheckIn (dd/mm/YYYY): ");
            string dateTime = Console.ReadLine();
            DateTime CheckIn = DateTime.ParseExact(dateTime, "dd/MM/yyyy", null);

            Console.WriteLine("Ngay CheckOut (dd/mm/YYYY): ");
            dateTime = Console.ReadLine();
            DateTime CheckOut = DateTime.ParseExact(dateTime, "dd/MM/yyyy", null);

            foreach (var room in currentHotel.rooms)
            {
                List<Book> currentBooking = new List<Book>();

                foreach (var book in books)
                {
                    if (book.hotelID.Equals(currentHotel.hotelID) && book.roomCode.Equals(room.roomCode))
                    {
                        currentBooking.Add(book);
                    }
                }
                bool isFind = false;
                foreach (var book in currentBooking)
                {
                    if (DateTime.Compare(book.checkin, CheckOut) > 0 || DateTime.Compare(book.checkout, CheckIn) < 0)
                    {
                        //room dat yeu cau
                    }
                    else
                    {
                        isFind = true;
                        break;
                    }

                }
                if (!isFind)
                {
                    Console.WriteLine("Room No: {0}, Room Name: {1}", room.roomCode, room.roomName);
                }

            }

        }
        public void Customer()
        {

            Customer customer = new Customer();

            int c;
            do
            {
                menuCustomer();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        customer.addCustomer(customers, ids);
                        break;
                    case 2:
                        customer.editCustomer(customers);
                        break;
                    case 3:
                        customer.deleteCustomer(customers);
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 4);
        }

        public void Hotel()
        {


            Hotel hotel = new Hotel();
            int choose;
            do
            {
                menuHotel();
                choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        hotel.addHotel(hotels, ids);
                        break;
                    case 2:
                        hotel.editHotel(
                            hotels, ids);
                        break;
                    case 3:
                        hotel.deleteCustomer(hotels, ids);
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (choose != 4);

        }
        private void menuHotel()
        {
            Console.WriteLine("1.Add Hotel");
            Console.WriteLine("2.Edit Hotel");
            Console.WriteLine("3.Dlete Hotel");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("Choose : ");
        }
        private void menuCustomer()
        {
            Console.WriteLine("1.Add Customer");
            Console.WriteLine("2.Edit Customer");
            Console.WriteLine("3.Dlete Customer");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("Choose : ");
        }
        private void menuBooking()
        {
            Console.WriteLine("1.Add Booking");
            Console.WriteLine("2.Show Booking");
            Console.WriteLine("3.Show room list available");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("Choose : ");
        }
        private void menuSearch()
        {
            Console.WriteLine("1.Search hotel");
            Console.WriteLine("2.Search Customer");
            Console.WriteLine("3.Search room");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("Choose : ");
        }


    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace AssignmentQliks
{
    class Hotel
    {
        internal object hotelID;
        internal IEnumerable<Room> rooms;
        internal int name;

        public void addCustomer(List<Customer> customers, List<string> ids)
        {
            Customer customer = new Customer();
            customer.input(ids);
            customers.Add(customer);
        }
        public void editCustomer(List<Customer> customers)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Enter PersonalID to edit : ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (Customer cus in customers)
                {
                    if (str.Equals(cus.cmnd))
                    {
                        cus.input(str);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("PersonalID is Not exist !!");
                }


            }
        }

        internal void Display()
        {
            throw new NotImplementedException();
        }

        public void deleteCustomer(List<Hotel> hotels, List<Customer> customers)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Enter PersonalID to delete : ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (Customer cus in customers)
                {
                    if (str.Equals(cus.cmnd))
                    {
                        customers.Remove(cus);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("PersonalID is Not exist !!");
                }


            }
        }

        internal void addHotel(List<Hotel> hotels, List<string> ids)
        {
            throw new NotImplementedException();
        }

        internal void deleteCustomer(List<Hotel> hotels, List<string> ids)
        {
            throw new NotImplementedException();
        }

        internal void editHotel(List<Hotel> hotels, List<string> ids)
        {
            throw new NotImplementedException();
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace AssignmentQliks
{
    class Customer
    {
        public string cmnd { get; set; }
        public string name { get; set; }
        public string gender { get; set; }
        public string address { get; set; }
        public int age { get; set; }
        public Customer()
        {

        }
        public Customer(string cmnd, string name, int age, string gender, string address)
        {
            this.address = address;
            this.age = age;
            this.cmnd = cmnd;
            this.gender = gender;
            this.name = name;
        }
        public void input(List<string> vs)
        {
            inputCmnd(vs);
            input(cmnd);
        }
        public void input(string cmnd)
        {
            this.cmnd = cmnd;
            inputName();
            inputAge();
            inputGender();
            inputaddress();
        }
        private void inputAge()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Age :");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    age = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }
        }
        bool checkInt(string s)
        {
            bool check = true;
            foreach (char item in s)
            {
                if (item < 48 || item > 57)
                {
                    check = false;
                    break;
                }

            }
            return check;
        }

        private void inputCmnd(List<string> vs)
        {
            bool ischeck = false;
            for (; ischeck == false;)
            {
                Console.WriteLine("PersonalID : ");
                cmnd = Console.ReadLine();
                foreach (string str in vs)
                {
                    if (cmnd.Equals(str))
                    {
                        Console.WriteLine("PersonalID is exist !!");
                        ischeck = true;
                        break;
                    }
                }
                if (!ischeck && string.IsNullOrEmpty(cmnd) == false)
                {
                    vs.Add(cmnd);
                    ischeck = true;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                    ischeck = false;
                }
            }
        }
        private void inputGender()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Gender : ");
                gender = Console.ReadLine();
                if (string.IsNullOrEmpty(gender) == false)
                {
                    ischeck = false;
                }
            }

        }
        private void inputaddress()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Address : ");
                address = Console.ReadLine();
                if (string.IsNullOrEmpty(address) == false)
                {
                    ischeck = false;
                }
            }

        }
        private void inputName()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Name : ");
                name = Console.ReadLine();
                if (string.IsNullOrEmpty(name) == false)
                {
                    ischeck = false;
                }
            }

        }
        public void display()
        {
            Console.WriteLine("CMND : {0} , Fullname : {1} , Age : {2} , Gender : {3} , Address : {4}", cmnd, name, age, gender, address);
        }

        internal void addCustomer(List<Customer> customers, List<string> ids)
        {
            throw new NotImplementedException();
        }

        internal void editCustomer(List<Customer> customers)
        {
            throw new NotImplementedException();
        }

        internal void deleteCustomer(List<Customer> customers)
        {
            throw new NotImplementedException();
        }
    }
}



using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Text;

namespace AssignmentQliks
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            FunctionMennu functionMennu = new FunctionMennu();
            int c;
            do
            {
                menu();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        functionMennu.Hotel();
                        break;
                    case 2:
                        functionMennu.Customer();
                        break;
                    case 3:
                        functionMennu.book();
                        break;
                    case 4:
                        functionMennu.Searching();
                        break;

                    case 5:
                        Console.WriteLine("Thoát !!");
                        break;


                    default:
                        Console.WriteLine("Lỗi !!");
                        break;
                }

            } while (c != 5);
        }
        static void menu()
        {
            Console.WriteLine("1.Khách sạn");
            Console.WriteLine("2.khách hàng");
            Console.WriteLine("3.Đặt Phòng");
            Console.WriteLine("4.Tìm kiếm");
            Console.WriteLine("5.Thoát !");
            Console.WriteLine("Chọn : ");
        }
    }
}




lê văn phương [T1907A]
lê văn phương

2020-06-03 09:34:34



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace QuanLyKhachSan
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        SqlConnection connection;
        SqlCommand command;
        string str = @"Data Source=DESKTOP-37PUKPU\A;Initial Catalog=QLKhachSan;Integrated Security=True";
        SqlDataAdapter adapter = new SqlDataAdapter();
        DataTable table = new DataTable();
        
      void loaddata()
        {
            command = connection.CreateCommand();
            command.CommandText = "select * from KhachHang";
            adapter.SelectCommand = command;
            table.Clear();
            adapter.Fill(table);
            dvg.DataSource = table;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            connection = new SqlConnection(str);
            connection.Open();
            loaddata();
        }

        private void dvg_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            txtmaphong.ReadOnly = true;
            int i;
            i = dvg.CurrentRow.Index;
            txtmaks.Text = dvg.Rows[i].Cells[0].Value.ToString();
            txtmaphong.Text = dvg.Rows[i].Cells[1].Value.ToString();
            txthoten.Text = dvg.Rows[i].Cells[2].Value.ToString();
            txtdiachi.Text = dvg.Rows[i].Cells[3].Value.ToString();
            txtgiaphong.Text = dvg.Rows[i].Cells[4].Value.ToString();
            txtsonguoi.Text = dvg.Rows[i].Cells[5].Value.ToString();
            cbtrangthai.Text = dvg.Rows[i].Cells[6].Value.ToString();
            cbloaiphong.Text = dvg.Rows[i].Cells[7].Value.ToString();
            dtpdate.Text = dvg.Rows[i].Cells[8].Value.ToString();
        }

        private void btnthem_Click(object sender, EventArgs e)
        {
            command = connection.CreateCommand();
            command.CommandText = "insert into KhachHang values('"+txtmaks.Text +"','"+txtmaphong.Text+"',N'" + txthoten.Text + "','" + txtdiachi.Text + "','" + txtgiaphong.Text + "','" + txtsonguoi.Text + "','" + cbtrangthai.Text + "','" + cbloaiphong.Text + "','" + dtpdate.Text + "')";
            command.ExecuteNonQuery();
            loaddata();

        }

        private void btnxoa_Click(object sender, EventArgs e)
        {
            command = connection.CreateCommand();
            command.CommandText = "delete  from KhachHang where maphong='"+txtmaphong.Text+"'";
            command.ExecuteNonQuery();
            loaddata();
        }

        private void btnsua_Click(object sender, EventArgs e)
        {
            command = connection.CreateCommand();
            command.CommandText = "update KhachHang set maphong= '"+ txtmaphong.Text + "',hoten='" + txthoten.Text + "',diachi='"+ txtdiachi.Text + "',giaphong= '"+ txtgiaphong.Text + "',songuoi='"+ txtsonguoi.Text + "',trangthai='"+ cbtrangthai .Text+ "',loaiphong='"+ cbloaiphong .Text+ "',ngayo='"+ dtpdate.Text+ "' where maks= '"+txtmaks.Text+"'";
            command.ExecuteNonQuery();
            loaddata();
        }

        private void btntimkiem_Click(object sender, EventArgs e)
        {
            string SqlSearch = "SELECT * FROM KhachHang WHERE maphong = @maphong";
            SqlCommand cmd = new SqlCommand(SqlSearch, connection);
            cmd.Parameters.AddWithValue("maphong", txtmaphong.Text);
            cmd.Parameters.AddWithValue("hoten", txthoten.Text);
            cmd.Parameters.AddWithValue("diachi", txtdiachi.Text);
            cmd.Parameters.AddWithValue("giaphong", txtgiaphong.Text);
            cmd.Parameters.AddWithValue("songuoi", txtsonguoi.Text);
            cmd.Parameters.AddWithValue("trangthai", cbtrangthai.Text);
            cmd.Parameters.AddWithValue("loaiphong", cbloaiphong.Text);
            cmd.Parameters.AddWithValue("ngayo", dtpdate.Text);
            cmd.ExecuteNonQuery();
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            dvg.DataSource = dt;
        }
    }
}



Trương Công Vinh [T1907A]
Trương Công Vinh

2020-06-03 07:18:10



using System;
using System.Collections.Generic;
using System.Text;

namespace Assignment
{
    class Customer
    {

        public string cmnd { get; set; }
        public string name { get; set; }
        public string gender { get; set; }
        public string address { get; set; }
        public int age { get; set; }
        public Customer()
        {

        }
        public Customer(string cmnd, string name, int age, string gender, string address)
        {
            this.address = address;
            this.age = age;
            this.cmnd = cmnd;
            this.gender = gender;
            this.name = name;
        }
        public void input(List<string> vs)
        {
            inputCmnd(vs);
            input(cmnd);
        }
        public void input(string cmnd)
        {
            this.cmnd = cmnd;
            inputName();
            inputAge();
            inputGender();
            inputaddress();
            
        }
        private void inputAge()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Age :");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    age = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }
        bool checkInt(string s)
        {
            bool check = true;
            foreach (char item in s)
            {
                if (item < 48 || item > 57)
                {
                    check = false;
                    break;
                }

            }
            return check;
        }
       
        private void inputCmnd(List<string> vs)
        {
            bool ischeck = false;
            for (; ischeck == false;)
            {
                Console.WriteLine("PersonalID : ");
                cmnd = Console.ReadLine();
                foreach (string str in vs)
                {
                    if (cmnd.Equals(str))
                    {
                        Console.WriteLine("PersonalID is exist !!");
                        ischeck = true;
                        break;
                    }
                }
                if (!ischeck && string.IsNullOrEmpty(cmnd) == false)
                {
                    vs.Add(cmnd);
                    ischeck = true;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                    ischeck = false;
                }
            }
        }
        private void inputGender()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Gender : ");
                gender = Console.ReadLine();
                if (string.IsNullOrEmpty(gender) == false)
                {
                    ischeck = false;
                }
            }

        }
        private void inputaddress()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Address : ");
                address = Console.ReadLine();
                if (string.IsNullOrEmpty(address) == false)
                {
                    ischeck = false;
                }
            }

        }
        private void inputName()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Name : ");
                name = Console.ReadLine();
                if (string.IsNullOrEmpty(name) == false)
                {
                    ischeck = false;
                }
            }

        }

        public void display()
        {
            Console.WriteLine("CMND : {0} , Fullname : {1} , Age : {2} , Gender : {3} , Address : {4}", cmnd, name, age, gender, address);
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Assignment
{
    class Management
    {
        List<Booking> bookings = new List<Booking>();
        List<Hotel> hotels = new List<Hotel>();
        List<Customer> customers = new List<Customer>();
        List<string> ids = new List<string>();
        public Management()
        {

        }
        public void Searching()
        {
            int c;
            do
            {
                menuSearch();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        Console.WriteLine("HotelId : ");
                        string str = Console.ReadLine();
                       bool isCheck = false;
                        foreach (var item in hotels)
                        {
                            if (item.hotelID.Equals(str))
                            {
                                item.display();
                                isCheck = true;
                                break;
                            }
                        }
                        if (!isCheck)
                        {
                            Console.WriteLine("Hotel is not Exit !!");
                        }
                        break;
                    case 2:
                        Console.WriteLine("HotelId : ");
                         str = Console.ReadLine();
                         isCheck = false;
                        foreach (var item in customers)
                        {
                            if (item.cmnd.Equals(str))
                            {
                                item.display();
                                isCheck = true;
                                break;
                            }
                        }
                        if (!isCheck)
                        {
                            Console.WriteLine("Customer is not Exit !!");
                        }
                        break;
                    case 3:
                        Console.WriteLine("HotelId : ");
                         str = Console.ReadLine();
                         isCheck = false;
                        foreach (var item in hotels)
                        {
                            if (item.hotelID.Equals(str))
                            {
                                foreach (Room room in item.rooms)
                                {
                                    room.display();
                                }
                                isCheck = true;
                                break;
                            }
                        }
                        if (!isCheck)
                        {
                            Console.WriteLine("Hotel is not Exit !!");
                        }
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 4);
        }
        public void book()
        {
            
            int c;
            do
            {
                menuBooking();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        Booking booking = new Booking();
                        booking.input(hotels,customers,ids);
                        bookings.Add(booking);
                        break;
                    case 2:
                        foreach (var item in bookings)
                        {
                            item.display();
                        }
                        break;
                    case 3:
                        showRoomByDate(bookings,hotels);
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 4);
        }
        public void showRoomByDate(List<Booking> books, List<Hotel> hotels)
        {
            if (hotels.Count == 0)
            {
                Console.WriteLine("khong co data!!!");
                return;
            }

            Hotel currentHotel = null;
            for (; ; )
            {
                foreach (Hotel hotel in hotels)
                {
                    Console.WriteLine("Ma KS: {0}, Ten KS: {1}", hotel.hotelID, hotel.name);
                }
                Console.WriteLine("Enter hotelID : ");
                string hotelID = Console.ReadLine();
                foreach (Hotel hotel in hotels)
                {
                    if (hotel.hotelID.Equals(hotelID))
                    {
                        currentHotel = hotel;
                        break;
                    }
                }
                if (currentHotel != null)
                {
                    break;
                }
                Console.WriteLine("(Not Found) Nhap lai: ");
            }
            if (currentHotel.rooms.Count == 0)
            {
                Console.WriteLine("khong co data!!!");
                return;
            }

            Console.WriteLine("Ngay CheckIn (dd/mm/YYYY): ");
            string dateTime = Console.ReadLine();
            DateTime CheckIn = DateTime.ParseExact(dateTime, "dd/MM/yyyy", null);

            Console.WriteLine("Ngay CheckOut (dd/mm/YYYY): ");
            dateTime = Console.ReadLine();
            DateTime CheckOut = DateTime.ParseExact(dateTime, "dd/MM/yyyy", null);


            foreach (var room in currentHotel.rooms)
            {
                List<Booking> currentBooking = new List<Booking>();

                foreach (var book in books)
                {

                    if (book.hotelID.Equals(currentHotel.hotelID) && book.roomCode.Equals(room.roomCode))
                    {
                        currentBooking.Add(book);
                    }


                }
                bool isFind = false;
                foreach (var book in currentBooking)
                {
                    if (DateTime.Compare(book.checkin, CheckOut) > 0 || DateTime.Compare(book.checkout, CheckIn) < 0)
                    {
                        //room dat yeu cau
                    }
                    else
                    {
                        isFind = true;
                        break;
                    }

                }
                if (!isFind)
                {
                    Console.WriteLine("Room No: {0}, Room Name: {1}", room.roomCode, room.roomName);
                }

            }

        }
        public void Customer()
        {
            
            CustomerModify customerModify = new CustomerModify();
            
            int c;
            do
            {
                menuCustomer();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        customerModify.addCustomer(customers, ids);
                        break;
                    case 2:
                        customerModify.editCustomer(customers);
                        break;
                    case 3:
                        customerModify.deleteCustomer(customers);
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 4);
        }

        public void Hotel()
        {
            

            hotelModify hotelModify = new hotelModify();
            int c;
            do
            {
                menuHotel();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        hotelModify.addHotel(hotels,ids);
                        break;
                    case 2:
                        hotelModify.editHotel(hotels,ids);
                        break;
                    case 3:
                        hotelModify.deleteCustomer(hotels, ids);
                        break;

                    case 4:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c!=4);

        }
        private void menuHotel()
        {
            Console.WriteLine("1.Add Hotel");
            Console.WriteLine("2.Edit Hotel");
            Console.WriteLine("3.Dlete Hotel");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("Choose : ");
        }
        private void menuCustomer()
        {
            Console.WriteLine("1.Add Customer");
            Console.WriteLine("2.Edit Customer");
            Console.WriteLine("3.Dlete Customer");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("Choose : ");
        }
        private void menuBooking()
        {
            Console.WriteLine("1.Add Booking");
            Console.WriteLine("2.Show Booking");
            Console.WriteLine("3.Show room list available");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("Choose : ");
        }
        private void menuSearch()
        {
            Console.WriteLine("1.Search hotel");
            Console.WriteLine("2.Search Customer");
            Console.WriteLine("3.Search room");
            Console.WriteLine("4.Exit !");
            Console.WriteLine("Choose : ");
        }


    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Assignment
{
    class Booking
    {

        public DateTime checkin { get; set; }
        public DateTime checkout { get; set; }
        public string cmnd { get; set; }

        public string hotelID { get; set; }

        public string roomCode { get; set; }


        public Booking()
        {

        }
        public void display()
        {
            Console.WriteLine("CheckIn : {0} , CheckOut : {1} , Cmnd : {2} , HotelID : {3} , roomID : {4}", checkin, checkout, cmnd,hotelID, roomCode);
        }
        public void input(List<Hotel> hotels, List<Customer> customers, List<string> ids)
        {
            string strDatetime = null;
            while (string.IsNullOrEmpty(strDatetime))
            {
                Console.WriteLine("Ngay book (dd/mm/YYYY): ");
                 strDatetime = Console.ReadLine();
                checkin = DateTime.ParseExact(strDatetime, "dd/MM/yyyy", null);
            }
            strDatetime = null;
            while (string.IsNullOrEmpty(strDatetime))
            {
                Console.WriteLine("Ngay tra phong (dd/mm/YYYY): ");
                strDatetime = Console.ReadLine();
                checkout = DateTime.ParseExact(strDatetime, "dd/MM/yyyy", null);
            }
            inputCMND(customers);
            inputHotelID(hotels,ids);
        }
        private void inputCMND(List<Customer> customers)
        {
            bool dk = false;
            Console.WriteLine("Enter PersonID : ");
            string find = Console.ReadLine();
            foreach (var item in customers)
            {
                if (find.Equals(item.cmnd))
                {
                    cmnd = find;
                    dk = true;
                    break;
                }
            }
            if (!dk)
            {
                Console.WriteLine("nhập thông tin Customer");
                Customer customer = new Customer();
                customer.input(find);
                customers.Add(customer);
                cmnd = customer.cmnd;
            }

        }
        private void inputHotelID(List<Hotel> hotels,List<string> ids)
        {
            bool dk = false;
            Console.WriteLine("Enter hotelID : ");
            string find = Console.ReadLine();
            foreach (var item in hotels)
            {
                if (find.Equals(item.hotelID))
                {
                    hotelID = find;
                    dk = true;
                    break;
                }
            }
            if (!dk)
            {
                Console.WriteLine("nhập thông tin hotel : ");
                Hotel hotel = new Hotel();
                hotel.input(ids);
                hotelID = hotel.hotelID;
                hotels.Add(hotel);
            }
            foreach (var item in hotels)
            {
                if (hotelID.Equals(item.hotelID))
                {
                    findRoom(item);
                }
            }


        }

        private void findRoom(Hotel hotel)
        {
            bool dk = true;
            while (dk)
            {
                foreach (Room item in hotel.rooms)
                {
                    item.display();
                }
                Console.WriteLine("Enter roomCode to book : ");
                string check;
                check = Console.ReadLine();
                foreach (Room item in hotel.rooms)
                {
                    if (check.Equals(item.roomCode))
                    {
                        roomCode = check;
                        dk = false;
                        break;
                    }
                }
                if (dk)
                {
                    Console.WriteLine("ma phong sai !!");
                }
            }
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Assignment
{
    class hotelModify
    {
        public hotelModify()
        {

        }
        public void addHotel(List<Hotel> hotels, List<string> ids)
        {
            Hotel hotel = new Hotel();
            hotel.input(ids);
            hotels.Add(hotel);
        }
        public void editHotel(List<Hotel> hotels, List<string> ids)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Enter HotelID to edit : ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (Hotel h in hotels)
                {
                    if (str.Equals(h.hotelID))
                    {
                        h.input(str, ids);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("PersonalID is Not exist !!");
                }


            }
        }
        public void deleteCustomer(List<Hotel> hotels, List<string> ids)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Enter HotelID to delete : ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (Hotel h in hotels)
                {
                    if (str.Equals(h.hotelID))
                    {
                        hotels.Remove(h);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("PersonalID is Not exist !!");
                }


            }


        }
    }
}




using System;
using System.Collections.Generic;
using System.Text;

namespace Assignment
{
    class Room
    {
        public string roomName { get; set; }
        public int floorNumber { get; set; }
        public int maxPerson { get; set; }
        public int price { get; set; }
        public string roomCode { get; set; }

        public Room()
        {

        }
        public Room(string roomName, int floorNumber, int maxPerson, int price, string roomCode)
        {
            this.floorNumber = floorNumber;
            this.maxPerson = maxPerson;
            this.price = price;
            this.roomCode = roomCode;
            this.roomName = roomName;
        }
        public void input(List<string> vs)
        {
            inputRoomName();
            inputfloorNumber();
            inputmaxPerson();
            inputprice();
            inputRoomCode(vs);
        }
        private void inputfloorNumber()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("tang  : ");

                string c2 = Console.ReadLine();
                if (checkInt(c2) &&  string.IsNullOrEmpty(c2) == false)
                {
                    floorNumber = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }
        private void inputmaxPerson()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("so nguoi toi da : ");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    maxPerson = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }

        private void inputprice()
        {


            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("gia phong 1 ngay : ");

                string c2 = Console.ReadLine();
                if (checkInt(c2) && string.IsNullOrEmpty(c2) == false)
                {
                    price = int.Parse(c2);
                    ischeck = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                }
            }

        }
        bool checkInt(string s)
        {
            bool check = true;
            foreach (char item in s)
            {
                if (item < 48 || item > 57)
                {
                    check = false;
                    break;
                }

            }
            return check;
        }
        private void inputRoomCode(List<string> vs)
        {
            bool ischeck = false;
            for (; ischeck == false;)
            {
                Console.WriteLine("ma phong : ");
                roomCode = Console.ReadLine();
                foreach (string str in vs)
                {
                    if (roomCode.Equals(str))
                    {
                        Console.WriteLine("PersonalID is exist !!");
                        ischeck = true;
                        break;
                    }
                }
                if (!ischeck && string.IsNullOrEmpty(roomCode) == false)
                {
                    vs.Add(roomCode);
                    ischeck = true;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                    ischeck = false;
                }
            }
        }
        private void inputRoomName()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("ten phong : ");
                roomName = Console.ReadLine();
                if (string.IsNullOrEmpty(roomName) == false)
                {
                    ischeck = false;
                }
            }

        }
        public void display()
        {
            Console.WriteLine("roomName : {0} , numberFloor : {1} , maxPerson : {2} , Price : {3} , roomCode : {4}", roomName, floorNumber, maxPerson, price, roomCode);

        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Assignment
{
    class Hotel
    {
        public string name { get; set; }
        public string address { get; set; }
        public string Rank { get; set; }

        public List<Room> rooms { get; set; }

        public string hotelID { get; set; }
        public Hotel()
        {
            rooms = new List<Room>();
        }
        public void input(List<string> ids)
        {

            inputHotelID(ids);
            input(hotelID,ids);
        }
        public void input(string hotelID, List<string> ids)
        {
            inputHotelName();
            inputHotelAddress();
            rankHotel();


            inputRoom(rooms,ids);
            this.hotelID = hotelID;

        }
        private void inputHotelID(List<string> vs)
        {
            bool ischeck = false;
            for (; ischeck == false;)
            {
                Console.WriteLine("HotelID : ");
                hotelID = Console.ReadLine();
                foreach (string str in vs)
                {
                    if (hotelID.Equals(str))
                    {
                        Console.WriteLine("PersonalID is exist !!");
                        ischeck = true;
                        break;
                    }
                }
                if (!ischeck && string.IsNullOrEmpty(hotelID) == false)
                {
                    vs.Add(hotelID);
                    ischeck = true;
                    break;
                }
                else
                {
                    Console.WriteLine("Error !!");
                    ischeck = false;
                }
            }
        }
        private void inputHotelName()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Name of Hotel  : ");
                name = Console.ReadLine();
                if (string.IsNullOrEmpty(name) == false)
                {
                    ischeck = false;
                }
            }

        }
        private void inputHotelAddress()
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Address of hotel : ");
                address = Console.ReadLine();
                if (string.IsNullOrEmpty(address) == false)
                {
                    ischeck = false;
                }
            }

        }
        public void display()
        {
            Console.WriteLine("hotelName : {0} , Address : {1} , Level : {2} , hotelID : {3} ", name, address, Rank, hotelID);
            Console.WriteLine("List of Room  : ");
            foreach (var item in rooms)
            {
                item.display();
            }
            Console.WriteLine("------------------------------------------------------------");

        }

        private void inputRoom(List<Room> rooms,List<string> ids)
        {
            Console.WriteLine("Seting Room's Information : ");
            for (; ; )
            {
                Room room = new Room();
                room.input(ids);
                rooms.Add(room);
                Console.WriteLine("add room : (y/n)");
                string option = Console.ReadLine();
                if (option.Equals("n"))
                {
                    break;
                }
            }
        }

        private void rankHotel()
        {
            bool dk = true;
            while (dk)
            {
                Console.WriteLine("1.VIP");
                Console.WriteLine("2.Normal");
                Console.WriteLine("Choose : ");
                int choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Rank = "VIP";
                        dk = false;
                        break;
                    case 2:
                        Rank = "Normal";
                        dk = false;
                        break;
                    default:
                        Console.WriteLine("Error !! ");

                        break;

                }
            }
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Assignment
{
    class CustomerModify
    {
        public CustomerModify()
        {

        }
        public void addCustomer(List<Customer> customers,List<string> ids)
        {
            Customer customer = new Customer();
            customer.input(ids);
            customers.Add(customer);
        }
        public void editCustomer(List<Customer> customers)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Enter PersonalID to edit : ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (Customer cus in customers)
                {
                    if (str.Equals(cus.cmnd))
                    {
                        cus.input(str);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("PersonalID is Not exist !!");
                }
                

            }
        }
        public void deleteCustomer(List<Customer> customers)
        {
            bool ischeck = true;
            while (ischeck)
            {
                Console.WriteLine("Enter PersonalID to delete : ");
                string str = Console.ReadLine();
                bool isCheck = false;
                foreach (Customer cus in customers)
                {
                    if (str.Equals(cus.cmnd))
                    {
                        customers.Remove(cus);
                        ischeck = false;
                        isCheck = true;
                        break;
                    }
                }
                if (!isCheck)
                {
                    Console.WriteLine("PersonalID is Not exist !!");
                }


            }
        }

    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Assignment
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Management management = new Management();
            int c;
            do
            {
                menu();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        management.Hotel();
                        break;
                    case 2:
                        management.Customer();
                        break;
                    case 3:
                        management.book();
                        break;
                    case 4:
                        management.Searching();
                        break;

                    case 5:
                        Console.WriteLine("EXIT !!");
                        break;


                    default:
                        Console.WriteLine("Error !!");
                        break;
                }

            } while (c != 5);
        }
        static void menu()
        {
            Console.WriteLine("1.Hotel");
            Console.WriteLine("2.Customer");
            Console.WriteLine("3.Booking the room");
            Console.WriteLine("4.Search");
            Console.WriteLine("5.Exit !");
            Console.WriteLine("Choose : ");
        }
    }
}