public ActionResult Them() { if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser)) { var model = new NhomNguoiDungModel(); model.DanhSachDonVi = xlDonVi.DocDanhSachTuDonViCha(currentUser.IdDonVi, (bool)Session[ConstantValues.SessionKeyVaiTro]); model.DanhSachChucNang = DocDanhSachChucNang(); return(View("Them", model)); } if (Request.Url != null) { SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath); } return(RedirectToAction("Index", "Login")); }
public ActionResult Them(FormCollection collection) { if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser)) { NotifyModel thongBao = new NotifyModel(); try { if (!string.IsNullOrEmpty(collection["save"].ToString())) { NhomNguoiDung nhomNguoiDung = new NhomNguoiDung(); nhomNguoiDung.Ten = collection["ten"].ToString(); nhomNguoiDung.MoTa = collection["moTa"].ToString(); nhomNguoiDung.IdDonVi = collection["donVi"].ToString(); //nguoi dung chi co the phan quyen nhung chuc nang ma ho co var chucNangList = collection["chucNang"].Split(','); nhomNguoiDung.DanhSachChucNang = chucNangList.ToList(); nhomNguoiDung.IdNguoiTao = currentUser.Id.ToString(); nhomNguoiDung.IdNguoiCapNhat = currentUser.Id.ToString(); if (xlNhomNguoiDung.Ghi(nhomNguoiDung)) { thongBao.TypeNotify = "alert-success"; thongBao.Message = "Thêm thành công"; } else { thongBao.TypeNotify = "alert-danger"; thongBao.Message = "Thêm thất bại!"; } } } catch (Exception) { thongBao.TypeNotify = "alert-danger"; thongBao.Message = "Thêm thất bại!"; } ViewBag.ThongBao = thongBao; var model = new NhomNguoiDungModel(); model.DanhSachDonVi = xlDonVi.DocDanhSachTuDonViCha(currentUser.IdDonVi, (bool)Session[ConstantValues.SessionKeyVaiTro]); model.DanhSachChucNang = DocDanhSachChucNang(); return(View("Them", model)); } if (Request.Url != null) { SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath); } return(RedirectToAction("Index", "Login")); }
public ActionResult Edit(NhomNguoiDungModel model) { if (!ModelState.IsValid) { TempData["Message"] = "Có lỗi xảy ra! Vui lòng kiểm tra lại thông tin."; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(View("Edit", model)); } if (!_quyenServices.Authorize((int)EnumQuyen.NHOMNGUOIDUNG_SUA)) { TempData["Message"] = "Bạn không có quyền thực hiện chức năng này"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("ViewDenied", "QLKS")); } var item = db.NHOMNGUOIDUNGs.Where(c => c.ID == model.ID).FirstOrDefault(); if (item == null) { TempData["Message"] = "Có lỗi xảy ra"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("List")); } item.Ten = model.Ten; item.QUYENs.Clear(); if (model.SelectedQuyens != null) { if (model.SelectedQuyens.Count > 0) { foreach (var quyen in model.SelectedQuyens) { var i = db.QUYENs.Find(quyen); item.QUYENs.Add(i); } } } db.SaveChanges(); _lichSuServices.LuuLichSu((int)Session["ID"], (int)EnumLoaiHanhDong.SUA, item.GetType().ToString()); TempData["Message"] = "Cập nhật thành công"; TempData["NotiType"] = "success"; //success là class trong bootstrap return(RedirectToAction("List")); }
public ActionResult Edit(int?id) { if (!_nguoiDungServices.isLoggedIn()) { TempData["Message"] = "Bạn chưa đăng nhập, vui lòng đăng nhập"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("Login", "NguoiDung")); } if (!_quyenServices.Authorize((int)EnumQuyen.NHOMNGUOIDUNG_SUA)) { TempData["Message"] = "Bạn không có quyền thực hiện chức năng này"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("ViewDenied", "QLKS")); } if (id == null) { return(RedirectToAction("List")); } var nhomNguoiDung = db.NHOMNGUOIDUNGs.Find(id); if (nhomNguoiDung == null) { TempData["Message"] = "Không tìm thấy nhóm người dùng này"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("List")); } var listQuyen = nhomNguoiDung.QUYENs.Select(c => c.ID).ToList(); //prepare model var model = new NhomNguoiDungModel(); model.ID = nhomNguoiDung.ID; model.Ma = nhomNguoiDung.Ma; model.SelectedQuyens = nhomNguoiDung.QUYENs.Select(c => c.ID).ToList(); model.Ten = nhomNguoiDung.Ten; //var nhomNguoiDungModel = AutoMapper.Mapper.Map<NhomNguoiDungModel>(nhomNguoiDung); var allQuyen = _quyenServices.GetAllQuyen(listQuyen).ToList(); model.DanhSachQuyen = allQuyen; return(View(model)); }
public ActionResult Create(NhomNguoiDungModel model) { if (!ModelState.IsValid) { TempData["Message"] = "Có lỗi xảy ra! Vui lòng kiểm tra lại thông tin."; TempData["NotiType"] = "success"; //success là class trong bootstrap return(View("Create", model)); } if (!_quyenServices.Authorize((int)EnumQuyen.NHOMNGUOIDUNG_THEM)) { TempData["Message"] = "Bạn không có quyền thực hiện chức năng này"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("ViewDenied", "QLKS")); } var item = AutoMapper.Mapper.Map <NHOMNGUOIDUNG>(model); db.NHOMNGUOIDUNGs.Add(item); //int a = 0; //a = db.Database.ExecuteSqlCommand("exec SP_CreateOrUpdate_NHOMNGUOIDUNG @Type, @ID, @Ten, @Ma, @UpdateID", new SqlParameter("@Type", int.Parse("0")), new SqlParameter("@ID", a), new SqlParameter("@Ten", item.Ten), new SqlParameter("@Ma", item.Ma), new SqlParameter("@UpdateID", int.Parse("0"))); //var nhomNguoiDung = db.NHOMNGUOIDUNGs.Find(a); if (model.SelectedQuyens != null) { if (model.SelectedQuyens.Count > 0) { foreach (var quyen in model.SelectedQuyens) { var i = db.QUYENs.Find(quyen); item.QUYENs.Add(i); } } } db.SaveChanges(); TempData["Message"] = "Thêm mới thành công"; TempData["NotiType"] = "success"; return(RedirectToAction("List")); }
public ActionResult Create() { if (!_nguoiDungServices.isLoggedIn()) { TempData["Message"] = "Bạn chưa đăng nhập, vui lòng đăng nhập"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("Login", "NguoiDung")); } if (!_quyenServices.Authorize((int)EnumQuyen.NHOMNGUOIDUNG_THEM)) { TempData["Message"] = "Bạn không có quyền thực hiện chức năng này"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("ViewDenied", "QLKS")); } var model = new NhomNguoiDungModel(); var maxId = db.NHOMNGUOIDUNGs.Select(c => c.ID).DefaultIfEmpty(0).Max(); var newId = (maxId + 1).ToString().PadLeft(4, '0'); model.Ma = "NHOM" + "-" + newId; var allQuyen = _quyenServices.GetAllQuyen(new List <int>()).ToList(); model.DanhSachQuyen = allQuyen; return(View(model)); }
// GET: NhomNguoiDung public ActionResult Index(int page = 1, int total = 0) { if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser)) { long currentRecord = ((page - 1) * PageNumber.NhomNguoiDung); var model = new NhomNguoiDungModel(); model.DanhSachNhomNguoiDung = xlNhomNguoiDung.DocDanhSachCungTenDonVi(PageNumber.NhomNguoiDung, (int)currentRecord); if (total > 0) { model.TotalPage = total; } else { model.TotalPage = (int)Math.Round((double)xlNhomNguoiDung.TongSoLuong() / PageNumber.NhomNguoiDung); } model.CurrentPage = page; return(View("Index", model)); } if (Request.Url != null) { SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath); } return(RedirectToAction("Index", "Login")); }
public ActionResult ChinhSua(string id) { if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser)) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Index", "NhomNguoiDung")); } var model = new NhomNguoiDungModel(); model.NhomNguoiDungHienTai = xlNhomNguoiDung.Doc(id); if (model.NhomNguoiDungHienTai == null) { return(RedirectToAction("Index", "NhomNguoiDung")); } model.DanhSachDonVi = xlDonVi.DocDanhSachTuDonViCha(currentUser.IdDonVi, (bool)Session[ConstantValues.SessionKeyVaiTro]); model.DanhSachChucNang = DocDanhSachChucNang(); return(View("ChinhSua", model)); } if (Request.Url != null) { SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath); } return(RedirectToAction("Index", "Login")); }
public ChangeResultSettings CapNhatNhomNguoiDung(string mdv, string nsd, string pas, NhomNguoiDungModel nhomNguoiDung) { throw new NotImplementedException(); }
public ChangeResultSettings CapNhatNhomNguoiDung(string mdv, string nsd, string pas, NhomNguoiDungModel nhomNguoiDung) { var result = new ChangeResultSettings(); try { result.ChangeResult = ChangeResult.ThanhCong; } catch (Exception) { result.ChangeResult = ChangeResult.ThatBai; } return(result); }
public ActionResult ChinhSua(FormCollection collection) { if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser)) { if (!string.IsNullOrEmpty(collection["save"].ToString())) { string id = collection["nhomNguoiDungId"].ToString(); if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Index", "NhomNguoiDung")); } var model = new NhomNguoiDungModel(); NhomNguoiDung nhomNguoiDung = xlNhomNguoiDung.Doc(id); model.NhomNguoiDungHienTai = nhomNguoiDung; if (nhomNguoiDung == null) { return(RedirectToAction("Index", "NhomNguoiDung")); } NotifyModel thongBao = new NotifyModel(); var user = (NguoiDung)SessionManager.ReturnSessionObject(ConstantValues.SessionKeyCurrentUser); try { nhomNguoiDung.Ten = collection["ten"].ToString(); nhomNguoiDung.MoTa = collection["moTa"].ToString(); nhomNguoiDung.IdDonVi = collection["donVi"].ToString(); //nguoi dung chi co the phan quyen nhung chuc nang ma ho co if (collection["chucNang"] != null) { var chucNangList = collection["chucNang"].Split(','); nhomNguoiDung.DanhSachChucNang = chucNangList.ToList(); } else { nhomNguoiDung.DanhSachChucNang = new List <string>(); } nhomNguoiDung.IdNguoiCapNhat = user.Id.ToString(); if (xlNhomNguoiDung.CapNhat(nhomNguoiDung)) { thongBao.TypeNotify = "alert-success"; thongBao.Message = "Cập nhật thông tin thành công"; } else { thongBao.TypeNotify = "alert-danger"; thongBao.Message = "Cập nhật thông tin thất bại!"; } } catch (Exception) { thongBao.TypeNotify = "alert-danger"; thongBao.Message = "Cập nhật thông tin thất bại!"; } ViewBag.ThongBao = thongBao; model.DanhSachDonVi = xlDonVi.DocDanhSachTuDonViCha(user.IdDonVi, (bool)Session[ConstantValues.SessionKeyVaiTro]); model.DanhSachChucNang = DocDanhSachChucNang(); return(View("ChinhSua", model)); } return(RedirectToAction("Index", "NhomNguoiDung")); } if (Request.Url != null) { SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath); } return(RedirectToAction("Index", "Login")); }