private void AddPropMenuItem_Click(object sender, EventArgs e) { saveOrUpdate = true; newAtribute = new AttributeProperty(); propertyGrid1.SelectedObject = newAtribute; sqlObj.attributePropList.Add(newAtribute); ui.MakeTreeView(treeView1, sqlObj.attributePropList, "Attribute"); }
public void DeleteAttribute(AttributeProperty property) { SqlDataReader reader; SqlCommand save = new SqlCommand(); save.Connection = SQLConnection.con; save.Connection.Open(); save.CommandType = System.Data.CommandType.StoredProcedure; save.CommandText = "IMS_DELETE_ATTRIBUTE"; save.Parameters.AddWithValue("inGUID", property.m_GUID); reader = save.ExecuteReader(); reader.Close(); save.Connection.Close(); }
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button == MouseButtons.Right) { ContextMenu contextMenu = new ContextMenu(); MenuItem menuItemAdd = new MenuItem("Создать атрибут", new System.EventHandler(this.AddPropMenuItem_Click)); MenuItem menuItemDelete = new MenuItem("Удалить атрибут", new System.EventHandler(this.MenuItemDelete_Click)); contextMenu.MenuItems.Add(menuItemAdd); contextMenu.MenuItems.Add(menuItemDelete); contextMenu.Show(treeView1, e.Location); } else if (e.Button == MouseButtons.Left) { selectedAttribut = sqlObj.attributePropList.Where(x => x.NAME.Equals(e.Node.Text)).ToList().FirstOrDefault(); propertyGrid1.SelectedObject = selectedAttribut; index = sqlObj.attributePropList.IndexOf(selectedAttribut); } }
public void SaveAttribute(AttributeProperty property) { SqlDataReader reader; SqlCommand save = new SqlCommand(); save.Connection = SQLConnection.con; save.Connection.Open(); save.CommandType = System.Data.CommandType.StoredProcedure; save.CommandText = "IMS_ADD_ATTRIBUTE"; save.Parameters.AddWithValue("inNAME", property.m_NAME); save.Parameters.AddWithValue("inSHORT_NAME", property.m_SHORT_NAME ?? DBNull.Value.ToString()); save.Parameters.AddWithValue("inALIAS", property.m_ALIAS ?? DBNull.Value.ToString()); save.Parameters.AddWithValue("inGUID", property.m_GUID); int mulID = 0; switch (property.m_List) { case "Атрибут может содержать одно значение": mulID = 0; break; case "Атрибут может содержать множество значений": mulID = 1; break; case "Атрибут может содержать одно значение из списка разрешённых значений+": mulID = 2; break; case "Атрибут может содержать множество значений из списка": mulID = 3; break; } save.Parameters.AddWithValue("inNOTE", property.m_NOTE ?? DBNull.Value.ToString()); save.Parameters.AddWithValue("inMULTIPLE_VALUED", mulID); reader = save.ExecuteReader(); reader.Close(); save.Connection.Close(); }