private void Delete() { ItemType itemType = ItemType.GetByKey(wneTypeId.ValueInt); if (itemType != null) { if (itemType.Delete(HyperCatalog.Shared.SessionState.User.Id)) { lbError.Visible = false; lbError.Text = string.Empty; panelEdit.Visible = false; panelGrid.Visible = true; UpdateDataView(); } else { lbError.CssClass = "hc_error"; lbError.Text = "Error: this item type is still used"; lbError.Visible = true; } } else { lbError.CssClass = "hc_error"; lbError.Text = "Error: a system error occurred"; lbError.Visible = true; } }
private void UpdateDataEdit(string selItemTypeId) { ItemType itemType = null; if (selItemTypeId.Length > 0) { itemType = ItemType.GetByKey(Convert.ToInt32(selItemTypeId)); } if (itemType == null) { lbTitle.Text = "Item type: New"; wneTypeId.Value = "-1"; lbItemTypeId.Visible = false; wneTypeId.Visible = false; UITools.HideToolBarButton(uwToolBarEdit, "Delete"); UITools.HideToolBarSeparator(uwToolBarEdit, "DeleteSep"); } else { lbTitle.Text = "Item type: " + itemType.Name; wneTypeId.Value = itemType.Id; txtTypeName.Text = itemType.Name; txtIcon.Text = itemType.Icon; lbItemTypeId.Visible = true; wneTypeId.Visible = true; wneTypeId.Enabled = false; } panelEdit.Visible = true; panelGrid.Visible = false; }
private void Save() { lbError.Text = string.Empty; int iTypeId = wneTypeId.ValueInt; ItemType itemType = ItemType.GetByKey(iTypeId); if (iTypeId == -1) { // create if (itemType == null) { itemType = new ItemType(iTypeId, txtTypeName.Text, txtIcon.Text); } else { lbError.CssClass = "hc_error"; lbError.Text = "Error: add/update failed - the properties can't be saved"; lbError.Visible = true; return; } } else { // update if (itemType != null) { itemType.Name = txtTypeName.Text; itemType.Icon = txtIcon.Text; } else { lbError.CssClass = "hc_error"; lbError.Text = "Error: add/update failed - the properties can't be saved"; lbError.Visible = true; return; } } if (itemType.Save()) { if (!wneTypeId.Visible) { // updated wneTypeId.Value = itemType.Id; wneTypeId.Text = itemType.Id.ToString(); wneTypeId.Visible = true; lbItemTypeId.Visible = true; wneTypeId.Enabled = false; if (HyperCatalog.Shared.SessionState.User.HasCapability(CapabilitiesEnum.EXTEND_CONTENT_MODEL)) { UITools.ShowToolBarButton(uwToolBarEdit, "Delete"); UITools.ShowToolBarSeparator(uwToolBarEdit, "DeleteSep"); } } // created lbError.Text = "Data saved!"; lbError.CssClass = "hc_success"; lbError.Visible = true; } else { lbError.CssClass = "hc_error"; lbError.Text = "Error: add/update failed - the properties can't be saved"; lbError.Visible = true; } }