private void ListViewNhomDichVu_FormatRow(object sender, FormatRowEventArgs e) { ThongTinDanhSachIntent_Response data = e.Model as ThongTinDanhSachIntent_Response; if (data != null) { if (data.ThongTinDanhSachIntent_ResponseType == (int)ThongTinDanhSachIntent_Response.TYPE.ROOT) { e.Item.Font = new Font(e.Item.Font, FontStyle.Bold); } if (data.ThongTinDanhSachIntent_ResponseType == (int)ThongTinDanhSachIntent_Response.TYPE.GROUP) { e.Item.Font = new Font(e.Item.Font, FontStyle.Bold); } } }
private void ListViewNhomDichVu_SelectedIndexChanged(object sender, EventArgs e) { mThongTinDanhSachIntent_Response = ListViewNhomDichVu.SelectedObject as ThongTinDanhSachIntent_Response; if (mThongTinDanhSachIntent_Response != null) { //Refresh dịch vụ if (mIntent_Response == null) { UtilityListView.ListViewRefresh(mListViewData, mThongTinDanhSachIntent_Response.mListData); } else { UtilityListView.ListViewRefresh(mListViewData, mThongTinDanhSachIntent_Response.mListData, mIntent_Response.Intent_ResponseID.ToString(), 0); } //Seach if (!String.IsNullOrEmpty(txtSearch.Text.Trim()) && mThongTinDanhSachIntent_Response.mListData.Count > 0) { UtilityListView.DoListViewFilter(mListViewData, txtSearch.Text); } } }
public FormViewIntent_Response() { InitializeComponent(); this.Translate(); this.UpdateUI(); base.DoInit(); //Create worker mThread = new ExBackgroundWorker(); mThread.WorkerReportsProgress = true; mThread.WorkerSupportsCancellation = true; mThread.ProgressChanged += new ProgressChangedEventHandler(bwAsync_WorkerChanged); mThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwAsync_WorkerCompleted); mThread.DoWork += new DoWorkEventHandler(bwAsync_Worker); this.olvColumnLoai.AspectGetter = delegate(object x) { Intent_Response data = (Intent_Response)x; if (data != null && data.Intent_ResponseID > 0) { return(DM_Intent_Type.GetDefault(data.DM_Intent_TypeID).DM_Intent_TypeName); } return(""); }; this.olvColumnDoiTuong.AspectGetter = delegate(object x) { Intent_Response data = (Intent_Response)x; if (data != null && data.Intent_ResponseID > 0) { DM_Entity_Type checkdata = DM_Entity_Type.GetDefaultList(0).FirstOrDefault(p => p.DM_Intent_TypeID == data.DM_Intent_TypeID && p.DM_Entity_TypeID == data.DM_Entity_TypeID); if (checkdata != null) { return(checkdata.DM_Entity_TypeName); } else { return(""); } } return(""); }; //Init container tree list view this.mListViewData.CanExpandGetter = delegate(object x) { Intent_Response data = (Intent_Response)x; if (data.mListSubData != null && data.mListSubData.Count > 0) { IList <Intent_Response> mListSubData = data.mListSubData; if (mListSubData.Count > 0) { return(true); } } return(false); }; this.mListViewData.ChildrenGetter = delegate(object x) { Intent_Response data = (Intent_Response)x; IList <Intent_Response> mListSubData = data.mListSubData; return(mListSubData); }; //Init container tree list view this.ListViewNhomDichVu.CanExpandGetter = delegate(object x) { ThongTinDanhSachIntent_Response data = (ThongTinDanhSachIntent_Response)x; if (data.mListSubData != null && data.mListSubData.Count > 0) { IList <ThongTinDanhSachIntent_Response> mListSubData = data.mListSubData; return(data.mListSubData.Count > 0); } return(false); }; this.ListViewNhomDichVu.ChildrenGetter = delegate(object x) { ThongTinDanhSachIntent_Response data = (ThongTinDanhSachIntent_Response)x; return(data.mListSubData); }; }
private void bwAsync_Worker(object sender, DoWorkEventArgs e) { ProcessingType type = (ProcessingType)e.Argument; e.Result = type; switch (type) { case ProcessingType.LoadData: { mListData_Flat = Intent_ResponsePresenter.GetIntent_Responses(); //Update dữ liệu mListData = new List <Intent_Response>(); foreach (DM_Intent_Type nhom in DM_Intent_Type.GetDefaultList(0)) { if (mListData_Flat.Any(p => p.DM_Intent_TypeID == nhom.DM_Intent_TypeID)) { Intent_Response group_Intent_Response = new Intent_Response(); group_Intent_Response.DM_Intent_TypeID = nhom.DM_Intent_TypeID; group_Intent_Response.Intent_ResponseID = -1; group_Intent_Response.Data = nhom.DM_Intent_TypeName; group_Intent_Response.mListSubData = new List <Intent_Response>(); mListData.Add(group_Intent_Response); IList <DM_Entity_Type> ListDM_Entity_Type = DM_Entity_Type.GetDefaultList(0).Where(p => p.DM_Intent_TypeID == nhom.DM_Intent_TypeID).ToList(); if (ListDM_Entity_Type.Count == 0) { group_Intent_Response.mListSubData = mListData_Flat.Where(p => p.DM_Intent_TypeID == nhom.DM_Intent_TypeID).ToList(); group_Intent_Response.mListSubData = group_Intent_Response.mListSubData.Select(p => { p.mParent = group_Intent_Response; return(p); }).ToList(); } else { foreach (DM_Entity_Type loai_dichvu in ListDM_Entity_Type) { if (mListData_Flat.Any(p => p.DM_Entity_TypeID == loai_dichvu.DM_Entity_TypeID && p.DM_Intent_TypeID == loai_dichvu.DM_Intent_TypeID)) { Intent_Response type_service = new Intent_Response(); type_service.DM_Intent_TypeID = nhom.DM_Intent_TypeID; type_service.DM_Entity_TypeID = loai_dichvu.DM_Entity_TypeID; type_service.Intent_ResponseID = -2; type_service.Data = loai_dichvu.DM_Entity_TypeName; type_service.mListSubData = mListData_Flat.Where(p => p.DM_Entity_TypeID == loai_dichvu.DM_Entity_TypeID && p.DM_Intent_TypeID == loai_dichvu.DM_Intent_TypeID).ToList(); type_service.mListSubData = type_service.mListSubData.Select(p => { p.mParent = type_service; return(p); }).ToList(); if (type_service.mListSubData.Count > 0) { group_Intent_Response.mListSubData.Add(type_service); } } } } } } //Update danh sách { mListThongTinDanhSachIntent_Response = new List <ThongTinDanhSachIntent_Response>(); mListThongTinDanhSachIntent_Response_Flat = new List <ThongTinDanhSachIntent_Response>(); ThongTinDanhSachIntent_Response.ThongTinDanhSachIntent_ResponseID_Index = 1; //Add tất cả nhóm dịch vụ ThongTinDanhSachIntent_Response root = new ThongTinDanhSachIntent_Response(); root.ThongTinDanhSachIntent_ResponseType = (int)ThongTinDanhSachIntent_Response.TYPE.ROOT; root.mListData = mListData; root.ThongTinDanhSachIntent_ResponseName = String.Format("Tất cả ({0})".Translate(), mListData_Flat.Count()); mListThongTinDanhSachIntent_Response.Add(root); mListThongTinDanhSachIntent_Response_Flat.Add(root); foreach (DM_Intent_Type nhom_dich_vu in DM_Intent_Type.GetDefaultList(1)) { Intent_Response group_service = mListData.FirstOrDefault(p => p.DM_Intent_TypeID == nhom_dich_vu.DM_Intent_TypeID && p.Intent_ResponseID == -1); if (group_service != null) { ThongTinDanhSachIntent_Response mData = new ThongTinDanhSachIntent_Response(); mData.ThongTinDanhSachIntent_ResponseType = (int)ThongTinDanhSachIntent_Response.TYPE.GROUP; mData.DM_Intent_TypeID = nhom_dich_vu.DM_Intent_TypeID; mData.mListSubData = new List <ThongTinDanhSachIntent_Response>(); mData.mListData = group_service.mListSubData; mData.ThongTinDanhSachIntent_ResponseName = DM_Intent_Type.GetDefault(mData.DM_Intent_TypeID).DM_Intent_TypeName + " (" + mListData_Flat.Where(p => p.DM_Intent_TypeID == mData.DM_Intent_TypeID).Count() + ")"; mListThongTinDanhSachIntent_Response.Add(mData); mListThongTinDanhSachIntent_Response_Flat.Add(mData); //Add loại dịch vụ { IList <DM_Entity_Type> list_sub = DM_Entity_Type.GetDefaultList(0).Where(p => p.DM_Intent_TypeID == nhom_dich_vu.DM_Intent_TypeID).ToList(); list_sub = list_sub.OrderBy(p => p.DM_Intent_TypeID).ThenBy(p => p.DM_Entity_TypeID).ToList(); foreach (DM_Entity_Type sub_data in list_sub) { Intent_Response type_service = group_service.mListSubData.FirstOrDefault(p => p.DM_Entity_TypeID == sub_data.DM_Entity_TypeID && p.Intent_ResponseID == -2 && p.DM_Intent_TypeID == sub_data.DM_Intent_TypeID); if (type_service != null) { ThongTinDanhSachIntent_Response mSubData = new ThongTinDanhSachIntent_Response(); mSubData.ThongTinDanhSachIntent_ResponseType = (int)ThongTinDanhSachIntent_Response.TYPE.SUB_GROUP; mSubData.DM_Intent_TypeID = mData.DM_Intent_TypeID; mSubData.DM_Entity_TypeID = sub_data.DM_Entity_TypeID; mSubData.mListData = group_service.mListSubData.Where(p => p.DM_Entity_TypeID == sub_data.DM_Entity_TypeID && p.DM_Intent_TypeID == sub_data.DM_Intent_TypeID).ToList(); mSubData.ThongTinDanhSachIntent_ResponseName = DM_Entity_Type.GetDefault(mSubData.DM_Entity_TypeID).DM_Entity_TypeName + " (" + mListData_Flat.Where(p => p.DM_Entity_TypeID == mSubData.DM_Entity_TypeID && p.DM_Intent_TypeID == mSubData.DM_Intent_TypeID).Count() + ")"; if (mSubData.mListData.Count > 0) { mData.mListSubData.Add(mSubData); mListThongTinDanhSachIntent_Response_Flat.Add(mSubData); } } } } } } } } break; default: break; } }