protected void btnAddAnAttribute_onClick(object sender, EventArgs e) { string newAttName = txtNewAttributeName.Text; string result = ""; MetadataNewDa MNDa = new MetadataNewDa(); if (newAttName.Length > 0) { if (MNDa.AttributeExists(newAttName)) { result = "An attribute called '" + newAttName + "' already exists. The new attribute was not created."; btnCreateNewAttributeNext.Visible = false; } { try { MNDa.CreateNewAttribute(newAttName); result = "The new attribute '" + newAttName + "' was successfully created."; btnCreateNewAttributeNext.Visible = true; } catch (Exception err) { result = "An error occured while creating the new attribute '" + newAttName + "'. The attribute was not added."; btnCreateNewAttributeNext.Visible = false; } } } lblCreateNewAttributeResult.Text = result; lblCreateNewAttributeName.Text = newAttName; lblCreateNewAttributeId.Text = MNDa.GetAnAttribute(newAttName).Rows[0]["AttributeId"].ToString(); viewMode = "createNewAttributeStep2"; setViewMode(); }
protected void btnEditAnAttribute_onClick(object sender, EventArgs e) { MetadataNewDa MNDa = new MetadataNewDa(); viewMode = "EditAnAttribute"; setViewMode(); int attributeId = -1; Button btn = (Button)sender; switch (btn.Text) { case "Edit attribute": attributeId = int.Parse(ddlEditAnAttribute.SelectedValue); break; case "Next": attributeId = int.Parse(lblCreateNewAttributeId.Text); break; case "Save": attributeId = int.Parse(txtEditAnAttributeId.Text); string attributeName = txtEditAnAttributeName.Text; if (attributeName.Length > 0) { MNDa.UpdateAttributeName(attributeId, attributeName); } break; case "Cancel": attributeId = int.Parse(txtEditAnAttributeId.Text); break; } DataTable dtA = MNDa.GetAnAttribute(attributeId); txtEditAnAttributeId.Text = dtA.Rows[0]["AttributeId"].ToString(); txtEditAnAttributeName.Text = dtA.Rows[0]["AttributeName"].ToString(); loadAttributeValueOptionsForAnAttribute(attributeId); }