public async Task SearchModuleFieldInfoOnchange(ChangeEventArgs e) { HomeBus homeBus = new HomeBus(moduleService, iConfiguration, distributedCache); #region Load DropdownList ĐK search. các phép And Or var field = moduleFieldInfo.Where(x => x.FieldID == e.Value.ToString()); if (field != null && field.Any()) { var conditionDefCode = await homeBus.LoadAllDefCode("SCDTYPE", field.First().ConditionType.ToString()); if (conditionDefCode != null && conditionDefCode.Any()) { var conditionValues = await homeBus.LoadAllDefCode(conditionDefCode.First().CodeValueName); if (conditionValues != null && conditionValues.Any()) { Conditions = conditionValues.ToList(); } } } #endregion }
protected override async Task OnInitializedAsync() { try { //if (string.IsNullOrEmpty(HttpContext.Session.GetString("UserName")) && modId.ToLower() != ConstMod.ModListHomo.ToLower()) //{ // return RedirectToAction("Login", "Home"); // NavigationManager.NavigateTo("PageToRedirect"); //} //Dongpv:look updata if (!string.IsNullOrEmpty(modId) && !string.IsNullOrEmpty(OrderID)) { ArrayList arrDetail = new ArrayList(); SysUtils.String2ArrayList(ref arrDetail, OrderID, "@", "="); modId = SysUtils.getValue(arrDetail, "MODID").ToString(); //Fix //modId = "03" + modId.Substring(2, 3); } //Dongpv:look updata CheckBoxModels = new List <CheckBoxModel>(); lstControl = new List <ModuleFieldInfo>(); moduleFieldInfo = new List <ModuleFieldInfo>(); HomeBus homeBus = new HomeBus(moduleService, iConfiguration, distributedCache); var data = await homeBus.GetModule(modId); int userId = int.Parse("0" + "" /*HttpContext.Session.GetString("UserId")*/); var groupModUser = await moduleService.GetGroupModByUserId(userId); RoleUser = groupModUser; moduleInfoModel = homeBus.ConvertFromViewModel(data); //Set title var arr = new string[1]; arr[0] = moduleInfoModel.ModulesInfo.ModuleName.GetLanguageTitle(moduleInfoModel.LanguageInfo); await JSRuntime.InvokeVoidAsync("SetTitle", arr); //Hết SetTitle Title = moduleInfoModel.ModulesInfo.ModuleName.GetLanguageTitle(await homeBus.LoadAllBtnLanguage()); var cb = moduleInfoModel.FieldsInfo.Where(x => !String.IsNullOrEmpty(x.ListSource)); var scdType = moduleInfoModel.FieldsInfo.Select(x => x.ConditionType); if (cb.Any()) { var codeInfoParram = cb.Select(x => new CodeInfoParram { CtrlType = x.ControlType, Name = x.FieldName, ListSource = x.ListSource }); //var para = string.Join("", sources); var sourceCodeInfo = cb.Where(x => x.ListSource.Contains(":"));//Lấy những thông tin các ListSource từ DefCode var codeInfoModels = new List <CodeInfoModel>(); if (sourceCodeInfo != null && sourceCodeInfo.Any()) { var defCodeAll = await homeBus.LoadAllDefCode(); var lstSource = sourceCodeInfo.Select(x => x.ListSource).ToList(); var cbDefCode = defCodeAll.Where(x => lstSource.Contains(":" + x.CodeType + "." + x.CodeName)); foreach (var item in sourceCodeInfo) { codeInfoModels.Add(new CodeInfoModel { Name = item.FieldName, CodeInfos = cbDefCode.Where(x => ":" + x.CodeType + "." + x.CodeName == item.ListSource).ToList() }); } } var dataCB = (await moduleService.GetCombobox(codeInfoParram.Where(x => !x.ListSource.Contains(":")).ToList()));//Lấy thông tin các Combobox theo Store codeInfoModels.AddRange(dataCB.Data); DataCombobox = codeInfoModels; } modSearch = await homeBus.LoadModSearchByModId(modId); if (modSearch != null) { var parrams = new List <string>(); if (!string.IsNullOrEmpty(parramMods)) { var btnParramInfo = (List <ButtonParamInfo>)JsonConvert.DeserializeObject <List <ButtonParamInfo> >(parramMods); var temp = btnParramInfo.Select(x => x.FieldName + " = '" + x.Value + "'"); parrams.AddRange(temp); } var query = ""; if (modSearch.QueryFormat.IndexOf("{0}") > 0) { if (modSearch.QueryFormat.IndexOf("{1}") > 0) { var currPage = 1; var paging = String.Format(" Limit {1} offset {0}", (currPage - 1) * CommonMethod.PageSize, (currPage - 1) * CommonMethod.PageSize + CommonMethod.PageSize); query = string.Format(modSearch.QueryFormat, Schema, parrams.Any() ? String.Join(" AND ", parrams) : " 1=1 ", paging); } else { query = string.Format(modSearch.QueryFormat, Schema, parrams.Any() ? String.Join(" AND ", parrams) : " 1=1 "); } } else { query = String.Format(modSearch.QueryFormat, Schema); } //Dongpv: //var dataGrid = await moduleService.LoadQueryModule(new ParramModuleQuery { Store = query }); var moduleFields = moduleInfoModel.FieldsInfo.FirstOrDefault(); if (modSearch.GroupModule == "004") { Message msg = new Message(); msg.MsgType = Constants.MSG_MISC_TYPE; //MESSAGE TYPE: INQ, MAINTAIN, TXN, REPORT msg.ObjectName = Constants.OBJ_SEARCH; msg.MsgAction = Constants.MSG_SEARCH; msg.Body.Add("SearchObject"); msg.Body.Add(moduleFields.Entity); msg.Body.Add("Condition"); msg.Body.Add(" WHERE 1=1"); msg.Body.Add("Page"); msg.Body.Add(0); var dataGrid = await moduleService.getQuery(msg); DataSearch = dataGrid; } else { var dataGrid = await moduleService.LoadQueryModule(new ParramModuleQuery { Store = query }); DataSearch = dataGrid; } //Dongpv: //var dataGrid = await _moduleService.LoadQueryModule(new ParramModuleQuery { Store = modSearch.QueryFormat }); ////Dongpv: //DataSearch = dataGrid; btnInfos = moduleInfoModel.ButtonsInfo == null ? new List <ButtonInfo>() : moduleInfoModel.ButtonsInfo; var moduleInfo = moduleInfoModel.ModulesInfo == null ? new ModuleInfo() : moduleInfoModel.ModulesInfo; moduleFieldInfo = moduleInfoModel.FieldsInfo == null ? new List <ModuleFieldInfo>() : moduleInfoModel.FieldsInfo; var parrs = moduleInfoModel.ButtonParamsInfo == null ? new List <ButtonParamInfo>() : moduleInfoModel.ButtonParamsInfo; codeInfos = DataCombobox; checkColAction = btnInfos.Where(x => x.ShowOnToolbar == "N").ToList(); checkBtnViews = btnInfos.Where(x => x.ButtonName.ToUpper() == EDefModBtn.BTN_VIEW.ToString().ToUpper()).ToList(); checkBtnEdits = btnInfos.Where(x => x.ButtonName.ToUpper() == EDefModBtn.BTN_EDIT.ToString().ToUpper()).ToList(); checkBtnDels = btnInfos.Where(x => x.ButtonName.ToUpper() == EDefModBtn.BTN_DELETE.ToString().ToUpper()).ToList(); checkBtnAssRole = btnInfos.Where(x => x.ButtonName.ToUpper() == EDefModBtn.BTN_ASSIGN_ROLE.ToString().ToUpper()).ToList(); checkBtnAssUsers = btnInfos.Where(x => x.ButtonName.ToUpper() == EDefModBtn.BTN_ASSIGN_USER.ToString().ToUpper()).ToList(); if (groupMods == null || groupMods.Count == 0) { groupMods = new List <GroupMod>(); groupMods.Add(new GroupMod { GroupId = "1", ModId = moduleInfoModel.ModulesInfo.ModuleID }); if (checkBtnEdits.Any()) { groupMods.Add(new GroupMod { GroupId = "1", ModId = checkBtnEdits.First().CallModuleID }); } if (checkBtnDels.Any()) { groupMods.Add(new GroupMod { GroupId = "1", ModId = checkBtnDels.First().CallModuleID }); } } checkBtnDel = checkBtnDels.Any(); checkBtnView = checkBtnViews.Any(); checkBtnEdit = checkBtnEdits.Any(); checkBtnAssignRole = checkBtnAssRole.Any(); checkBtnAssignUser = checkBtnAssUsers.Any(); parramEdit = new List <ButtonParamInfo>(); parramView = new List <ButtonParamInfo>(); parramDel = new List <ButtonParamInfo>(); parramAssignUser = new List <ButtonParamInfo>(); if (checkBtnView) { var parramViews = parrs.Where(x => x.ButtonName == EDefModBtn.BTN_VIEW.ToString()); if (parramViews.Any()) { parramView = parramViews.ToList(); } } if (checkBtnEdit) { var parramEdits = parrs.Where(x => x.ButtonName == EDefModBtn.BTN_EDIT.ToString()); if (parramEdits.Any()) { parramEdit = parramEdits.ToList(); } } if (checkBtnDel) { var parramDels = parrs.Where(x => x.ButtonName == EDefModBtn.BTN_DELETE.ToString()); if (parramDels.Any()) { parramDel = parramDels.ToList(); } } if (checkBtnAssignUser) { var parramAssignUsers = parrs.Where(x => x.ButtonName == EDefModBtn.BTN_ASSIGN_USER.ToString()); if (parramAssignUsers.Any()) { parramAssignUser = parramAssignUsers.ToList(); } } } //return View("Search", modId); } catch (Exception ex) { //return View("Search", modId); } }