public ActionResult Create(Huyhdvat entity) { string maviettat = entity.stt; entity.Idhoadon = _huyhdvatRepository.newId(); entity.ngaytao = System.DateTime.Now; string firstId = entity.Idhoadon.Substring(0, 6); string last = entity.Idhoadon.Substring(6, 4); entity.stt = firstId + HttpContext.Session.GetString("maviettat") + last; entity.chinhanh = HttpContext.Session.GetString("chinhanh"); entity.nguoitaohd = HttpContext.Session.GetString("username"); entity.logfile = " User tạo hoá đơn :" + entity.nguoitaohd + " vào lúc " + System.DateTime.Now.ToString(); var result = _huyhdvatRepository.Create(entity); if (result == null) { SetAlert("Tạo hoá đơn không thành công. Vui lòng nhấn lại nút submit", "error"); return(View()); } else { SetAlert("Tạo hoá đơn thành công", "success"); return(RedirectToAction("Edit", new { id = entity.Idhoadon })); } }