public void update() { Console.InputEncoding = UnicodeEncoding.Unicode; Console.OutputEncoding = UnicodeEncoding.Unicode; string mhd; string tt; tt: Console.ForegroundColor = ConsoleColor.Green; Console.Write("nhập mã hoá đơn bạn muốn cập nhật:"); mhd = Console.ReadLine(); ReadFile("HoaDonNhap.txt"); HoaDonNhap dt = timkiemhoadon(mhd); if (dt == null) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("mã hóa đơn bạn vừa nhập không tồn tại,bấm phím bất kỳ để nhập lại:"); Console.ReadKey(); goto tt; } else { dt.update(); WriteFile("HoaDonNhap.txt"); } }
public void writefile(string filename, HoaDonNhap dt) { StreamWriter sw = new StreamWriter(filename, true); sw.WriteLine(dt.tostring()); sw.Close(); }
public void Nhap() { Console.InputEncoding = UnicodeEncoding.Unicode; Console.OutputEncoding = UnicodeEncoding.Unicode; HoaDonNhap dt; dt = new HoaDonNhap(); dt.nhap(); Them(dt); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("bấm Enter để hoàn tất"); Console.Read(); }
public HoaDonNhap(HoaDonNhap hdb) { a = new int[3]; this.mahoadon = hdb.mahoadon; this.ngaylap = hdb.ngaylap; this.ngay = hdb.ngay; this.ngay = this.ngaylap.ToString("yyyyMMdd-HHMMss"); this.thanhtien = hdb.thanhtien; this.nguoilap = hdb.nguoilap; this.tdt = hdb.tdt; this.soluong = hdb.soluong; this.tien = hdb.tien; this.tien = this.thanhtien.ToString(); }
public void Them(HoaDonNhap hdb) { Console.InputEncoding = UnicodeEncoding.Unicode; Console.OutputEncoding = UnicodeEncoding.Unicode; if (timkiemhoadon(hdb.Mahoadon) != null) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("mã hóa đơn đã bị trùng,không thể thêm"); } else { HoaDonNhap.Add(hdb); writefile("HoaDonNhap.txt", hdb); hdb.cnsl(); } }
public void ReadFile(string filename) { HoaDonNhap = new List <HoaDonNhap>(); StreamReader sr = new StreamReader(filename); String tmp; HoaDonNhap dt; while (sr.EndOfStream == false) { tmp = sr.ReadLine().Trim(); if (tmp == "") { continue; } dt = new HoaDonNhap(tmp); HoaDonNhap.Add(dt); } sr.Close(); }