public void xoa() { Console.Clear(); Console.WriteLine("XOA THONG TIN HOA DON NHAP "); List <Hoadonnhap> list = spDLL.LayDSHoadonnhap(); string ma; Console.Write("Nhap ma hoa don nhap can xoa:"); ma = Console.ReadLine(); int i = 0; for (i = 0; i < list.Count; ++i) { if (list[i].mahdn == ma) { break; } } if (i < list.Count) { Hoadonnhap b = new Hoadonnhap(list[i]); spDLL.Xoahoadonnhap(b); } }
public List <Hoadonnhap> Timhoadonnhap(Hoadonnhap hdn) { List <Hoadonnhap> list = lhdn.LayDSHoadonnhap(); List <Hoadonnhap> kq = new List <Hoadonnhap>(); //Voi gai tri ngam dinh ban dau if (hdn.mancc == 0 && hdn.mann == null && hdn.ngaynhan == null && hdn.ghichu == null) { kq = list; } //Tim theo mancc if (hdn.mancc > 0) { for (int i = 0; i < list.Count; ++i) { if (list[i].mancc >= 0) { kq.Add(new Hoadonnhap(list[i])); } } } // Tim theo tong tien //Cac truong hop khac cac ban tu lam else { kq = null; } return(kq); }
//Chèn một bản ghi hang hoa vào tệp public void Insert(Hoadonnhap hh) { int mah = Mahdn + 1; StreamWriter fwrite = File.AppendText(txtfile); fwrite.WriteLine(); fwrite.Write(mah + "#" + hh.mahdn + "#" + hh.mancc + "#" + hh.mann + "#" + hh.ngaynhan + "#" + hh.tongtien + "#" + hh.ghichu); fwrite.Close(); }
//Chèn một bản ghi học sinh vào tệp public void Themhoadonnhap(Hoadonnhap sp) { string mahdn = DateTime.Now.ToString("ss"); StreamWriter fwrite = File.AppendText(txtfile); fwrite.WriteLine(); fwrite.Write(mahdn + "#" + sp.mancc + "#" + sp.mann + "#" + sp.ngaynhan + "#" + sp.ghichu); fwrite.Close(); }
public void Themhoadonnhap(Hoadonnhap hdn) { if (hdn.mann != "") { lhdn.Themhoadonnhap(hdn); } else { throw new Exception("Du lieu sai"); } }
public void Nhap() { Console.Clear(); Console.WriteLine(" NHAP THONG TIN HOA DON NHAP "); Hoadonnhap sp = new Hoadonnhap(); Console.Write("Nhap ma nha cung cap:"); sp.mancc = int.Parse(Console.ReadLine()); Console.Write("Nhap mann :"); sp.mann = Console.ReadLine(); Console.Write(" Nhap ngay nhan :"); sp.ngaynhan = DateTime.Parse(Console.ReadLine()); Console.Write("Nhap ghi chu :"); sp.ghichu = Console.ReadLine(); spDLL.Themhoadonnhap(sp); }
public void Sua() { Console.Clear(); Console.WriteLine("SUA THONG TIN HOA DON NHAP"); List <Hoadonnhap> list = spDLL.LayDSHoadonnhap(); string ma; Console.Write("Nhap ma hoa don nhap can sua:"); ma = Console.ReadLine(); int i = 0; for (i = 0; i < list.Count; ++i) { if (list[i].mahdn == ma) { break; } } if (i < list.Count) { Hoadonnhap sp = new Hoadonnhap(list[i]); Console.Write("Nhap ma ncc:"); int macc = int.Parse(Console.ReadLine()); if (macc != 0) { sp.mancc = macc; } Console.Write("ngay mann moi:"); string mann = Console.ReadLine(); if (mann != "") { sp.mann = mann; } Console.Write("Nhap ngay ban:"); DateTime nn = DateTime.Parse(Console.ReadLine()); sp.ngaynhan = nn; Console.Write("Nhap ghi chu moi :"); string gc = Console.ReadLine(); if (gc != "") { sp.ghichu = gc; } spDLL.Suahoadonnhap(sp); } else { Console.WriteLine("Khong ton tai ma hoa don ban nay"); } }
public void Xoahoadonnhap(Hoadonnhap xhdn) { int i; List <Hoadonnhap> list = lhdn.LayDSHoadonnhap(); for (i = 0; i < list.Count; ++i) { if (list[i].mahdn == xhdn.mahdn) { break; } } if (i < list.Count) { list.RemoveAt(i); lhdn.Update(list); } else { throw new Exception("Khong ton tai ma nay"); } }