Mã: Chọn tất cả
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QuanLyDanhMucVideo
{
class Program
{
static void ThemDanhMucVideo(List <Products> L)
{
Products vd;
do
{
Console.WriteLine("Nhap thong tin video:");
vd = new Products();
vd.Nhap();
L.Add(vd);
Console.WriteLine("Nhan phim bat ky de tiep tuc. Nhan Escape de ket thuc.");
} while (Console.ReadKey(true).Key != ConsoleKey.Escape);
}
static void Main(string[] args)
{
List <Products> DS = new List<Products>();
string keyword;
Funcs F = new Funcs();
Console.WriteLine("========== NHAP DU LIEU ==========");
ThemDanhMucVideo(DS);
Console.WriteLine("==================================");
Console.WriteLine();
do
{
Console.Write(">>> Nhap the loai phim can tim: ");
keyword = F.ChuanHoa(Console.ReadLine());
Console.WriteLine("Ket qua: ");
foreach (Products v in DS)
{
if (v.TheLoai == v.sTheLoai(keyword))
{
v.Xuat();
}
}
Console.WriteLine();
Console.Write(">>> Nhap ten dien vien nam chinh can tim: ");
keyword = F.ChuanHoa(Console.ReadLine());
foreach (Products v in DS)
{
if (v.TenDienVienNamChinh == keyword)
{
v.Xuat();
}
}
Console.WriteLine();
Console.Write(">>> Nhap ten dao dien can tim: ");
keyword = F.ChuanHoa(Console.ReadLine());
foreach (Products v in DS)
{
if (v.TenDaoDien == keyword)
{
v.Xuat();
}
}
Console.WriteLine("Nhan phim bat ky de tim tiep. Nhan Escape de ket thuc.");
Console.WriteLine();
} while (Console.ReadKey(true).Key != ConsoleKey.Escape);
Console.Write(">>> KET THUC CHUONG TRINH <<< ");
Console.ReadLine();
}
}
}
Mã: Chọn tất cả
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QuanLyDanhMucVideo
{
class Products
{
string TenPhim;
public string TheLoai;
public string TenDaoDien;
public string TenDienVienNamChinh;
string TenDienVienNuChinh;
int NamSanXuat;
string HangSanXuat;
public void Nhap()
{
Funcs F = new Funcs();
Console.Write("Ten phim: ");
TenPhim = F.ChuanHoa(Console.ReadLine());
Console.Write("The loai (1 - Hinh su, 2 - Tinh cam, 3 - Hai): ");
TheLoai = sTheLoai(F.ChuanHoa(Console.ReadLine()));
Console.Write("Ten dao dien: ");
TenDaoDien = F.ChuanHoa(Console.ReadLine());
Console.Write("Ten dien vien nam chinh: ");
TenDienVienNamChinh = F.ChuanHoa(Console.ReadLine());
Console.Write("Ten dien vien nu chinh: ");
TenDienVienNuChinh = F.ChuanHoa(Console.ReadLine());
Console.Write("Nam san xuat: ");
NamSanXuat = int.Parse(Console.ReadLine());
Console.Write("Hang san xuat: ");
HangSanXuat = F.ChuanHoa(Console.ReadLine());
Console.WriteLine();
}
public void Xuat()
{
Console.WriteLine("Ten phim: " + TenPhim);
Console.WriteLine("The loai: " + TheLoai);
Console.WriteLine("Ten dao dien: " + TenDaoDien);
Console.WriteLine("Ten dien vien nam chinh: " + TenDienVienNamChinh);
Console.WriteLine("Ten dien vien nu chinh: " + TenDienVienNuChinh);
Console.WriteLine("Nam san xuat: " + NamSanXuat);
Console.WriteLine("Hang san xuat: " + HangSanXuat);
}
public string sTheLoai(string str)
{
switch (str)
{
case "1":
return "Hinh Su";
case "2":
return "Tinh Cam";
case "3":
return "Hai";
case "Hinh Su":
case "Tinh Cam":
case "Hai":
return str;
default:
return "Hinh Su";
}
}
}
}
Mã: Chọn tất cả
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QuanLyDanhMucVideo
{
class Funcs
{
public string ChuanHoa(string str)
{
string re = "";
str = str.Trim();
if (str.Length > 0)
{
do
{
str = str.Replace(" ", " ");
}
while (str.IndexOf(" ") != -1);
string[] arr = str.Split(' ');
for (int iCount = 0; iCount < arr.Length; iCount++)
{
arr[iCount] = arr[iCount].Substring(0, 1).ToUpper() +arr[iCount].Substring(1).ToLower();
re = re + arr[iCount] + " ";
}
}
return re.Trim();
}
}
}