private void Save() { int techspecContainerId = -1; if (ddlTechspecContainers != null) { string sTechspecCont = ddlTechspecContainers.SelectedValue; if (sTechspecCont.Length > 0) { techspecContainerId = Convert.ToInt32(sTechspecCont); } } if (techspecContainerId > 0) { Container fContainer = Container.GetByKey(featureContainerId); Container tContainer = Container.GetByKey(techspecContainerId); ContainerDependency dependency = new ContainerDependency(fContainer, tContainer); if (dependency.Save()) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "close", "<script>UpdateParent(" + featureContainerId + ");</script>"); } else { lbError.CssClass = "hc_error"; lbError.Text = ContainerDependency.LastError; lbError.Visible = true; } } }
private void Delete() { for (int i = 0; i < dg.Rows.Count; i++) { TemplatedColumn col = (TemplatedColumn)dg.Rows[i].Cells.FromKey("Select").Column; CheckBox cb = (CheckBox)((CellItem)col.CellItems[i]).FindControl("g_sd"); if (cb.Checked) { int techspecContainerId = -1; string sTechspecContainerId = dg.Rows[i].Cells.FromKey("Id").Value.ToString(); if (sTechspecContainerId.Length > 0) { techspecContainerId = Convert.ToInt32(sTechspecContainerId); } ContainerDependency dependency = ContainerDependency.GetByKey(featureContainerId, techspecContainerId); if (!dependency.Delete(HyperCatalog.Shared.SessionState.User.Id)) { lbError.CssClass = "hc_error"; lbError.Text = ContainerDependency.LastError; lbError.Visible = true; break; } } } UpdateDataView(); }
void UpdateDataView() { string filter = string.Empty; filter += " FeatureContainerId=" + featureContainerId; // filter if (txtFilter.Text.Length > 0) { string cleanFilter = txtFilter.Text.Replace("'", "''").ToLower(); cleanFilter = cleanFilter.Replace("[", "[[]"); cleanFilter = cleanFilter.Replace("_", "[_]"); cleanFilter = cleanFilter.Replace("%", "[%]"); filter += " AND (LOWER(TC.Tag) like '%" + cleanFilter + "%'"; filter += " OR LOWER(TC.ContainerName) like '%" + cleanFilter + "%'"; filter += " OR LOWER(TC.Definition) like '%" + cleanFilter + "%')"; } // Get all container dependencies using (ContainerDependencyList dependencies = ContainerDependency.GetAll(filter)) { if (dependencies != null) { if (dependencies.Count > 0) { dg.DataSource = dependencies; Utils.InitGridSort(ref dg); dg.DataBind(); UITools.RefreshTab(this.Page, "ContainerDependencies", dg.Rows.Count); if (SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_DICTIONARY)) { UITools.ShowToolBarSeparator(uwToolbar, "DeleteSep"); UITools.ShowToolBarButton(uwToolbar, "Delete"); uwToolbar.Items.FromKeyButton("Delete").DefaultStyle.Width = Unit.Pixel(120); } dg.Visible = true; lbNoresults.Visible = false; } else { if (txtFilter.Text.Length > 0) { lbNoresults.Text = "No record match your search (" + txtFilter.Text + ")"; } dg.Visible = false; lbNoresults.Visible = true; } // refresh tab count UITools.RefreshTab(Page, "ContainerDependencies", dependencies.Count); } } }
private void CheckDependency() { InputForm inputForm = InputForm.GetByKey(InputFormId); if (inputForm != null) { if (refContainer.ContainerTypeCode == 'F') // feature container { // Retrieve all container dependencies for this feature container string filter = " FeatureContainerId=" + refContainer.Id; using (ContainerDependencyList dependencies = ContainerDependency.GetAll(filter)) { if ((dependencies != null) && (dependencies.Count > 0)) { // Create list of tech spec containers (in container dependencies) string techSpecsList = string.Empty; foreach (HyperCatalog.Business.ContainerDependency d in dependencies) { // Current tech spec container HyperCatalog.Business.Container techSpecContainer = d.TechspecContainer; // tech spec container is or not attached to this input form int i = 0; using (InputFormContainerList ifcList = InputFormContainer.GetAll("InputFormId=" + InputFormId + " AND ContainerId=" + techSpecContainer.Id)) { if ((ifcList == null) || (ifcList.Count == 0)) { i++; if (techSpecsList.Length > 0) { techSpecsList += "\\n"; } techSpecsList += " " + i.ToString() + " - " + techSpecContainer.Name + " [" + techSpecContainer.Tag + "]"; } } } // Tech specs (in container dependencies) are not attached to this input form if (techSpecsList.Length > 0) { string msg = "REMINDER - are the following tech spec containers in your tech specs input forms?\\n"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "warning", "<script>alert('" + msg + techSpecsList + "');</script>"); } } } } } }