public string GetDefaultDataType() { if (LogicalName.Contains("firstname")) { return(DataTypeHelper.FirstName); } if (LogicalName.Contains("lastname")) { return(DataTypeHelper.LastName); } if (LogicalName.Contains("fullname")) { return(DataTypeHelper.Name); } if (LogicalName == "customerid") { return(DataTypeHelper.Customer); } if (LogicalName.Contains("birthday")) { return(DataTypeHelper.DatePast); } if (LogicalName.Contains("country")) { return(DataTypeHelper.Country); } if (LogicalName.Contains("city")) { return(DataTypeHelper.City); } if (LogicalName.Contains("street") || LogicalName.Contains("_line1")) { return(DataTypeHelper.Street); } if (LogicalName.Contains("email")) { return(DataTypeHelper.Email); } if (LogicalName.Contains("phone") || LogicalName.Contains("mobile")) { return(DataTypeHelper.PhoneNumber); } if (EntityName == "account" && LogicalName == "name") { return(DataTypeHelper.CompanyNames); } return(DataTypeHelper.GetValidTypes(TypeCode)[0]); }
private void DoStuffWhenSelectingAField(object sender, ItemCheckEventArgs e) { if (!(listbox.Items[e.Index] is Attribute selectedAttribute)) { return; } if (e.CurrentValue == CheckState.Checked) { _selectedAttributes.Remove(selectedAttribute); for (var i = panel2.Controls.Count - 1; i >= 0; i--) { if (panel2.Controls[i].Name.Contains(selectedAttribute.LogicalName)) { panel2.Controls.RemoveAt(i); } } if (panel2.Controls.Count == 1) { panel3.Visible = false; lblDataType.Visible = false; } return; } lblDataType.Visible = true; _selectedAttributes.Add(selectedAttribute); List <string> validTypes; try { validTypes = DataTypeHelper.GetValidTypes(selectedAttribute.TypeCode); } catch (NotImplementedException exception) { e.NewValue = e.CurrentValue; MessageBox.Show(exception.Message); return; } var l = new Label { Font = _defaultFont, Margin = new Padding(10, 3, 3, 0), Text = selectedAttribute.DisplayName, Dock = DockStyle.Top, Name = $"lbl{selectedAttribute.LogicalName}", Anchor = AnchorStyles.Top, Width = panel2.Width }; var c = new ComboBox { Dock = DockStyle.Top, Margin = new Padding(10, 3, 3, 20), Font = _defaultFont, Name = $"{selectedAttribute.LogicalName}", Anchor = AnchorStyles.Top, Width = Convert.ToInt32(panel2.Width * 0.8), DropDownStyle = ComboBoxStyle.DropDownList }; c.SelectedValueChanged += (o, args) => { selectedAttribute.SetTypeOfData(c.Text); }; foreach (var validType in validTypes) { c.Items.Add(validType); } c.SelectedItem = selectedAttribute.GetDefaultDataType(); panel2.Controls.Add(l); panel2.Controls.Add(c); panel3.Visible = true; }