public string maThietBi; public string tenThietBi; public double giaThietBi; public int namNhapThietBi;
public string moTaThietBi;
public static void Main()
thongTinThietBi[] thietBi; int soThietBi;
Console.Write("So thiet bi can quan ly:"); soThietBi = int.Parse(Console.ReadLine()); thietBi = new thongTinThietBi[soThietBi];
Console.Write("Chon Chuc Nang:"); chonChucNang= int.Parse(Console.ReadLine()); Console.Clear(); switch (chonChucNang)
case 1: themThietBi(thietBi,soThietBi); break; case 2: xoaThietBi(thietBi,soThietBi); break; case 3: timThietBi(thietBi,soThietBi); break; case 4: sapXepThietBi(thietBi,soThietBi); break; case 5: hienthiThietBiCu(thietBi,soThietBi); break; case 6: show_all(thietBi,soThietBi); break; case 10: Console.WriteLine("Cam On Ban Da Su Dung Chuong Trinh");break;
default: Console.WriteLine("Chưa xư lý");break;
}while (chonChucNang!=10);
Console.WriteLine("\n***CHUC NANG CHUONG TRINH*** \n");
Console.WriteLine("1. Them Thiet Bi");
Console.WriteLine("2. Xoa Thiet Bi");
Console.WriteLine("3. Tim Thiet Bi Theo Ma");
Console.WriteLine("4. Sap Xep Thiet Bi Theo Chieu Tang Gia");
Console.WriteLine("5. Hien Thi Thiet Bi Qua 1 Nam");
Console.WriteLine("6. Hien thi toan bo thiet bi");
Console.WriteLine("10. Thoat Chuong Trinh");
Console.WriteLine("\n*************");
static void themThietBi(thongTinThietBi[] thietBi,int soThietBi)
Console.WriteLine("***Them thiet bi moi*** \n"); Console.Write("Nhap ma thiet bi:"); tb.maThietBi = Console.ReadLine();
Console.Write("Nhap ten thiet bi:");
tb.tenThietBi = Console.ReadLine(); Console.Write("Nhap gia thiet bi:"); tb.giaThietBi= double.Parse(Console.ReadLine().ToString()); Console.Write("Nhap nam thiet bi:"); tb.namNhapThietBi =int.Parse(Console.ReadLine()); Console.Write("Nhap mo ta thiet bi:"); tb.moTaThietBi = Console.ReadLine();
for (int i=0;i< soThietBi;i++)
if (object.Equals(thietBi[i].maThietBi,null)==true)
Console.WriteLine("Da them thanh cong \n");
Console.WriteLine("Het vung luu tru");
static void xoaThietBi(thongTinThietBi[] thietBi,int soThietBi)
string maXoa; bool xoaduoc=false;
Console.WriteLine("***Xoa thiet bi moi*** \n"); Console.Write("Nhap ma can xoa:"); maXoa = Console.ReadLine();
for (int i=0;i<soThietBi;i++)
if (object.Equals(thietBi[i].maThietBi,null)==true)
if (thietBi[i].maThietBi.Equals(maXoa)==true)
thongTinThietBi[] t=new thongTinThietBi[1];
for (int j=i;j<soThietBi-1;j++)
Console.WriteLine("Da xoa duoc");
Console.WriteLine("Khong tim thay de xoa");
static void timThietBi(thongTinThietBi[] thietBi,int soThietBi)
string matim; bool timduoc=false;
Console.WriteLine("***Tim thiet bi theo ma*** \n"); Console.Write("Nhap ma can tim:"); matim = Console.ReadLine();
for (i=0;i<soThietBi;i++)
if (object.Equals(thietBi[i].maThietBi,null)==true)
if (thietBi[i].maThietBi.Equals(matim)==true)
Console.WriteLine("Da tim thay thiet bi voi thong tin");
Console.WriteLine("Nhap ma thiet bi:{0}",thietBi[i].maThietBi);
Console.WriteLine("Nhap ten thiet bi:{0}",thietBi[i].tenThietBi);
Console.WriteLine("Nhap gia thiet bi:{0}",thietBi[i].giaThietBi);
Console.WriteLine("Nhap nam thiet bi:{0}",thietBi[i].namNhapThietBi);
Console.WriteLine("Nhap mo ta thiet bi:{0}",thietBi[i].moTaThietBi);
Console.WriteLine("Khong tim thay thiet bi voi ma:{0}",matim);
static void sapXepThietBi(thongTinThietBi[] thietBi,int soThietBi)
for (int i=0;i<soThietBi-1;i++) for (int j=i;j<soThietBi;j++)
if (thietBi[i].giaThietBi > thietBi[j].giaThietBi)
tam = thietBi[i]; thietBi[i]=thietBi[j];
static void hienthiThietBiCu(thongTinThietBi[] thietBi,int soThietBi)
int namHienTai = DateTime.Now.Year;
Console.WriteLine("*** Toan bo thiet bi qua 01 nam ke tu ngay nhap kho***\n");
for (int i=0;i<soThietBi;i++)
if (object.Equals(thietBi[i].maThietBi,null)!=true)
if ((thietBi[i].namNhapThietBi + 1)<namHienTai)
Console.WriteLine("Nhap ma thiet bi:{0}",thietBi[i].maThietBi);
Console.WriteLine("Nhap ten thiet bi:{0}",thietBi[i].tenThietBi);
Console.WriteLine("Nhap gia thiet bi:{0}",thietBi[i].giaThietBi);
Console.WriteLine("Nhap nam thiet bi:{0}",thietBi[i].namNhapThietBi);
Console.WriteLine("Nhap mo ta thiet bi:{0}",thietBi[i].moTaThietBi); Console.WriteLine();
static void show_all(thongTinThietBi[] thietBi,int soThietBi)
Console.WriteLine("*** Toan bo thiet bi dang quan ly***\n");
for (int i=0;i<soThietBi;i++)
if (object.Equals(thietBi[i].maThietBi,null)!=true)
Console.WriteLine("Nhap ma thiet bi:{0}",thietBi[i].maThietBi);
Console.WriteLine("Nhap ten thiet bi:{0}",thietBi[i].tenThietBi);
Console.WriteLine("Nhap gia thiet bi:{0}",thietBi[i].giaThietBi);
Console.WriteLine("Nhap nam thiet bi:{0}",thietBi[i].namNhapThietBi);
Console.WriteLine("Nhap mo ta thiet bi:{0}",thietBi[i].moTaThietBi); Console.WriteLine();
Console.WriteLine("\n******\n");