protected void PopulateSearchResult() { tvSearchResult.Nodes.Clear(); //populate Search Result - Segment Details - START List <SegmentDetail> ListSegDtls = new List <SegmentDetail>(); if (AuthUser.JuncUserRoles.FirstOrDefault().RoleID == 3 || AuthUser.JuncUserRoles.FirstOrDefault().RoleID == 4) { ListSegDtls = new SegmentDetailsDAL().GetSegmentDetails().ToList().Where(x => x.Status == "A").ToList(); } else { ListSegDtls = AuthUser.UserSegDtlWorkflows.Where(x => x.Status == "A").Select(x => x.SegmentDetail).ToList(); List <int> ParentIDs = ListSegDtls.Select(x => Convert.ToInt32(x.ParentDetailID)).Distinct().ToList(); while (ParentIDs.Count > 0) { List <SegmentDetail> lstParObj = new SegmentDetailsDAL().GetSegmentDetails().ToList().Where(x => ParentIDs.Contains(x.SegmentDetailID)).ToList(); foreach (SegmentDetail o in lstParObj) { if (ListSegDtls.Where(x => x.SegmentDetailID == o.SegmentDetailID).Count() == 0) { ListSegDtls.Add(o); } } ParentIDs = lstParObj.Select(x => Convert.ToInt32(x.ParentDetailID)).Distinct().ToList(); } } ListSegDtls = ListSegDtls.OrderBy(x => x.ParentDetailID).ThenBy(x => x.DetailCode).ToList(); foreach (Segment segment in new SegmentDAL().GetSegments().Where(w => ListSegDtls.Select(y => y.Segment.SegmentID).Contains(w.SegmentID)) .OrderBy(x => x.SegmentOrder).ToList()) { TreeNode parentNode = new TreeNode(segment.SegmentName, segment.SegmentID.ToString()); parentNode.SelectAction = TreeNodeSelectAction.None; //find deep level nodes CreateSearhResultNode(ListSegDtls, ref parentNode, segment.SegmentID, 0); tvSearchResult.Nodes.Add(parentNode); tvSearchResult.ExpandAll(); } foreach (TreeNode parentNode in tvSearchResult.Nodes) { FindAllNodes(parentNode); } //populate Search Result - Segment Details - END //populate Search Result - Selected Period - START BuildSelectedPeriodList(); //populate Search Result - Selected Period - END }
protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "EditRow") { ClearPageData(); GridViewRow selectedRow = gvUsers.Rows[Convert.ToInt32(e.CommandArgument)]; selectedRow.Style["background-color"] = "skyblue"; MasterUser objMasterUser = DAL.UsersDAL.StaticUserId(Convert.ToInt32(gvUsers.DataKeys[selectedRow.RowIndex]["UserID"]), ""); MembershipUser _MembershipUser = Membership.GetUser(objMasterUser.UserName); if ((Guid)_MembershipUser.ProviderUserKey == objMasterUser.UUID) { Session["SelectedMasterUser"] = objMasterUser; username.Value = objMasterUser.UserName.Trim(); email.Value = objMasterUser.UserEmail.Trim(); question.Value = objMasterUser.SecQuestion.Trim(); answer.Value = Security.Decrypt(objMasterUser.SecAnswer.Trim()); fullname.Value = objMasterUser.FullName.Trim(); icno.Value = objMasterUser.UserIC.Trim(); dept.Value = objMasterUser.Department.Trim(); phone.Value = objMasterUser.UserPhoneNo.Trim(); designation.Value = objMasterUser.Designation.Trim(); fax.Value = objMasterUser.Fax.Trim(); offaddress.Value = objMasterUser.OfficeAddress.Trim(); period.Value = objMasterUser.PeriodOfService.Trim(); grade.Value = objMasterUser.PositionGrade.Trim(); title.Value = objMasterUser.Title.Trim(); status.SelectedIndex = -1; status.Items.FindByValue(new Helper().GetItemStatusEnumName(Convert.ToChar(objMasterUser.UserStatus))).Selected = true; role.SelectedIndex = -1; ListItem item = role.Items.FindByValue(new UsersRoleDAL().ListUserRole().Where(x => x.UserID == objMasterUser.UserID) .Select(y => Convert.ToString(y.RoleID)).FirstOrDefault()); if (item != null) { role.SelectedValue = item.Value; } /*User Mengurus Workflow - start*/ List <AccountCode> lstAccCode = objMasterUser.UserMengurusWorkflows.Where(x => x.Status == "A").Select(x => x.AccountCode1).ToList(); List <string> lstParAccCode = lstAccCode.Select(x => x.ParentAccountCode).Distinct().ToList(); while (lstParAccCode.Count() > 0) { List <AccountCode> lstObjPar = new AccountCodeDAL().GetAccountCodes().ToList().Where(x => lstParAccCode.Contains(x.AccountCode1)).ToList(); foreach (AccountCode ac in lstObjPar) { if (lstAccCode.Where(x => x.AccountCode1 == ac.AccountCode1).Count() == 0) { lstAccCode.Add(ac); } } lstParAccCode = lstObjPar.Select(x => x.ParentAccountCode).Distinct().ToList(); } PopulateACChild(tvMengurus.Nodes, lstAccCode); /*User Mengurus Workflow - end*/ /*User Perjawatan Workflow - start*/ List <string> lstServiceCode = objMasterUser.UserPerjawatanWorkflows.Where(x => x.Status == "A").Select(x => x.GroupPerjawatanCode).ToList(); for (int i = 0; i < gvPerjawatanWorkFlow.Rows.Count; i++) { ((CheckBox)gvPerjawatanWorkFlow.Rows[i].Cells[0].FindControl("chkSelect")).Checked = lstServiceCode.Contains(gvPerjawatanWorkFlow.DataKeys[i]["GroupPerjawatanCode"].ToString()); } /*User Perjawatan Workflow - end*/ /*User Segment Details Workflow - start*/ List <SegmentDetail> lstSegDtls = objMasterUser.UserSegDtlWorkflows.Where(x => x.Status == "A").Select(x => x.SegmentDetail).ToList(); List <int> lstParSegDtls = lstSegDtls.Select(x => Convert.ToInt32(x.ParentDetailID)).Distinct().ToList(); while (lstParSegDtls.Count > 0) { List <SegmentDetail> lstParObj = new SegmentDetailsDAL().GetSegmentDetails().ToList().Where(x => lstParSegDtls.Contains(x.SegmentDetailID)).ToList(); foreach (SegmentDetail o in lstParObj) { if (lstSegDtls.Where(x => x.SegmentDetailID == o.SegmentDetailID).Count() == 0) { lstSegDtls.Add(o); } } lstParSegDtls = lstParObj.Select(x => Convert.ToInt32(x.ParentDetailID)).Distinct().ToList(); } Boolean TVcheckbox = false; foreach (TreeNode node in tvSegmentDetails.Nodes) { TVcheckbox = PopulateSDChild(node, lstSegDtls, 0); if (TVcheckbox == true) { node.Checked = true; } } /*User Segment Details Workflow - end*/ //Change workflow button colors accordingly - start if (role.SelectedValue != "3") { CustomizeButtonWorkflow(lstAccCode.Select(x => x.AccountCode1).ToList(), lstServiceCode, lstSegDtls.Select(x => x.SegmentDetailID).ToList()); } //Change workflow button colors accordingly - end ChangePageMode(Helper.PageMode.Edit); form_Wiz.Visible = true; } } } catch (Exception ex) { ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true); } }