private void UpdateDataView() { string sSql = string.Empty; string filter = txtFilter.Text; if (filter != string.Empty) { string cleanFilter = filter.Replace("'", "''").ToLower(); cleanFilter = cleanFilter.Replace("[", "[[]"); cleanFilter = cleanFilter.Replace("_", "[_]"); cleanFilter = cleanFilter.Replace("%", "[%]"); sSql = " LOWER(ContainerType) like '%" + cleanFilter + "%' "; } using (ContainerTypeList containerTypes = ContainerType.GetAll(sSql)) { if (containerTypes != null) { if (containerTypes.Count > 0) { dg.DataSource = containerTypes; Utils.InitGridSort(ref dg); dg.DataBind(); lbNoresults.Visible = false; dg.Visible = true; } else { if (txtFilter.Text.Length > 0) { lbNoresults.Text = "No record match your search (" + txtFilter.Text + ")"; } lbNoresults.Visible = true; dg.Visible = false; } panelGrid.Visible = true; lbTitle.Text = "Container types list"; } } }
private void UpdateDataView() { lbError.Visible = false; InputFormType type = InputFormType.GetByKey(inputFormTypeCode); if (type != null) { // Get input form type lblTitle.Text = "New exclusion rule for input form type " + type.Name + " [" + type.Code + "]"; // Build collection with all possible container types (not used in exclusion rule) ContainerTypeList containerTypes = GetPossibleContainerTypes(); if (containerTypes.Count > 0) { dg.DataSource = containerTypes; Utils.InitGridSort(ref dg, false); dg.DataBind(); dg.DisplayLayout.AllowSortingDefault = Infragistics.WebUI.UltraWebGrid.AllowSorting.No; } else { dg.Visible = false; lbError.Text = "No container types"; lbError.CssClass = "hc_success"; lbError.Visible = true; UITools.HideToolBarButton(uwToolbar, "Save"); UITools.HideToolBarSeparator(uwToolbar, "SaveSep"); } } else { // Wrong request data lbError.CssClass = "hc_error"; lbError.Text = "Error: exclusion rule of input form type is null"; lbError.Visible = true; } }
private ContainerTypeList GetPossibleContainerTypes() { // result list of container type ContainerTypeList resultList = new ContainerTypeList(); // Get all container types using (ContainerTypeList containerTypes = ContainerType.GetAll()) { // Get all exclusion rules for this input form type (input form type code is not empty) string sqlFilter = "InputFormTypeCode = '" + inputFormTypeCode + "'"; using (InputFormTypeExclusionRuleList iftExclusionRules = InputFormTypeExclusionRule.GetAll(sqlFilter)) { // Delete container type already used if (containerTypes != null) { foreach (ContainerType ct in containerTypes) { bool isFound = false; if (iftExclusionRules != null) { foreach (InputFormTypeExclusionRule er in iftExclusionRules) { isFound = isFound || (er.ContainerTypeCode == ct.Code); } } if (!isFound) { resultList.Add(ct); } } } } } return(resultList); }