public ActionResult Edit(int id) { if (id < 0) { return(RedirectToAction("Index", "HoaDon", new { @message = "Không tìm thấy hóa đơn này." })); } var ctx = new SmsContext(); var Infor = ctx.SP_GET_BILL_INFOR(id).FirstOrDefault(); if (Infor == null) { return(RedirectToAction("Index", "HoaDon", new { @message = "Không tìm thấy hóa đơn này." })); } var details = ctx.SP_GET_BILL_DETAIL_BY_ID(id).ToList <SP_GET_BILL_DETAIL_BY_ID_Result>(); var stores = ctx.KHOes.Where(u => u.ACTIVE == "A").ToList(); var units = ctx.DON_VI_TINH.Where(u => u.ACTIVE == "A").ToList(); EditHoaDonBanHang model = new EditHoaDonBanHang(); model.Store = stores; model.Units = units; model.Infor = Infor; model.Details = details; ctx.Dispose(); return(View(model)); }