IMG-LOGO
×

Giáo Trình Học

Khoá học lập trình C# (.NET Core)

Kiến Thức Căn Bản - Khai Báo Biến, Toán Tử, Mệnh Đề Điều Kiện, Lặp

[Video] Giới thiệu về ngôn ngữ lập trình C# & .NET Framework + Khai báo biến trong C# [Video] Hướng dẫn tìm hiểu biến + toán tử trong lập trình C# [Video] Hướng dẫn tìm hiểu mệnh đề điều kiện if - else - switch trong C# [Video] Tìm dãy số nguyên tố - Lập trình C# - Loop trong C# [Video] In dãy số chẵn & lẻ từ mảng số nguyên - Lập trình C# - Loop trong C#




Trang Chủ 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

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

by GokiSoft.com - 09:41 01/11/2021 15,498 Lượt Xem

Đề 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.


Bình luận



Chia sẻ từ lớp học

Phí Văn Long [T1907A]

Ngày viết: 23:07 03/06/2020

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]

Ngày viết: 22:40 03/06/2020

Đường Thanh Bình [T1907A]

Ngày viết: 21:46 03/06/2020



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]

Ngày viết: 16:34 03/06/2020



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]

Ngày viết: 14:18 03/06/2020



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 : ");
        }
    }
}


Phân Loại Bài Viết

Tài Liệu Tham Khảo

Ứng Dụng Tiện Ích



Đã sao chép!!!