public void xoa() { Console.Clear(); Console.WriteLine("XOA THONG TIN HOA DON BAN "); List <hoadonban> list = spDLL.GetAllhoadonban(); string ma; Console.Write("Nhap ma hoa don ban can xoa:"); ma = Console.ReadLine(); int i = 0; for (i = 0; i < list.Count; ++i) { if (list[i].Mahdb == ma) { break; } } if (i < list.Count) { hoadonban b = new hoadonban(list[i]); spDLL.xoahoadonban(b); } else { Console.WriteLine("Khong ton tai ma san pham nay"); } }
public List <hoadonban> timhoadonban(hoadonban hdb) { List <hoadonban> list = lhhdb.GetAllhoadonban(); List <hoadonban> kq = new List <hoadonban>(); //Voi gai tri ngam dinh ban dau if (hdb.Mahdb == null && hdb.Giaban == 0 && hdb.Ngayban == null) { kq = list; } //Tim theo else if (hdb.Mahdb != "") { for (int i = 0; i < list.Count; ++i) { if (list[i].Mahdb.IndexOf(hdb.Mahdb) >= 0) { kq.Add(new hoadonban(list[i])); } } } else { kq = null; } return(kq); }
public ActionResult DeleteConfirmed(long id) { hoadonban hoadonban = db.hoadonbans.Find(id); db.hoadonbans.Remove(hoadonban); db.SaveChanges(); return(RedirectToAction("Index")); }
//Chèn một bản ghi hóa đơn bán vào tệp public void themhoadonban(hoadonban hd) { string mahdb = DateTime.Now.ToString("tt"); StreamWriter fwrite = File.AppendText(txtfile); fwrite.WriteLine(); fwrite.Write(mahdb + "#" + hd.Giaban + "#" + hd.Ngayban); fwrite.Close(); }
public void Nhap() { Console.Clear(); Console.WriteLine(" NHAP THONG TIN HOA DON BAN "); hoadonban sp = new hoadonban(); Console.Write("Nhap gia ban :"); sp.Giaban = double.Parse(Console.ReadLine()); Console.Write(" Nhap ngay ban:"); sp.Ngayban = DateTime.Parse(Console.ReadLine()); spDLL.themhoadonban(sp); }
public void themhoadonban(hoadonban hdb) { if (hdb.Giaban > 0) { lhhdb.themhoadonban(hdb); } else { throw new Exception("Du lieu sai"); } }
// GET: hoadonbans/Delete/5 public ActionResult Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } hoadonban hoadonban = db.hoadonbans.Find(id); if (hoadonban == null) { return(HttpNotFound()); } return(View(hoadonban)); }
public ActionResult Edit([Bind(Include = "hoadonban_id,ngaytao,ngayhoanthanh,noigui,soluong,hoadonban_id,merchant_id,hinhthucthanhtoan_id,tinhtranggiaohang_id,hoadonmua_id")] hoadonban hoadonban) { if (ModelState.IsValid) { db.Entry(hoadonban).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.hinhthucthanhtoan_id = new SelectList(db.hinhthucthanhtoans, "hinhthucthanhtoan_id", "tenhinhthucthanhtoan", hoadonban.hinhthucthanhtoan_id); ViewBag.hoadonban_id = new SelectList(db.hoadonbans, "hoadonban_id", "tenhoadonban", hoadonban.hoadonban_id); ViewBag.merchant_id = new SelectList(db.merchants, "merchant_id", "cmnd", hoadonban.merchant_id); ViewBag.tinhtranggiaohang_id = new SelectList(db.tinhtranggiaohangs, "tinhtranggiaohang_id", "tentinhtranggiaohang", hoadonban.tinhtranggiaohang_id); ViewBag.hoadonmua_id = new SelectList(db.hoadonmuas, "hoadonmua_id", "noinhan", hoadonban.hoadonmua_id); return(View(hoadonban)); }
// GET: hoadonbans/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } hoadonban hoadonban = db.hoadonbans.Find(id); if (hoadonban == null) { return(HttpNotFound()); } ViewBag.hinhthucthanhtoan_id = new SelectList(db.hinhthucthanhtoans, "hinhthucthanhtoan_id", "tenhinhthucthanhtoan", hoadonban.hinhthucthanhtoan_id); ViewBag.hoadonban_id = new SelectList(db.hoadonbans, "hoadonban_id", "tenhoadonban", hoadonban.hoadonban_id); ViewBag.merchant_id = new SelectList(db.merchants, "merchant_id", "cmnd", hoadonban.merchant_id); ViewBag.tinhtranggiaohang_id = new SelectList(db.tinhtranggiaohangs, "tinhtranggiaohang_id", "tentinhtranggiaohang", hoadonban.tinhtranggiaohang_id); ViewBag.hoadonmua_id = new SelectList(db.hoadonmuas, "hoadonmua_id", "noinhan", hoadonban.hoadonmua_id); return(View(hoadonban)); }
public void Hientimkiem(hoadonban hdb) { int i; List <hoadonban> list = lhhdb.GetAllhoadonban(); Console.WriteLine("mahoadonban" + "\t" + "giaban" + "\t" + "ngay"); for (i = 0; i < list.Count; ++i) { if (list[i].Mahdb == hdb.Mahdb) { Console.WriteLine(hdb.Mahdb + "\t" + hdb.Giaban + "\t\t" + hdb.Ngayban); } else { throw new Exception("Khong ton tai hs nay"); } } }
public void Sua() { Console.Clear(); Console.WriteLine("SUA THONG TIN HOA DON BAN"); List <hoadonban> list = spDLL.GetAllhoadonban(); string ma; Console.Write("Nhap ma hoa don ban can sua:"); ma = Console.ReadLine(); int i = 0; for (i = 0; i < list.Count; ++i) { if (list[i].Mahdb == ma) { break; } } if (i < list.Count) { hoadonban sp = new hoadonban(list[i]); //Console.Write("Nhap ma hoa don ban:"); //string mahdb = Console.ReadLine(); //if (mahdb != "") sp.Mahdb = mahdb; Console.Write("gia ban:"); double gb = double.Parse(Console.ReadLine()); sp.Giaban = gb; Console.Write("Nhap ngay ban:"); DateTime nb = DateTime.Parse(Console.ReadLine()); sp.Ngayban = nb; spDLL.suahoadonban(sp); } else { Console.WriteLine("Khong ton tai ma hóa đơn này nay"); } }
public void xoahoadonban(hoadonban mahdb) { int i; List <hoadonban> list = lhhdb.GetAllhoadonban(); for (i = 0; i < list.Count; ++i) { if (list[i].Mahdb == mahdb.Mahdb) { break; } } if (i < list.Count) { list.RemoveAt(i); lhhdb.update(list); } else { throw new Exception("Khong ton tai ma nay"); } }
public void Hientimkiem() { Console.Clear(); Console.WriteLine("HIEN THONG TIN TIM KIEM"); List <hoadonban> list = spDLL.GetAllhoadonban(); string ma; Console.Write("Nhap ma hoa don ban can hien thi:"); ma = Console.ReadLine(); int i; for (i = 0; i < list.Count; ++i) { if (list[i].Mahdb == ma) { break; } } if (i < list.Count) { hoadonban b = new hoadonban(list[i]); spDLL.Hientimkiem(b); } }