Tải bản đầy đủ (.docx) (18 trang)

ĐÁP ÁN FULL CODE VÀ HÌNH BTNT ASSIGMENT FINAL QUẢN LÝ AIRPORT

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (316.57 KB, 18 trang )

Create a C# Windows form program to manage an airport with fixed wing airplane and helicopter

Require 001: Business need
Create a C# Windows form program to manage an airport with fixed wing airplane and helicopter

Require 002: Working requirement
Working time: 3hrs
Working environment: Visual Studio.Net 2010 IDE, NUnit, log4Net and FxCop 10.0 on local PC, no internet
connection
Delivery: Source code and testing, reviewing evident packaged in a compress archive,

Require 003: Product architecture
The product is implemented using MVC pattern

Require 004: Technology
The product implements all terminology of Object Oriented Programming paradigm:
• Encapsulation,









Overload,
Inheritance,
Override,
Feature Hiding,
Polymorphism,


Abstract airport
Interface

Require 005: Input data






The product gets input data from an input file
An input file is a csv file
The input file contains the information about 25 fixed wing airplanes, each one in one input line. Each fixed
wing airplane has its ID, model, plane type, cruise speed, empty weight, max takeoff weight, min needed
runway size.
The input file contains the information about 40 helicopters, each one in one input line. Each helicopter has
its ID, model, cruise speed, empty weight, max takeoff weight, range
The input file contains the information about 4 airports, each one in one input line. Each airport has an ID, a
name, runway size, max fixed wing parking place, list of fixed wing airplane ID, max rotated wing parking
place, list of helicopter ID.

Require 006: Data constraint
In the input data has followed constraints:
• ID is a string of 7 characters, started by “FW” for fixed wing airplane, “RW” for helicopter and “AP” for airport,
followed by 5 digits. ID is unique
• The model size is maximum 40 characters



Three fixed wing airplane type are CAG (Cargo), LGR (Long range) and PRV (Private)


Require 007: Airport Management








The program has function to create and to delete an airport. The name, runway size and capacity of the new
airport are selected when a new airport is creating.
The program has function to add to an airport one or more fixed wing airplane(s) which currently does not
participate to an airport and which has the min needed runway size shorter than the airport runway size.
The program has function to remove one or more helicopter(s) from an airport.
The program has function to add to an airport one or more helicopter(s) which currently does not participate
to an airport.
The program has function to remove one or more helicopter(s) from an airport having.

Require 008: Plane management





The program has function to change plane type and min needed runway size of fixed wing airplane
If a fixed wing airplane is parked in an airport, its min runway size does not excess the airport runway size.
The program has function to cruise speed and max takeoff weight of helicopter.
The max takeoff weight of helicopter does not excess 1.5 times of its empty weight


Require 009: Output data

o
o




The program has function to save the data of an airport, having a valid data to an output file




The output file is a csv file

An airport, having a valid data is an airport having
At least 5 fixed wing airplanes
At least 10 helicopters

The output data of an airport is
o
In the first line: Airport ID, name, runway size, capacity
o
Fixed wing airplane information, sorted by range and min needed runway size from higher to lower
o
Information of each fixed wing airplane is in one output line
o
Helicopter information, sorted by range and max takeoff weight from higher to lower
o
Information of each helicopter is in one output line

o
The plan – fixed wing and helicopter – information will be followed by its fly method – “fixed wing” for fixed wing
airplane and “rotated wing” for helicopter.

Require 010: Main Interface
The main windows form contains the control for:
• Data input group.
o
This group allows inputting data from file. The input data file can be selected by file selection dialog

• Airport management group
o
The window form must follow the requirement 009 and
o
The window form must display information about 5 airports and allows selecting any airport for management
action
• Fixed wing airplane management group
o
The window form must follow the requirement 010 and
o
The window form must display the information of one fixed wing airplane and allows selecting any fixed wing
airplane for management action
• Helicopter management group
o
The window form must follow the requirement 010 and


o
The window form must display the information of one helicopter and allows selecting any helicopter for
management action

• Close program
Each unsuccessful action will be informed to user by a message box

Require 011: Testing
The product is tested pass in user case level

Require 012: Coding review
The product is tested with no error message in FxCop tool

Require 013: Logging
The product running is logged in method level using Log4Net

Note scale
Require 001: Business need

o
o
o
o
o
o
o




Data input 10p





Fixed wing airplane management 6p. Each data 3p

Airport management 50p
Create airport 5p
Delete airport 5p
Save data 8p
Add fixed wing airplane 8p
Remove fixed wing airplane 8p
Add helicopter 8p
Remove helicopter 8p
Helicopter management: 6p. Each data 3p

Require 003: Product architecture
5p

Require 004: Technology
Each complete terminology 1p: total 8p

Require 011: Testing
Total 5p, each error found decreases 1p, minimum 0p

Require 012: Coding review
Total 5p, each error found decreases 1p, minimum 0p


Require 013: Logging
Total 5p, each error found decreases 1p, minimum 0p

TẠO CLASS KẾT NỐI

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QUANLY_AIRPORT
{
class ketnoi
{
static string chuoiketnoi = @"Data source=VAIO;Database=QUANLY_AIRPORT;Integrated security=True";
public SqlConnection conn = new SqlConnection(chuoiketnoi);
public void KetNoi()
{
try
{
conn.Open();
Console.WriteLine("Ket noi thanh cong !!!");
Console.ReadLine();
}
catch
{
Console.WriteLine("Ket noi that bai !");
Console.ReadLine();
}
finally
{
conn.Close();
}
}

}
}

TẠO CLASS MENU
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QUANLY_AIRPORT
{
class menu
{
sanbay sb = new sanbay();
maybay mb = new maybay();
Tructhang tt = new Tructhang();


public void menusanbay()
{
ketnoi kn = new ketnoi();
kn.conn.Open();
int chon;
do
{
Console.Clear();
Console.WriteLine("\n===================================");
Console.WriteLine("\n 1) Them San Bay");
Console.WriteLine("\n 2) Xoa San Bay");
Console.WriteLine("\n 3) Xem San Bay");

Console.WriteLine("\n 4) Them May Bay Vao San Bay");
Console.WriteLine("\n 5) Xoa May Bay Khoi San Bay");
Console.WriteLine("\n 6) Them Truc Thang Vao San Bay");
Console.WriteLine("\n 7) Xoa Truc Thang Khoi San Bay");
Console.WriteLine("\n 8) Thoat");
Console.WriteLine("\n Vui long chon chuc nang!");
Console.WriteLine("\n===================================");
chon = int.Parse(Console.ReadLine());
switch (chon)
{
case 1: sb.Nhap(); break;
case 2: sb.Xoa(); break;
case 3: sb.XuatSanbay(); break;
case 4: mb.NhapMBSB(); break;
case 5: mb.XoaMBSB(); break;
case 6: tt.NhapTTSB(); break;
case 7: tt.XoaTTSB(); break;
case 8: break;
}
} while (chon != 8);
}
public void menumaybay()
{
ketnoi kn = new ketnoi();
kn.conn.Open();
int chon;
do
{
Console.Clear();
Console.WriteLine("\n===============================");

Console.WriteLine("\n 1) Them May Bay");
Console.WriteLine("\n 2) Xoa May Bay");
Console.WriteLine("\n 3) Xuat May Bay");
Console.WriteLine("\n 4) Sua Loai May Bay");
Console.WriteLine("\n 5) Sua KTDB May Bay");
Console.WriteLine("\n 6) Thoat");
Console.WriteLine("\n Vui long chon chuc nang!");
Console.WriteLine("\n===============================");
chon = int.Parse(Console.ReadLine());
switch (chon)
{
case 1: mb.nhap(); break;


case 2: mb.Xoa(); break;
case 3: mb.XuatMaybay(); break;
case 4: mb.SuaLoai(); break;
case 5: mb.SuaKichThuoc(); break;
case 6: break;
}
} while (chon != 6);
}
public void menutructhang()
{
ketnoi kn = new ketnoi();
kn.conn.Open();
int chon;
do
{
Console.Clear();

Console.WriteLine("\n==============================");
Console.WriteLine("\n 1) Them Truc Thang");
Console.WriteLine("\n 2) Xoa Truc Thang");
Console.WriteLine("\n 3) Xuat Truc Thang");
Console.WriteLine("\n 4) Thoat");
Console.WriteLine("\n Vui long chon chuc nang!");
Console.WriteLine("\n===============================");
chon = int.Parse(Console.ReadLine());
switch (chon)
{
case 1: tt.nhap(); break;
case 2: tt.Xoa(); break;
case 3: tt.XuatTructhang(); break;
case 4: break;
}
} while (chon != 4);
}
}
}

TẠO CLASS MÁY BAY
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
namespace QUANLY_AIRPORT
{

class maybay
{
private string idmb;
public string Idmb


{
get { return idmb; }
set { idmb = value; }
}
private string model;
public string Model
{
get { return model; }
set { model = value; }
}
private string cruisespeed;
public string Cruisespeed
{
get { return cruisespeed; }
set { cruisespeed = value; }
}
public string Loai
{
get { return loai; }
set { loai = value; }
}
private string emptyweight;
public string Emptyweight
{

get { return emptyweight; }
set { emptyweight = value; }
}
private string maxtakeoffweight;
public string Maxtakeoffweight
{
get { return maxtakeoffweight; }
set { maxtakeoffweight = value; }
}
private string minneededrunwaysize;
public string minneededrunwaysize1
{
get { return minneededrunwaysize; }
set { minneededrunwaysize = value; }
}
private string idsb;
public string Idsb
{
get { return idsb; }
set { idsb = value; }
}
private string loai;
public void ThemMaybay(maybay mb)
{
ketnoi kn = new ketnoi();


kn.conn.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO
MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES ('" +

mb.Idmb + "','" + mb.model + "','" + mb.Cruisespeed + "','" + mb.Loai + "'," + mb.Emptyweight + ",'" +
mb.Maxtakeoffweight + "','" + mb.minneededrunwaysize + "')", kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nThem thanh cong");
kn.conn.Close();
}
public void XoaMaybay(maybay mb)
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("Delete MAYBAY from MAYBAY where IDMB='" + mb.Idmb + "'", kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nXoa thanh cong");
kn.conn.Close();
}
public void XuatMaybay()
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM MAYBAY", kn.conn);
SqlDataAdapter sdr = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sdr.Fill(dt);
foreach (DataRow Row in dt.Rows)
{
Console.Clear();
Console.WriteLine("ID May Bay : {0} \n\nModel : {1} \n\nToc do : {2} \n\nLoai May Bay : {7} \n\nSuc chua : {3}
\n\nSuc chua toi da : {4} \n\nkich thuoc duong bang : {5} \n\nID San Bay : {6}", Row["IDMB"], Row["model"],
Row["cruisespeed"], Row["emptyweight"], Row["maxtakeoffweight"], Row["minneededrunwaysize"], Row["IDSB"],
Row["Loai"]);

Console.WriteLine("\n\n\nBam Enter de quay lai menu");
}
Console.ReadLine();
}
public void SuaLoaiMaybay(maybay mb)
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("UPDATE MAYBAY SET loai='" + mb.Loai + "' where IDMB='" + mb.Idmb +
"'", kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nSua may bay {0} thanh loai {1} thanh cong", mb.Idmb, mb.Loai);
kn.conn.Close();
}
public void SuaKTMaybay(maybay mb)
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("update MAYBAY set minneededrunwaysize='" + mb.minneededrunwaysize1 +
"' where IDMB='" + mb.Idmb + "'", kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nSua may bay {0} co kich thuoc duong bang {1} thanh cong", mb.Idmb,
mb.minneededrunwaysize1);


kn.conn.Close();
}
public void ThemMBVaoSanBay(maybay mb)
{
ketnoi kn = new ketnoi();

kn.conn.Open();
SqlCommand cmd = new SqlCommand("update MAYBAY set IDSB='" + mb.Idsb + "' where IDMB='" + mb.Idmb + "'",
kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nThem may bay {0} vao san bay {1} thanh cong", mb.Idmb, mb.Idsb);
kn.conn.Close();
}
public void XoaMBKhoiSanBay(maybay mb)
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("update MAYBAY set IDSB='NULL' where IDMB='" + mb.Idmb + "'",
kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nXoa may bay {0} ra khoi san bay thanh cong", mb.Idmb);
kn.conn.Close();
}
public void nhap()
{
maybay mb = new maybay();
Console.Clear();
Console.Write("\nNhap Id May Bay : ");
mb.Idmb = Console.ReadLine();
Console.Write("\nNhap model may bay : ");
mb.Model = Console.ReadLine();
Console.Write("\nNhap toc do may bay : ");
mb.Cruisespeed = Console.ReadLine();
Console.Write("\nNhap loai may bay : ");
mb.Loai = Console.ReadLine();
Console.Write("\nNhap cho chua : ");

mb.Emptyweight = Console.ReadLine();
Console.Write("\nNhap cho chua toi da : ");
mb.Maxtakeoffweight = Console.ReadLine();
Console.Write("\nNhap kich thuoc duong bang : ");
mb.minneededrunwaysize1 = Console.ReadLine();
mb.ThemMaybay(mb);
Console.ReadLine();
}
public void Xoa()
{
maybay mb = new maybay();
Console.Clear();
Console.Write("\nNhap Id May Bay can xoa : ");
mb.Idmb = Console.ReadLine();
mb.XoaMaybay(mb);
Console.ReadLine();
}
public void NhapMBSB()
{
maybay mb = new maybay();


Console.Clear();
Console.Write("\nNhap Id May Bay can them : ");
mb.Idmb = Console.ReadLine();
Console.Write("\nNhap Id San Bay can them : ");
mb.idsb = Console.ReadLine();
mb.ThemMBVaoSanBay(mb);
Console.ReadLine();
}

public void XoaMBSB()
{
maybay mb = new maybay();
Console.Clear();
Console.Write("\nNhap Id May Bay can Xoa Khoi San Bay : ");
mb.Idmb = Console.ReadLine();
mb.ThemMBVaoSanBay(mb);
Console.ReadLine();
}
public void SuaLoai()
{
maybay mb = new maybay();
Console.Clear();
Console.Write("\nNhap Id May Bay can sua : ");
mb.Idmb = Console.ReadLine();
Console.Write("\nNhap Loai May bay muon doi : ");
mb.Loai = Console.ReadLine();
mb.SuaLoaiMaybay(mb);
Console.ReadLine();
}
public void SuaKichThuoc()
{
maybay mb = new maybay();
Console.Clear();
Console.Write("\nNhap Id May Bay can sua : ");
mb.Idmb = Console.ReadLine();
Console.Write("\nNhap KTDB May bay muon doi : ");
mb.minneededrunwaysize1 = Console.ReadLine();
mb.SuaKTMaybay(mb);
Console.ReadLine();

}
}
}

TẠO CLASS SÂN BAY
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QUANLY_AIRPORT
{
class sanbay


{
private string idsb;
public string Idsb
{
get { return idsb; }
set { idsb = value; }
}
private string ten;
public string Ten
{
get { return ten; }
set { ten = value; }
}

private string minneededrunwaysize;
public string Minneededrunwaysize
{
get { return minneededrunwaysize; }
set { minneededrunwaysize = value; }
}
private string maxfixedwingparkingplace;
public string Maxfixedwingparkingplace
{
get { return maxfixedwingparkingplace; }
set { maxfixedwingparkingplace = value; }
}

public void ThemSanbay(sanbay sb)
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO SANBAY
(IDSB,TEN,minneededrunwaysize,maxfixedwingparkingplace) VALUES ('" + sb.Idsb + "','" + sb.Ten + "','" +
sb.Minneededrunwaysize + "'," + sb.Maxfixedwingparkingplace + ")", kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nThem thanh cong");
kn.conn.Close();
}
public void XuatSanbay()
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM SANBAY", kn.conn);
SqlDataAdapter sdr = new SqlDataAdapter(cmd);

DataTable dt = new DataTable();
sdr.Fill(dt);
foreach (DataRow Row in dt.Rows)
{
Console.Clear();


Console.WriteLine("ID San Bay : {0} \n\nTen San Bay : {1} \n\nKich thuoc duong bang : {2} \n\nCho dap may bay toi
da : {3} ", Row["IDSB"], Row["TEN"], Row["minneededrunwaysize"], Row["maxfixedwingparkingplace"]);
Console.WriteLine("\n\n\nBam Enter de quay lai menu");
}
Console.ReadLine();
}
public void XoaSanbay(sanbay sb)
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("Delete SANBAY from SANBAY where IDSB ='" + sb.Idsb + "'", kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nXoa thanh cong");
kn.conn.Close();
}
public void Nhap()
{
sanbay sb = new sanbay();
Console.Clear();
Console.Write("\nNhap Id San Bay : ");
sb.Idsb = Console.ReadLine();
Console.Write("\nNhap ten san bay : ");
sb.Ten = Console.ReadLine();

Console.Write("\nNhap kich thuoc duong bang : ");
sb.Minneededrunwaysize = Console.ReadLine();
Console.Write("\nNhap noi dap may bay toi da : ");
sb.Maxfixedwingparkingplace = Console.ReadLine();
sb.ThemSanbay(sb);
Console.ReadLine();
}
public void Xoa()
{
sanbay sb = new sanbay();
Console.Clear();
Console.Write("\nNhap Id San Bay can xoa : ");
sb.Idsb = Console.ReadLine();
sb.XoaSanbay(sb);
Console.ReadLine();
}
}
}

TẠO CLASS TRỰC THĂNG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
namespace QUANLY_AIRPORT
{



class Tructhang
{
private string idtt;
public string Idtt
{
get { return idtt; }
set { idtt = value; }
}
private string model;
public string Model
{
get { return model; }
set { model = value; }
}
private string cruisespeed;
public string Cruisespeed
{
get { return cruisespeed; }
set { cruisespeed = value; }
}
private string emptyweight;
public string Emptyweight
{
get { return emptyweight; }
set { emptyweight = value; }
}
private string maxtakeoffweight;
public string Maxtakeoffweight
{

get { return maxtakeoffweight; }
set { maxtakeoffweight = value; }
}
private string minneededrunwaysize;
public string minneededrunwaysizeTT
{
get { return minneededrunwaysize; }
set { minneededrunwaysize = value; }
}
private string idsb;
public string Idsb
{
get { return idsb; }
set { idsb = value; }
}
public void ThemTructhang(Tructhang tt)
{
ketnoi kn = new ketnoi();
kn.conn.Open();


SqlCommand cmd = new SqlCommand("INSERT INTO
TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES ('" + tt.Idtt +
"','" + tt.model + "','" + tt.Cruisespeed + "'," + tt.Emptyweight + ",'" + tt.Maxtakeoffweight + "','" +
tt.minneededrunwaysizeTT + "')", kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\n Them thanh cong");
kn.conn.Close();
}
public void XoaTructhang(Tructhang tt)

{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("Delete TRUCTHANG from TRUCTHANG where IDTT='" + tt.Idtt + "'",
kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nXoa thanh cong");
kn.conn.Close();
}
public void XuatTructhang()
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM TRUCTHANG", kn.conn);
SqlDataAdapter sdr = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sdr.Fill(dt);
foreach (DataRow Row in dt.Rows)
{
Console.Clear();
Console.WriteLine("ID Truc Thang : {0} \n\nModel : {1} \n\nToc do : {2} \n\nSuc chua : {3} \n\nSuc chua toi da : {4}
\n\nkich thuoc duong bang : {5} \n\nID San Bay : {6}", Row["IDTT"], Row["model"], Row["cruisespeed"],
Row["emptyweight"], Row["maxtakeoffweight"], Row["minneededrunwaysize"], Row["IDSB"]);
Console.WriteLine("\n\n\nBam Enter de quay lai menu");
}
Console.ReadLine();
}
public void ThemTTVaoSanBay(Tructhang tt)
{
ketnoi kn = new ketnoi();

kn.conn.Open();
SqlCommand cmd = new SqlCommand("update TRUCTHANG set IDSB='" + tt.Idsb + "' where IDTT='" + tt.Idtt + "'",
kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nThem truc thang {0} vao san bay {1} thanh cong", tt.Idtt, tt.Idsb);
kn.conn.Close();
}
public void XoaTTKhoiSanBay(Tructhang tt)
{
ketnoi kn = new ketnoi();
kn.conn.Open();
SqlCommand cmd = new SqlCommand("update TRUCTHANG set IDSB='NULL' where IDTT='" + tt.Idtt + "'",
kn.conn);
cmd.ExecuteNonQuery();
Console.WriteLine("\nXoa truc thang {0} vao san bay thanh cong", tt.Idtt);
kn.conn.Close();
}


public void nhap()
{
Tructhang tt = new Tructhang();
Console.Clear();
Console.Write("\nNhap Id Truc Thang : ");
tt.Idtt = Console.ReadLine();
Console.Write("\nNhap model truc thang : ");
tt.Model = Console.ReadLine();
Console.Write("\nNhap toc do truc thang : ");
tt.Cruisespeed = Console.ReadLine();
Console.Write("\nNhap cho chua : ");

tt.Emptyweight = Console.ReadLine();
Console.Write("\nNhap cho chua toi da : ");
tt.Maxtakeoffweight = Console.ReadLine();
Console.Write("\nNhap kich thuoc duong bang : ");
tt.minneededrunwaysizeTT = Console.ReadLine();
tt.ThemTructhang(tt);
Console.ReadLine();
}
public void Xoa()
{
Tructhang tt = new Tructhang();
Console.Clear();
Console.Write("\n Nhap Id Truc Thang can xoa : ");
tt.Idtt = Console.ReadLine();
tt.XoaTructhang(tt);
Console.ReadLine();
}
public void NhapTTSB()
{
Tructhang tt = new Tructhang();
Console.Clear();
Console.Write("\n Nhap Id Truc Thang can them : ");
tt.Idtt = Console.ReadLine();
Console.Write("\n Nhap Id San Bay can them : ");
tt.Idsb = Console.ReadLine();
tt.ThemTTVaoSanBay(tt);
Console.ReadLine();
}
public void XoaTTSB()
{

Tructhang tt = new Tructhang();
Console.Clear();
Console.Write("\n Nhap Id May Bay can Xoa Khoi San Bay : ");
tt.Idtt = Console.ReadLine();
tt.XoaTTKhoiSanBay(tt);
Console.ReadLine();
}
}
}

TẠO CHƯƠNG TRÌNH MAIN ( PROGRAM )
using System;
using System.Collections.Generic;


using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QUANLY_AIRPORT
{
class Program
{
static void Main(string[] args)
{
ketnoi kn = new ketnoi();
menu mn = new menu();
Tructhang tt = new Tructhang();
kn.conn.Open();
int chon;
do

{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\n==================================");
Console.WriteLine("\n 1) Quan Ly San Bay");
Console.WriteLine("\n 2) Quan Ly May Bay");
Console.WriteLine("\n 3) Quan Ly Truc Thang");
Console.WriteLine("\n 4) Thoat");
Console.WriteLine("\n Vui long chon chuc nang !");
Console.WriteLine("\n==================================");
chon = int.Parse(Console.ReadLine());
switch (chon)
{
case 1: mn.menusanbay(); break;
case 2: mn.menumaybay(); break;
case 3: mn.menutructhang(); break;
case 4: break;
}
} while (chon != 4);
}
}
}

CODE CƠ SỞ DỮ LIỆU DATABASE
CREATE DATABASE QUANLY_AIRPORT
GO
USE QUANLY_AIRPORT
GO
CREATE TABLE MAYBAY
(

IDMB
CHAR(7) PRIMARY KEY,
model
VARCHAR(40),
cruisespeed
VARCHAR(30),
loai
VARCHAR(30),
emptyweight
VARCHAR(30),
maxtakeoffweight VARCHAR(30),
minneededrunwaysize
VARCHAR(30),
IDSB
CHAR(7) NULL


)
CREATE TABLE TRUCTHANG
(
IDTT
CHAR(7) PRIMARY KEY,
model
VARCHAR(40),
cruisespeed
VARCHAR(30),
emptyweight
VARCHAR(30),
maxtakeoffweight VARCHAR(30),
minneededrunwaysize

VARCHAR(30),
IDSB
CHAR(7) NULL,
)
CREATE TABLE SANBAY
(
IDSB
CHAR(7) PRIMARY KEY,
TEN
VARCHAR(30),
minneededrunwaysize
VARCHAR(30),
maxfixedwingparkingplace VARCHAR(30),
)
ALTER TABLE MAYBAY ADD CONSTRAINT FK_SANBAY_MAYBAY FOREIGN KEY (IDSB) REFERENCES
SANBAY(IDSB)
ALTER TABLE TRUCTHANG ADD CONSTRAINT FK_SANBAY_TRUCTHANG FOREIGN KEY (IDSB)
REFERENCES SANBAY(IDSB)
INSERT INTO MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('FW11111','BOSS001',900,'Thuong',500,6000,'30M')
INSERT INTO MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('FW22222','BOSS002',900,'Vip',500,6000,'40M')
INSERT INTO MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('FW33333','BOSS003',800,'Vip',500,6000,'30M')
INSERT INTO MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('FW44444','BOSS004',900,'Vip',500,6000,'50M')
INSERT INTO MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('FW55555','BOSS005',900,'Thuong',500,6000,'30M')
INSERT INTO MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('FW66666','BOSS006',900,'Vip',500,6000,'40')

INSERT INTO MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('FW77777','BOSS007',800,'Thuong',500,6000,'20')
INSERT INTO MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('FW88888','BOSS008',900,'Thuong',500,6000,'30M')
INSERT INTO MAYBAY(IDMB,model,cruisespeed,loai,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('FW99999','BOSS009',700,'Thuong',500,6000,'30M')
INSERT INTO TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('RW10000','KING001',1000,400,3000,'35M')
INSERT INTO TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('RW20000','KING002',2000,500,4000,'55M')
INSERT INTO TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('RW30000','KING003',1000,400,5000,'35M')
INSERT INTO TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('RW40000','KING004',1000,600,7000,'25M')
INSERT INTO TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('RW50000','KING005',3000,400,5000,'35M')
INSERT INTO TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('RW60000','KING006',1000,400,5000,'40M')
INSERT INTO TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('RW70000','KING007',1000,700,8000,'35M')


INSERT INTO TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('RW80000','KING008',2000,400,5000,'50M')
INSERT INTO TRUCTHANG(IDTT,model,cruisespeed,emptyweight,maxtakeoffweight,minneededrunwaysize) VALUES
('RW90000','KING009',1000,300,4000,'35M')
INSERT INTO SANBAY(IDSB,TEN,minneededrunwaysize,maxfixedwingparkingplace) VALUES ('AP11111','TAN SAN
NHAT','5000M',100)
INSERT INTO SANBAY(IDSB,TEN,minneededrunwaysize,maxfixedwingparkingplace) VALUES ('AP22222','NOI
BAI','6000M',100)

INSERT INTO SANBAY(IDSB,TEN,minneededrunwaysize,maxfixedwingparkingplace) VALUES ('AP33333','QUOC TE
CAN THO','4000M',100)
INSERT INTO SANBAY(IDSB,TEN,minneededrunwaysize,maxfixedwingparkingplace) VALUES ('AP44444','QUOC TE
DA NANG','5000M',100)
SELECT * FROM MAYBAY
SELECT * FROM TRUCTHANG
SELECT * FROM SANBAY



×