protected void rptRoles_ItemDataBound(object sender, RepeaterItemEventArgs e) { EmployeeRoleForBackend role = (EmployeeRoleForBackend)e.Item.DataItem; int roleId = role.RoleId; string roleName = role.RoleName; string roleDisplayName = role.RoleDisplayName; int empTotal = role.EmpTotal; HtmlGenericControl ctlRoleName = (HtmlGenericControl)e.Item.FindControl("ctlRoleName"); ctlRoleName.InnerHtml = roleName; ctlRoleName.Attributes["class"] = "RoleDisplay-" + roleName; HtmlGenericControl ctlRoleDisplayName = (HtmlGenericControl)e.Item.FindControl("ctlRoleDisplayName"); ctlRoleDisplayName.InnerHtml = roleDisplayName; ctlRoleDisplayName.Attributes["class"] = "RoleDisplay-" + roleName; HtmlAnchor btnEdit = (HtmlAnchor)e.Item.FindControl("btnEdit"); btnEdit.Attributes["onclick"] = string.Format("popWin('Role-Config.aspx?act={0}&roleid={1}', 700, 600); return false;", ConfigFormAction.edit, roleId); btnEdit.Title = Resources.Lang.Main_btnEdit_Hint; Literal ltrEdit = (Literal)e.Item.FindControl("ltrEdit"); ltrEdit.Text = Resources.Lang.Main_btnEdit; HtmlAnchor btnGrant = (HtmlAnchor)e.Item.FindControl("btnGrant"); btnGrant.Attributes["onclick"] = string.Format("popWin('Role-Privilege.aspx?roleid={0}', 700, 600); return false;", roleId); btnGrant.Title = Resources.Lang.Main_btnGrant_Hint; Literal ltrGrant = (Literal)e.Item.FindControl("ltrGrant"); ltrGrant.Text = Resources.Lang.Main_btnGrant; LinkButton btnDelete = (LinkButton)e.Item.FindControl("btnDelete"); btnDelete.CommandArgument = string.Join(",", roleId.ToString(), roleName); btnDelete.Text = "<i class='fa fa-trash-o'></i> " + Resources.Lang.Main_btnDelete; btnDelete.ToolTip = Resources.Lang.Main_btnDelete_Hint; btnDelete.OnClientClick = string.Format("return confirm('" + Resources.Lang.Role_ConfirmDelete_Format + "');", roleName, roleDisplayName); string ownerAccount = role.PostAccount; int ownerDeptId = role.PostDeptId.Value; btnEdit.Visible = empAuth.CanEditThisPage(false, ownerAccount, ownerDeptId); btnGrant.Visible = btnEdit.Visible && (roleName != "admin"); if (!empAuth.CanDelThisPage(ownerAccount, ownerDeptId) || roleName == "admin" || empTotal > 0) { btnDelete.Visible = false; } }
protected void rptDepartments_ItemDataBound(object sender, RepeaterItemEventArgs e) { DepartmentForBackend deptData = (DepartmentForBackend)e.Item.DataItem; int deptId = deptData.DeptId; string deptName = deptData.DeptName; int empTotal = deptData.EmpTotal; HtmlAnchor btnEdit = (HtmlAnchor)e.Item.FindControl("btnEdit"); btnEdit.Attributes["onclick"] = string.Format("popWin('Department-Config.aspx?act={0}&id={1}', 700, 600); return false;", ConfigFormAction.edit, deptId); btnEdit.Title = Resources.Lang.Main_btnEdit_Hint; Literal ltrEdit = (Literal)e.Item.FindControl("ltrEdit"); ltrEdit.Text = Resources.Lang.Main_btnEdit; LinkButton btnDelete = (LinkButton)e.Item.FindControl("btnDelete"); btnDelete.CommandArgument = string.Join(",", deptId.ToString(), deptName); btnDelete.Text = "<i class='fa fa-trash-o'></i> " + Resources.Lang.Main_btnDelete; btnDelete.ToolTip = Resources.Lang.Main_btnDelete_Hint; btnDelete.OnClientClick = string.Format("return confirm('" + Resources.Lang.Dept_ConfirmDelete_Format + "');", deptId, deptName); string ownerAccount = deptData.PostAccount; int ownerDeptId = deptData.PostDeptId; btnEdit.Visible = empAuth.CanEditThisPage(false, ownerAccount, ownerDeptId); if (!empAuth.CanDelThisPage(ownerAccount, ownerDeptId) || empTotal > 0) { btnDelete.Visible = false; } }
protected void rptAccounts_ItemDataBound(object sender, RepeaterItemEventArgs e) { EmployeeForBackend empData = (EmployeeForBackend)e.Item.DataItem; int empId = empData.EmpId; string empAccount = empData.EmpAccount; string roleName = empData.RoleName; bool isAccessDenied = empData.IsAccessDenied; DateTime startDate = empData.StartDate.Value; DateTime endDate = empData.EndDate.Value; string remarks = (empData.Remarks ?? "").Trim(); HtmlGenericControl ctlRoleDisplayName = (HtmlGenericControl)e.Item.FindControl("ctlRoleDisplayName"); ctlRoleDisplayName.InnerHtml = empData.RoleDisplayName; ctlRoleDisplayName.Attributes["class"] = "RoleDisplay-" + roleName; HtmlTableRow EmpArea = (HtmlTableRow)e.Item.FindControl("EmpArea"); if (isAccessDenied) { HtmlGenericControl ctlIsAccessDenied = (HtmlGenericControl)e.Item.FindControl("ctlIsAccessDenied"); ctlIsAccessDenied.Attributes["title"] = Resources.Lang.Status_AccessDenied; ctlIsAccessDenied.Visible = true; EmpArea.Attributes["class"] = "table-danger"; } HtmlGenericControl ctlAccountState = (HtmlGenericControl)e.Item.FindControl("ctlAccountState"); if (DateTime.Today < startDate && empAccount != "admin") { // on schedule ctlAccountState.Attributes["class"] = "fa fa-hourglass-start fa-lg text-info"; ctlAccountState.Attributes["title"] = Resources.Lang.Status_OnSchedule; } else if (endDate < DateTime.Today && empAccount != "admin" || isAccessDenied) { // offline ctlAccountState.Attributes["class"] = "fa fa-ban fa-lg text-danger"; ctlAccountState.Attributes["title"] = Resources.Lang.Status_AccessDeniedOrExpired; EmpArea.Attributes["class"] = "table-danger"; } else { // online ctlAccountState.Attributes["title"] = Resources.Lang.Status_Normal; } Literal ltrValidDateRange = (Literal)e.Item.FindControl("ltrValidDateRange"); ltrValidDateRange.Text = string.Format("{0:yyyy-MM-dd} ~ {1:yyyy-MM-dd}", startDate, endDate); if (remarks != "") { HtmlGenericControl ctlRemarks = (HtmlGenericControl)e.Item.FindControl("ctlRemarks"); ctlRemarks.Attributes["title"] = remarks; ctlRemarks.Visible = true; } HtmlAnchor btnEdit = (HtmlAnchor)e.Item.FindControl("btnEdit"); btnEdit.Attributes["onclick"] = string.Format("popWin('Account-Config.aspx?act={0}&empid={1}', 700, 600); return false;", ConfigFormAction.edit, empId); btnEdit.Title = Resources.Lang.Main_btnEdit_Hint; Literal ltrEdit = (Literal)e.Item.FindControl("ltrEdit"); ltrEdit.Text = Resources.Lang.Main_btnEdit; LinkButton btnDelete = (LinkButton)e.Item.FindControl("btnDelete"); btnDelete.CommandArgument = string.Join(",", empId.ToString(), empAccount); btnDelete.Text = "<i class='fa fa-trash-o'></i> " + Resources.Lang.Main_btnDelete; btnDelete.ToolTip = Resources.Lang.Main_btnDelete_Hint; btnDelete.OnClientClick = string.Format("return confirm('" + Resources.Lang.Account_ConfirmDelete_Format + "');", empData.EmpName, empData.EmpAccount); string ownerAccount = empData.OwnerAccount; int ownerDeptId = empData.OwnerDeptId; btnEdit.Visible = (empAuth.CanEditThisPage(false, ownerAccount, ownerDeptId) || c.IsMyAccount(empAccount)); if (!empAuth.CanDelThisPage(ownerAccount, ownerDeptId) || empAccount == "admin" || empAccount == c.GetEmpAccount()) { btnDelete.Visible = false; } }