private void button2_Click(object sender, EventArgs e) { if (textCollectionName.Text == "" || textCollectionName.Text == null) { MessageBox.Show("Collection name is required.", "Error Creating Collection"); return; } if (!Regex.IsMatch(textCollectionName.Text, @"^[\p{L}]+$")) { MessageBox.Show("Collection name can only have letters.", "Error Creating Collection"); return; } IEnumerable <CustomCollection> allCollections = dbc.getCollections(); String newCollectionName = dbc.RemoveTurkishCharacters(textCollectionName.Text); foreach (CustomCollection collection in allCollections) { if (collection.name == newCollectionName) { MessageBox.Show("Collection already exists.", "Error Creating Collection"); return; } } List <Attribute> attributes = new List <Attribute>(); if (listBox1.Items.Count == 0) { MessageBox.Show("At least one field is required.", "Error Creating Collection"); return; } foreach (Field f in listBox1.Items) { var attr = new Attribute { name = f.name, type = f.type, }; attributes.Add(attr); } var customCollection = new CustomCollection { name = dbc.RemoveTurkishCharacters(textCollectionName.Text), aliase = textCollectionName.Text, attributes = attributes, }; dbc.createCollection(newCollectionName, attributes); mainForm.updateCollectionList(); mainForm.updateItemList(customCollection); mainForm.setSelectedCollection(customCollection); this.Close(); }
public void updateCollectionList() { flowLayoutPanel1.Controls.Clear(); collectionList = dbc.getCollections(); foreach (CustomCollection collection in collectionList) { Button button = new Button(); button.Width = 170; button.Height = 35; button.Anchor = AnchorStyles.None; button.FlatStyle = FlatStyle.Flat; button.BackColor = Color.White; button.Font = new Font("Microsoft YaHei", 8.25f); button.Text = collection.aliase; button.Click += (s, e) => { updateItemList(collection); }; flowLayoutPanel1.Controls.Add(button); } }