public DoiTra(DoiTra doi)
 {
     this.madoitra = doi.madoitra;
     this.tendt    = doi.tendt;
     this.tendt    = doi.tendt;
     this.ngaydoi  = doi.ngaydoi;
 }
        public void nhap()
        {
            DoiTra dt = new DoiTra();

            dt.nhap();
            them(dt);
            Console.ReadKey();
        }
        public void writefile(string filename, DoiTra dt)
        {
            StreamWriter sw = new StreamWriter(filename, true);

            sw.WriteLine(dt.tostring());

            sw.Close();
        }
 public void them(DoiTra dt)
 {
     Console.InputEncoding  = UnicodeEncoding.Unicode;
     Console.OutputEncoding = UnicodeEncoding.Unicode;
     ReadFile("doitra.txt");
     if (TimKiemTheoMa(dt.Madoitra.Trim()) != null)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("thêm thất bại, mã đổi trả đã tồn tại");
     }
     else
     {
         doitra.Add(dt);
         writefile("doitra.txt", dt);
     }
 }
        public void ReadFile(string filename)
        {
            doitra = new List <DoiTra>();
            StreamReader sr = new StreamReader(filename);
            String       tmp;
            DoiTra       dt;

            while (sr.EndOfStream == false)
            {
                tmp = sr.ReadLine().Trim();
                if (tmp == "")
                {
                    continue;
                }
                dt = new DoiTra(tmp);
                doitra.Add(dt);
            }
            sr.Close();
        }