private void UpdateFunction() { int _groupID = (int)grdvGroup.GetRowCellValue(grdvGroup.FocusedRowHandle, colGroupID); busGroupFunction = new BUS.BUStblGROUP_FUNCTION(); var _oldFunction = busGroupFunction.LayTatCatblGROUP_FUNCTION().Where(a => a.GROUPID == _groupID); var _newFunction = GetGroupFunction(_groupID); foreach (var a in _oldFunction) { busGroupFunction.XoatblGROUP_FUNCTION(a.GROUPID, a.FUNCTIONID, a.MODULEID); } foreach (var b in _newFunction) { busGroupFunction.ThemtblGROUP_FUNCTION(b); } }
//lấy quyền sử dụng các control trong từng module cho người dùng, bao gồm cả việc ng sd thuộc nhiều nhóm sử dụng private void GetFunctionOfGroupsByUserID(int _userID) { busGroupUser = new BUS.BUStblGROUPUSER(); var _GroupUser = busGroupUser.LayTatCatblGROUPUSER().Where(a => a.USERID == _userID); List<DTO.DTOtblGROUP_FUNCTION> _lstGroupFunction = new List<DTO.DTOtblGROUP_FUNCTION>(); foreach (var a in _GroupUser) { busGroupFunction = new BUS.BUStblGROUP_FUNCTION(); var _lstFunc = busGroupFunction.LayTatCatblGROUP_FUNCTION().Where(p => p.GROUPID == a.GROUPID).ToList(); foreach (var b in _lstFunc) { _lstGroupFunction.Add(b); } } //var _IsUsedFunc= _lstGroupFunction.GroupBy(a => a.FUNCTIONID).ToList(); var _IsUsedFunc = _lstGroupFunction.Where(a => a.VALUE == true).GroupBy(a => a.FUNCTIONID, (key, group) => group.First()).ToList(); foreach (var a in _IsUsedFunc) { switch (a.FUNCTIONID) { #region cấp quyền sử dụng các chức năng case 1: Function.DatPhong.Nhan = true; break; case 2: Function.DatPhong.DK = true; break; case 3: Function.DatPhong.Sua = true; break; case 4: Function.DatPhong.Xoa = true; break; case 5: Function.DSPhong.Them = true; break; case 6: Function.DSPhong.Sua = true; break; case 7: Function.DSPhong.Xoa = true; break; case 8: Function.KP_LP.ThemLP = true; break; case 9: Function.KP_LP.SuaLP = true; break; case 10: Function.KP_LP.XoaLP = true; break; case 11: Function.KP_LP.ThemKP = true; break; case 12: Function.KP_LP.SuaKP = true; break; case 13: Function.KP_LP.XoaKP = true; break; case 14: Function.Gia.CapNhat = true; break; case 15: Function.ThanhToan.TinhTien = true; break; case 16: Function.HoaDon.XoaHD = true; break; case 17: Function.PT_CK.ThemPT = true; break; case 18: Function.PT_CK.SuaPT = true; break; case 19: Function.PT_CK.XoaPT = true; break; case 20: Function.PT_CK.ThemCK = true; break; case 21: Function.PT_CK.SuaCK = true; break; case 22: Function.PT_CK.XoaCK = true; break; case 23: Function.KhachHang.ThemKH = true; break; case 24: Function.KhachHang.SuaKH = true; break; case 25: Function.KhachHang.XoaKH = true; break; case 26: Function.KhachHang.ThemLKH = true; break; case 27: Function.KhachHang.SuaLKH = true; break; case 28: Function.KhachHang.XoaLKH = true; break; case 29: Function.NhanVien.ThemNV = true; break; case 30: Function.NhanVien.SuaTTNV = true; break; case 31: Function.NhanVien.Xoa = true; break; case 32: Function.ChucVu.Them = true; break; case 33: Function.ChucVu.Sua = true; break; case 34: Function.ChucVu.Xoa = true; break; case 35: Function.DichVu.Them = true; break; case 36: Function.DichVu.Sua = true; break; case 37: Function.DichVu.Xoa = true; break; case 38: Function.DichVu.ThemDV = true; break; case 39: Function.ThietBi.Them = true; break; case 40: Function.ThietBi.Sua = true; break; case 41: Function.ThietBi.Xoa = true; break; case 42: Function.ThietBi.ThemTB = true; break; case 43: Function.User.Them = true; break; case 44: Function.User.Sua = true; break; case 45: Function.User.Xoa = true; break; case 46: Function.Group.Them = true; break; case 47: Function.Group.Sua = true; break; case 48: Function.Group.Xoa = true; break; case 49: Function.BaoCao.Phong = true; break; case 50: Function.BaoCao.Thue_DatPhong = true; break; case 51: Function.BaoCao.DoanhThu = true; break; case 52: Function.BaoCao.DichVu = true; break; case 53: Function.BaoCao.ThietBi = true; break; case 54: Function.BaoCao.KhachHang = true; break; case 55: Function.BaoCao.NhanVien = true; break; case 56: Function.KP_LP.ThemTT = true; break; case 57: Function.KP_LP.SuaTT = true; break; case 58: Function.KP_LP.XoaTT = true; break; #endregion } } }
private void LoadFunction() { if (grdvGroup.GetRowCellValue(grdvGroup.FocusedRowHandle, colGroupID) != null) { busFunction = new BUS.BUStblFUNCTION(); busGroupFunction = new BUS.BUStblGROUP_FUNCTION(); busModule = new BUS.BUStblMODULE(); int _groupID = (int)grdvGroup.GetRowCellValue(grdvGroup.FocusedRowHandle, colGroupID); var _Func = (from a in busGroupFunction.LayTatCatblGROUP_FUNCTION() join b in busModule.LayTatCatblMODULE() on a.MODULEID equals b.MODULEID join c in busFunction.LayTatCatblFUNCTION() on a.FUNCTIONID equals c.FUNCTIONID where a.GROUPID == _groupID orderby a.MODULEID ascending select new { ModuleID = a.MODULEID, ModuleName = b.MODULENAME, FunctionID = a.FUNCTIONID, FunctionName = c.FUNCTIONNAME, Value = a.VALUE }); DataTable dt = clsXuLy.ConvertDataTable(_Func.ToList()); grdFunction.DataSource = dt; } else grdFunction.DataSource = null; }