예제 #1
0
        private TabPage AddTab(ConfigurationTabDto item)
        {
            TabPage tbp = new TabPage();

            tbp.Name = item.Name;
            tbp.Text = item.Title;
            tabControl.TabPages.Add(tbp);
            return(tbp);
        }
예제 #2
0
        private void AddButtonSave(ConfigurationTabDto item, Control control, TabPage tab)
        {
            Button btn = new Button
            {
                Parent = control,
                Name   = $"btn_salvar_{item.Id}",
                Text   = "Salvar",
                Dock   = DockStyle.Right
            };

            btn.Click += (object sender, EventArgs e) =>
            {
                Salvar(item, tab);
            };
        }
예제 #3
0
        private void Salvar(ConfigurationTabDto item, Control tab)
        {
            var configValues     = new List <ConfigurationValueDto>();
            var configurationDto = _configurationService.GetConfigurationByIdDto(item.Id);

            foreach (var col in configurationDto.ConfigurationColumn)
            {
                var value = new ConfigurationValueDto();
                switch (col.Component)
                {
                case ComponentAllowed.TextBox:
                    var text = tab.Controls.Find($"{col.Name}_{col.Id}", true).FirstOrDefault() as TextBox;
                    value = new ConfigurationValueDto()
                    {
                        ConfigurationColumnId = col.Id,
                        Value = text.Text,
                        ConfigurationRowId = item.RowId
                    };
                    configValues.Add(value);
                    break;

                case ComponentAllowed.TextArea:
                    break;

                case ComponentAllowed.CheckBox:
                    var groupCheckBox = tab.Controls.Find($"grp_{col.Group}", true).FirstOrDefault() as GroupBox;
                    var valueCheckbox = string.Empty;
                    foreach (CheckBox checkBox in groupCheckBox.Controls)
                    {
                        if (checkBox.Checked)
                        {
                            valueCheckbox += $"{checkBox.Text}; ";
                        }
                    }

                    value = new ConfigurationValueDto()
                    {
                        ConfigurationColumnId = col.Id,
                        Value = valueCheckbox,
                        ConfigurationRowId = item.RowId
                    };
                    configValues.Add(value);
                    break;

                case ComponentAllowed.SearchModal:
                    var searchModal = tab.Controls.Find($"{col.Name}_{col.Id}", true).FirstOrDefault() as TextBox;
                    value = new ConfigurationValueDto()
                    {
                        ConfigurationColumnId = col.Id,
                        Value = searchModal.Text,
                        ConfigurationRowId = item.RowId
                    };
                    configValues.Add(value);
                    break;

                case ComponentAllowed.RadioButton:
                    var groupRadio = tab.Controls.Find($"grp_{col.Group}", true).FirstOrDefault() as GroupBox;
                    var valueRadio = string.Empty;
                    foreach (RadioButton radio in groupRadio.Controls)
                    {
                        if (radio.Checked)
                        {
                            valueRadio = radio.Text;
                        }
                    }

                    value = new ConfigurationValueDto()
                    {
                        ConfigurationColumnId = col.Id,
                        Value = valueRadio,
                        ConfigurationRowId = item.RowId
                    };
                    configValues.Add(value);
                    break;

                case ComponentAllowed.DropDownList:
                    var dropDown = tab.Controls.Find($"{col.Name}_{col.Id}", true).FirstOrDefault() as ComboBox;
                    value = new ConfigurationValueDto()
                    {
                        ConfigurationColumnId = col.Id,
                        Value = (dropDown.SelectedItem as ValueDto).Value,
                        ConfigurationRowId = item.RowId
                    };
                    configValues.Add(value);
                    break;

                default:
                    break;
                }
            }
            _configurationValueService.InsertRangeValuesDto(item.Id, item.RowId, configValues);

            configurationDto.ConfigurationRow = _configurationRowService.GetRowsByConfigurationDto(configurationDto.Id).ToList();

            tab.Controls.RemoveByKey("myNewGrid");
            DataGridViewFormService.GetComponent(configurationDto.ConfigurationColumn.ToList(), configurationDto.ConfigurationRow.ToList(), tab);
        }
예제 #4
0
        private void AddComponents(ConfigurationTabDto config, TabPage tab)
        {
            config.ConfigurationColumn
            .OrderByDescending(o => o.Index)
            .GroupBy(g => g.Group)
            .Select(s => new ComponentItemDto()
            {
                Group = s.Key,
                ConfigurationColumns = s.ToList(),
                SearchModal          = s.All(a => a.Component == ComponentAllowed.SearchModal)
            })
            .ToList()
            .ForEach(f =>
            {
                var control  = AddControl(tab, f);
                var pos_x    = 20;
                var position = 20;
                if (f.SearchModal)
                {
                    var source      = f.ConfigurationColumns.OrderBy(o => o.Index).FirstOrDefault(fi => !fi.ReadOnly);
                    var config_fill = _configurationColumnFillService.GetColumnsFillByColumnSource(source.Id).FirstOrDefault();
                    AddTextBox(control, f.ConfigurationColumns.FirstOrDefault(fi => fi.Id == config_fill?.ConfigurationColumnSourceId), ref position, ref pos_x);
                    position -= 40;
                    AddTextBox(control, f.ConfigurationColumns.FirstOrDefault(fi => fi.Id == config_fill.ConfigurationColumnDestinationId), ref position, ref pos_x);
                    position -= 40;
                    AddButtonSearch(control, f, config_fill, ref position, ref pos_x);
                }
                else
                {
                    f.ConfigurationColumns.ToList().ForEach(fo =>
                    {
                        switch (fo.Component)
                        {
                        case ComponentAllowed.TextBox:
                            AddTextBox(control, fo, ref position, ref pos_x);
                            pos_x = 20;
                            break;

                        case ComponentAllowed.RadioButton:
                            position = RadioButonFormService.GetComponent(fo, control, position);
                            break;

                        case ComponentAllowed.CheckBox:
                            position = CheckBoxFormService.GetComponent(fo, control, position);
                            break;

                        case ComponentAllowed.DropDownList:
                            position = AddComboBox(control, fo, position);
                            break;

                        default:
                            break;
                        }
                    });
                }

                control.ResumeLayout(false);
            });

            foreach (var item in config.ConfigurationRow)
            {
                if (item.ConfigurationValue == null)
                {
                    item.ConfigurationValue = new List <ConfigurationValueDto>();
                }

                item.ConfigurationValue.AddRange(_configurationValueService.GetValuesByRow(item.Id));
            }

            DataGridViewFormService.GetComponent(config.ConfigurationColumn.ToList(), config.ConfigurationRow.ToList(), tab);
        }
예제 #5
0
        private void SetComponents(ConfigurationTabDto item, TabPage tab)
        {
            var configurationDto = _configurationService.GetConfigurationByIdDto(item.Id);

            AddComponents(configurationDto, tab);
        }