Esempio n. 1
0
        static clsCauThu NhapCauThu()
        {
            clsCauThu a = new clsCauThu();

            Console.Write("Nhap Ma Cau Thu: ");
            a.MaCauThu = Console.ReadLine();
            Console.Write("Nhap Ten Cau Thu: ");
            a.TenCauThu = Console.ReadLine();
            do
            {
                try
                {
                    Console.Write("Nhap Ngay Sinh:");
                    a.NgaySinh = DateTime.Parse(Console.ReadLine());
                }
                catch
                {
                    Console.WriteLine("Nhap sai ngay sinh vui long nhap lai");
                    a.NgaySinh = DateTime.Today;
                }
            }while(a.NgaySinh > DateTime.Today.AddYears(-12));
            return(a);
        }
Esempio n. 2
0
        static void HienThiThongTinCauThuNhoTuoiNhat(List <clsCauThu> dsCauThu)
        {
            clsCauThu min = dsCauThu[0];
            int       i;

            Console.WriteLine("-------------------------------------------------------------------");
            Console.WriteLine("|    Ma So   |              Ten               |  Ngay Sinh | Tuoi |");
            Console.WriteLine("-------------------------------------------------------------------");
            foreach (var element in dsCauThu)
            {
                Console.WriteLine("| {0,-10} | {1,-30} | {2,10} |  {3,2}  |", element.MaCauThu, element.TenCauThu, element.NgaySinh.ToString("dd/MM/yyyy"), DateTime.Today.Year - element.NgaySinh.Year);
                i = min.NgaySinh.CompareTo(element.NgaySinh);
                //j = Math.Abs(DateTime.Today.CompareTo(min.NgaySinh));
                if (min.NgaySinh.CompareTo(element.NgaySinh) == -1)
                {
                    min = element;
                }
            }
            Console.WriteLine("-------------------------------------------------------------------");
            Console.WriteLine("| {0,-10} | {1,-30} | {2,10} |  {3,2}  |", min.MaCauThu, min.TenCauThu, min.NgaySinh.ToString("dd/MM/yyyy"), DateTime.Today.Year - min.NgaySinh.Year);
            Console.WriteLine("-------------------------------------------------------------------");
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }