public ActionResult Delete(int[] cbxItem) { qtSubstitutesService _substitute = new qtSubstitutesService(); qtSubstitute substitute = new qtSubstitute(); if (cbxItem != null && cbxItem.Count() > 0) { qtSubstituteDetailService _substitutedetail = new qtSubstituteDetailService(); foreach (int item in cbxItem) { try { substitute = _substitute.FindByKey(item); if (substitute != null) { _substitutedetail.DeleteObject(_substitutedetail.FindList().Where(m => m.SubstituteId == item).ToList()); _substitute.Delete(substitute); } } catch (Exception) { } } } return(RedirectToAction("Index")); }
public ActionResult Index(int?DepartmentId, int?page) { qtSubstitutesService _Substitute = new qtSubstitutesService(); IPagedList <qtSubstitute> Substitute = _Substitute.FindListByPage(DepartmentId, page); ViewBag.DonVi = TreeUnit(DepartmentId); return(View(Substitute)); }
public ActionResult Create(int?id) { qtSubstitutesService _Substitutes = new qtSubstitutesService(); qtSubstitute substitute = new qtSubstitute(); if (id.HasValue) { substitute = _Substitutes.FindByKey(id); DanhSachNguoiDung(substitute.DepartmentId, substitute.SubstituteId); //DropDownListView(substitute.qtDepartment.UnitId, substitute.DepartmentId); } else { DanhSachNguoiDung(null, null); DropDownListView(null, null); } return(View(substitute)); }
public ActionResult Create(int?id, int?UnitId, int?DepartmentId, string AppName, string AppCode, bool IsActive) { qtSubstitutesService _Substitutes = new qtSubstitutesService(); qtSubstitute substitute = new qtSubstitute(); if (id.HasValue) { substitute = _Substitutes.FindByKey(id); DanhSachNguoiDung(substitute.DepartmentId, substitute.SubstituteId); } else { DanhSachNguoiDung(DepartmentId, null); } ViewBag.AppName = AppName; ViewBag.AppCode = AppCode; ViewBag.IsActive = IsActive; DropDownListView(UnitId, substitute.DepartmentId); return(View(substitute)); }
public ActionResult Save(int?id, int?SubstituteId, string AppName, string AppCode, bool IsActive, int DepartmentId, string[] cbxItem) { qtSubstitutesService _Substitutes = new qtSubstitutesService(); qtSubstitute substitute = new qtSubstitute(); if (SubstituteId.HasValue && SubstituteId.Value > 0) { substitute = _Substitutes.FindByKey(SubstituteId); } substitute.AppName = AppName; substitute.AppCode = AppCode; substitute.IsActive = IsActive; substitute.DepartmentId = DepartmentId; if (SubstituteId.HasValue && SubstituteId.Value > 0) { _Substitutes.Update(substitute); } else { _Substitutes.Insert(substitute); } if (cbxItem.Count() > 0) { qtSubstituteDetailService _detail = new qtSubstituteDetailService(); _detail.RunSql("Delete SubstituteDetail where SubstituteId=" + substitute.SubstituteId); foreach (string item in cbxItem) { qtSubstituteDetail detail = new qtSubstituteDetail(); detail.SubstituteId = substitute.SubstituteId; detail.UserId = TypeHelper.ToInt32(item); _detail.Insert(detail); } } return(RedirectToAction("Index")); }