public void SetData(Entities objectContext, User searchUser, UserOrRoleRights currUserRights) { Tools.CheckObjectContext(objectContext); if (searchUser == null) { throw new ArgumentNullException("searchUser"); } if (currUserRights == null) { throw new ArgumentNullException("currUserRights"); } BRoles bRoles = new BRoles(); user = searchUser; lblUserName.Text = searchUser.name; searchUser.Reports.Load(); lblReports.Text = string.Format("Доклади: {0}", searchUser.Reports.Count); if (searchUser.isAdmin == true) { lblRole.Text = "Администратор"; lblRole.ForeColor = Color.Red; } else { Role userRole = bRoles.GetUserRole(objectContext, searchUser); lblRole.Text = string.Format("Роля: {0}", userRole.name); } btnSeeReports.Visible = currUserRights.SeeVisibleReportsVisible; btnSeeReports.Enabled = currUserRights.SeeVisibleReportsEnabled; btnSeeDeletedReports.Visible = currUserRights.SeeDeletedReportVisible; btnSeeDeletedReports.Enabled = currUserRights.SeeDeletedReportsEnabled; if (currUserRights.IsAdmin == true && searchUser.isAdmin == false) { btnChangeRole.Visible = true; List <Role> allRoles = bRoles.GetRoles(objectContext); if (allRoles.Count > 1) { btnChangeRole.Enabled = true; } else { btnChangeRole.Enabled = false; } } else { btnChangeRole.Visible = false; } }
public void SetData(Report currReport, UserOrRoleRights userRights) { if (currReport == null) { throw new ArgumentNullException("currReport"); } if (userRights == null) { throw new ArgumentNullException("userRights"); } if (!currReport.UserReference.IsLoaded) { currReport.UserReference.Load(); } report = currReport; if (currReport.visible == true) { btnDelete.Visible = userRights.DeleteReportVisible; btnDelete.Enabled = userRights.DeleteReportEnabled; } else { btnDelete.Visible = false; } if (currReport.visible == true) { if (currReport.solved == false) { btnSolve.Visible = userRights.MarkReportAsResolvedVisible; btnSolve.Enabled = userRights.MarkReportAsResolvedEnabled; } else { btnSolve.Visible = false; } } else { btnSolve.Visible = false; } lblDateAdded.Text = report.dateAdded.ToLocalTime().ToString(); lblUser.Text = currReport.User.name; lblAbout.Text = string.Format("Относно: {0}", currReport.about); if (currReport.solved == true) { lblStatus.Text = "Статус: решен"; } else { lblStatus.Text = "Статус: не решен"; } lblDescription.Text = currReport.description; }