Example #1
0
 private void InitializePatternMasterDataGrid(SfDataGrid dataGrid)
 {
     _categoryColumn = new GridComboBoxColumn()
     {
         HeaderText  = "구분",
         MappingName = nameof(Pattern.Category),
     };
     dataGrid.Columns.Add(_categoryColumn);
     dataGrid.Columns.Add(new GridTextColumn()
     {
         HeaderText = "패턴명", MappingName = nameof(Pattern.Name)
     });
     dataGrid.AutoGenerateColumns = false;
     dataGrid.SelectionChanged   += OnPatternMasterDataGridSelectionChanged;
 }
Example #2
0
        private void Startup(PrefabManager prefabManager)
        {
            ItemNameField.Text = _prefabName;

            FillPrefabDataTable();
            List <DataRow> origRows = new List <DataRow>();

            foreach (DataRow row in _prefabTable.Rows)
            {
                origRows.Add(row);
            }

            _prefabTable.RowChanged += (sender, args) =>
            {
                SaveButton.IsEnabled = !string.IsNullOrEmpty(ItemNameField.Text);
                if (args.Action == DataRowAction.Add)
                {
                    args.Row[1] = "TextField";
                    _prefabTable.AcceptChanges();
                }
                else
                {
                    switch (args.Action)
                    {
                    case DataRowAction.Change when !origRows.Contains(args.Row):
                        return;

                    case DataRowAction.Change:
                        int      index = origRows.IndexOf(args.Row);
                        string[] keys  = _changedColumnNames.Keys.ToArray();

                        _changedColumnNames[keys[index]] = args.Row[0].ToString();
                        _prefabTable.AcceptChanges();
                        break;
                    }
                }

                RowPositionTextBox.MaxValue = _prefabTable.Rows.Count;
            };
            _prefabTable.RowDeleting += (sender, args) =>
            {
                if (origRows.Contains(args.Row))
                {
                    _deletedColumns.Add(args.Row[0].ToString());
                }
            };
            _prefabTable.RowDeleted += (sender, args) =>
            {
                SaveButton.IsEnabled = !string.IsNullOrEmpty(ItemNameField.Text);
                _prefabTable.AcceptChanges();
                RowPositionTextBox.MaxValue = _prefabTable.Rows.Count;
            };
            RowPositionTextBox.MaxValue = _prefabTable.Rows.Count;

            PrefabGrid.ItemsSource = _prefabTable;
            var j = 0;

            PrefabGrid.Loaded += (sender, args) =>
            {
                var comboStrings = new HashSet <string>
                {
                    "TextField",
                    "AutoComplete",
                    "CheckBox",
                    "ComboBox",
                    "DatePicker",
                    "Numeric",
                    "Currency",
                    "Hyperlink",
                    "Percentage"
                };
                if (j == 0)
                {
                    for (var i = 0; i < _prefabTable.Columns.Count; i++)
                    {
                        GridColumn column;
                        if (i == 1)
                        {
                            column = new GridComboBoxColumn
                            {
                                MappingName     = _prefabTable.Columns[i].ColumnName,
                                ItemsSource     = comboStrings,
                                StaysOpenOnEdit = true,
                                IsEditable      = false,
                                HeaderText      = _prefabTable.Columns[i].ColumnName
                            };

                            PrefabGrid.Columns.Add(column);
                        }
                        else if (i > 1)
                        {
                            column = new GridNumericColumn
                            {
                                MappingName          = _prefabTable.Columns[i].ColumnName,
                                HeaderText           = _prefabTable.Columns[i].ColumnName,
                                NumberDecimalDigits  = 0,
                                NumberGroupSeparator = ","
                            };

                            PrefabGrid.Columns.Add(column);
                        }
                        else
                        {
                            column = new GridTextColumn
                            {
                                MappingName = _prefabTable.Columns[i].ColumnName,
                                HeaderText  = _prefabTable.Columns[i].ColumnName
                            };

                            PrefabGrid.Columns.Add(column);
                        }
                    }
                }

                j++;
            };
            _prefabManager = prefabManager;

            _changedColumnNames = new Dictionary <string, string>();
            foreach (DataRow dr in _prefabTable.Rows)
            {
                _changedColumnNames.Add(dr[0].ToString(), dr[0].ToString());
            }
            _deletedColumns = new List <string>();
        }
Example #3
0
        private void InitializeDataGrid(SfDataGrid masterDataGrid, SfDataGrid detailDataGrid)
        {
            Appearances.DataGrid(masterDataGrid);
            Appearances.DataGrid(detailDataGrid);

            var numberFormat = new NumberFormatInfo();

            numberFormat.NumberDecimalDigits = 0;
            numberFormat.NumberGroupSizes    = new int[] { 3 };

            var numberFormat2 = new NumberFormatInfo();

            numberFormat2.NumberDecimalDigits = 2;
            numberFormat2.NumberGroupSizes    = new int[] { 3 };

            masterDataGrid.Columns.Add(new GridTextColumn()
            {
                HeaderText = "진단구역명", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.Zone)
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "최소수압(kgf/cm²)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.MinPressure), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "최대수압(kgf/cm²)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.MaxPressure), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "평균수압(kgf/cm²)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.AvgPressure), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "범위", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.StDevPressure), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.AutoGenerateColumns = false;

            _pipeTypeComboBoxColumn = new GridComboBoxColumn()
            {
                HeaderText = "관종", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(Pipe.PP_TYPE)
            };
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "관로ID", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(Pipe.ID), NumberFormatInfo = numberFormat
            });
            detailDataGrid.Columns.Add(new GridTextColumn()
            {
                HeaderText = "관리번호", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(Pipe.MGR_ID)
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "최소수압(kgf/cm²)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(Pipe.PRESSURE_MIN), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "최대수압(kgf/cm²)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(Pipe.PRESSURE_MAX), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "평균수압(kgf/cm²)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(Pipe.PRESSURE_AVG), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(_pipeTypeComboBoxColumn);
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "관경(mm)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(Pipe.PP_CIR), NumberFormatInfo = numberFormat
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "관로길이(m)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(Pipe.PP_LEN), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "매설년수", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(Pipe.NYEAR), NumberFormatInfo = numberFormat
            });
            detailDataGrid.AutoGenerateColumns = false;

            var detailsView = new GridViewDefinition();

            detailsView.RelationalColumn = nameof(PipeGroup.Pipes);
            detailsView.DataGrid         = detailDataGrid;

            masterDataGrid.DetailsViewDefinitions.Add(detailsView);
            //dataGrid.SelectionChanged   += OnPatternMasterDataGridSelectionChanged;
        }
        public static void GenerateColumnsSfDataGrid(SfDataGrid dataGrid, DataTable table, string prefab)
        {
            using (var conn = new SqlConnection(App.ConnectionString))
            {
                conn.Open();
                if (!string.IsNullOrEmpty(prefab))
                {
                    DataTable prefabTable = App.GetPrefabDataTable(conn, $"{Settings.Default.Schema}_PREFABS", prefab);
                    DataTable comboTable  =
                        App.GetPrefabDataTable(conn, $"{Settings.Default.Schema}_COMBOBOXES", prefab);

                    //could loop by table.ColumnNames.Count; but if prebab is changed... problems; maybe not all columns showing
                    for (var i = 0; i < table.Columns.Count; i++)
                    {
                        GridColumn column;

                        try
                        {
                            if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("autocomplete"))
                            {
                                column = new GridTemplateColumn
                                {
                                    MappingName = table.Columns[i].ColumnName,
                                    HeaderText  = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                var comboStrings = new HashSet <string>();
                                for (var j = 0; j < comboTable.Rows.Count; j++)
                                {
                                    if (!string.IsNullOrEmpty(
                                            comboTable.Rows[j][prefabTable.Rows[i]["COLUMNS"].ToString()].ToString()))
                                    {
                                        comboStrings.Add(comboTable.Rows[j][prefabTable.Rows[i]["COLUMNS"].ToString()]
                                                         .ToString());
                                    }
                                }

                                var autoCompleteElem = new FrameworkElementFactory(typeof(AutoComplete));

                                var autoCompleteItemsBind = new Binding
                                {
                                    Source = comboStrings,
                                    UpdateSourceTrigger   = UpdateSourceTrigger.PropertyChanged,
                                    BindsDirectlyToSource = true
                                };

                                var autoCompleteBind =
                                    new Binding(table.Columns[i].ColumnName)
                                {
                                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                                    Mode = BindingMode.TwoWay,
                                    BindsDirectlyToSource = true
                                };

                                autoCompleteElem.SetValue(UIElement.FocusableProperty, true);
                                autoCompleteElem.SetValue(AutoComplete.IsDropDownOpenProperty, true);
                                autoCompleteElem.SetValue(ItemsControl.IsTextSearchEnabledProperty, true);
                                autoCompleteElem.SetValue(AutoComplete.IsAutoAppendProperty, true);
                                autoCompleteElem.SetValue(ItemsControl.IsTextSearchCaseSensitiveProperty, false);
                                autoCompleteElem.SetValue(AutoComplete.CustomSourceProperty, autoCompleteItemsBind);
                                autoCompleteElem.SetValue(AutoComplete.TextProperty, autoCompleteBind);
                                autoCompleteElem.SetValue(AutoComplete.CanResizePopupProperty, false);
                                //autoCompleteElem.SetValue(AutoComplete.IsFilterProperty, true);
                                autoCompleteElem.SetValue(AutoComplete.EnableSortingProperty, false);

                                var cellEditingTemplate =
                                    new DataTemplate(typeof(AutoComplete))
                                {
                                    VisualTree = autoCompleteElem
                                };
                                ((GridTemplateColumn)column).EditTemplate = cellEditingTemplate;

                                var defaultElement = new FrameworkElementFactory(typeof(TextBlock));

                                var bind = new Binding(table.Columns[i].ColumnName)
                                {
                                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                                    Mode = BindingMode.TwoWay,
                                    BindsDirectlyToSource = true
                                };

                                defaultElement.SetValue(TextBlock.TextProperty, bind);
                                defaultElement.SetValue(FrameworkElement.VerticalAlignmentProperty,
                                                        VerticalAlignment.Center);

                                var defaultTemplate = new DataTemplate(typeof(TextBlock))
                                {
                                    VisualTree = defaultElement
                                };
                                ((GridTemplateColumn)column).CellTemplate = defaultTemplate;

                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("datepicker"))
                            {
                                column = new GridDateTimeColumn
                                {
                                    MappingName            = table.Columns[i].ColumnName,
                                    Pattern                = DateTimePattern.ShortDate,
                                    CanEdit                = true,
                                    AllowNullValue         = true,
                                    NullText               = string.Empty,
                                    AllowScrollingOnCircle = true,
                                    EnableBackspaceKey     = true,
                                    EnableDeleteKey        = true,
                                    ShowRepeatButton       = true,
                                    HeaderText             = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("checkbox"))
                            {
                                column = new GridCheckBoxColumn
                                {
                                    MappingName  = table.Columns[i].ColumnName,
                                    IsThreeState = false,
                                    HeaderText   = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("numeric"))
                            {
                                column = new GridNumericColumn
                                {
                                    MappingName          = table.Columns[i].ColumnName,
                                    HeaderText           = prefabTable.Rows[i]["COLUMNS"].ToString(),
                                    NumberDecimalDigits  = 3,
                                    NumberGroupSeparator = ","
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("currency"))
                            {
                                column = new GridCurrencyColumn
                                {
                                    MappingName = table.Columns[i].ColumnName,
                                    HeaderText  = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("hyperlink"))
                            {
                                column = new GridHyperlinkColumn
                                {
                                    MappingName = table.Columns[i].ColumnName,
                                    HeaderText  = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("percentage"))
                            {
                                column = new GridPercentColumn
                                {
                                    MappingName = table.Columns[i].ColumnName,
                                    HeaderText  = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("combobox"))
                            {
                                var comboStrings = new HashSet <string>();
                                for (var j = 0; j < comboTable.Rows.Count; j++)
                                {
                                    if (!string.IsNullOrEmpty(
                                            comboTable.Rows[j][prefabTable.Rows[i]["COLUMNS"].ToString()].ToString()))
                                    {
                                        comboStrings.Add(comboTable.Rows[j][prefabTable.Rows[i]["COLUMNS"].ToString()]
                                                         .ToString());
                                    }
                                }

                                column = new GridComboBoxColumn
                                {
                                    MappingName     = table.Columns[i].ColumnName,
                                    ItemsSource     = comboStrings,
                                    StaysOpenOnEdit = true,
                                    IsEditable      = true,
                                    HeaderText      = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else
                            {
                                column = new GridTextColumn
                                {
                                    MappingName = table.Columns[i].ColumnName,
                                    HeaderText  = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }
                        }
                        catch
                        {
                            column = new GridTextColumn
                            {
                                MappingName = table.Columns[i].ColumnName,
                                HeaderText  = table.Columns[i].ColumnName
                            };

                            dataGrid.Columns.Add(column);
                        }
                    }
                }
                else
                {
                    foreach (DataColumn column in table.Columns)
                    {
                        GridColumn gridColumn = new GridTextColumn
                        {
                            MappingName = column.ColumnName,
                            HeaderText  = column.ColumnName
                        };

                        dataGrid.Columns.Add(gridColumn);
                    }
                }

                conn.Close();
            }
        }
Example #5
0
        public static void GenerateColumnsSfDataGrid(SfDataGrid dataGrid, DataTable table, string prefab)
        {
            using (var conn = new SqlConnection(App.ConnectionString))
            {
                conn.Open();
                if (!string.IsNullOrEmpty(prefab))
                {
                    DataTable prefabTable = App.GetPrefabDataTable(conn, $"{App.Settings["Schema"]}_PREFABS", prefab);
                    DataTable comboTable  =
                        App.GetPrefabDataTable(conn, $"{App.Settings["Schema"]}_COMBOBOXES", prefab);

                    //could loop by table.ColumnNames.Count; but if prebab is changed... problems; maybe not all columns showing
                    for (var i = 0; i < table.Columns.Count; i++)
                    {
                        GridColumn column;

                        try
                        {
                            if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("autocomplete"))
                            {
                                var comboStrings = new HashSet <string>();
                                for (var j = 0; j < comboTable.Rows.Count; j++)
                                {
                                    if (!string.IsNullOrEmpty(
                                            comboTable.Rows[j][prefabTable.Rows[i]["COLUMNS"].ToString()].ToString()))
                                    {
                                        comboStrings.Add(comboTable.Rows[j][prefabTable.Rows[i]["COLUMNS"].ToString()]
                                                         .ToString());
                                    }
                                }

                                StringBuilder sb1 = new StringBuilder();
                                sb1.AppendLine(
                                    "<DataTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">");
                                sb1.AppendLine("<ComboBox PlaceholderText=\"{Binding " + prefabTable.Rows[i]["COLUMNS"] +
                                               ", Mode=TwoWay}\" IsEditable=\"True\" IsTextSearchEnabled=\"True\" IsDropDownOpen=\"True\" >");
                                foreach (var comboString in comboStrings)
                                {
                                    sb1.AppendLine($"<x:String>{comboString}</x:String>");
                                }
                                sb1.AppendLine("</ComboBox>");
                                sb1.AppendLine("</DataTemplate>");
                                DataTemplate cellTemplate = (DataTemplate)XamlReader.Load(sb1.ToString());
                                column = new GridTemplateColumn
                                {
                                    MappingName  = table.Columns[i].ColumnName,
                                    HeaderText   = prefabTable.Rows[i]["COLUMNS"].ToString(),
                                    EditTemplate = cellTemplate
                                };
                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("datepicker"))
                            {
                                column = new GridDateTimeColumn
                                {
                                    MappingName        = table.Columns[i].ColumnName,
                                    FormatString       = "MM/dd/yyyy",
                                    AllowInlineEditing = true,
                                    AllowNullValue     = true,
                                    HeaderText         = prefabTable.Rows[i]["COLUMNS"].ToString(),
                                    WaterMark          = string.Empty
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("checkbox"))
                            {
                                column = new GridCheckBoxColumn
                                {
                                    MappingName  = table.Columns[i].ColumnName,
                                    IsThreeState = false,
                                    HeaderText   = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("numeric"))
                            {
                                column = new GridNumericColumn
                                {
                                    MappingName = table.Columns[i].ColumnName,
                                    HeaderText  = prefabTable.Rows[i]["COLUMNS"].ToString(),
                                    MaximumNumberDecimalDigits = 3
                                };

                                dataGrid.Columns.Add(column);
                            }                            /*
                                                          * else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("currency"))
                                                          * {
                                                          *     column = new GridCurrencyColumn
                                                          *     {
                                                          *             MappingName = table.Columns[i].ColumnName,
                                                          *             HeaderText = prefabTable.Rows[i]["COLUMNS"].ToString()
                                                          *     };
                                                          *
                                                          *     dataGrid.Columns.Add(column);
                                                          * }*/
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("hyperlink"))
                            {
                                column = new GridHyperlinkColumn
                                {
                                    MappingName = table.Columns[i].ColumnName,
                                    HeaderText  = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }                            /*
                                                          * else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("percentage"))
                                                          * {
                                                          *     column = new GridPercentColumn
                                                          *     {
                                                          *             MappingName = table.Columns[i].ColumnName,
                                                          *             HeaderText = prefabTable.Rows[i]["COLUMNS"].ToString()
                                                          *     };
                                                          *
                                                          *     dataGrid.Columns.Add(column);
                                                          * }*/
                            else if (prefabTable.Rows[i]["TYPES"].ToString().ToLower().Equals("combobox"))
                            {
                                var comboStrings = new HashSet <string>();
                                for (var j = 0; j < comboTable.Rows.Count; j++)
                                {
                                    if (!string.IsNullOrEmpty(
                                            comboTable.Rows[j][prefabTable.Rows[i]["COLUMNS"].ToString()].ToString()))
                                    {
                                        comboStrings.Add(comboTable.Rows[j][prefabTable.Rows[i]["COLUMNS"].ToString()]
                                                         .ToString());
                                    }
                                }

                                column = new GridComboBoxColumn
                                {
                                    MappingName = table.Columns[i].ColumnName,
                                    ItemsSource = comboStrings,
                                    HeaderText  = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }
                            else
                            {
                                column = new GridTextColumn
                                {
                                    MappingName = table.Columns[i].ColumnName,
                                    HeaderText  = prefabTable.Rows[i]["COLUMNS"].ToString()
                                };

                                dataGrid.Columns.Add(column);
                            }                             //TODO: More? CalendarDatePicker, TimePicker, DatePicker, Slider, ToggleSwitch, RichEditBox, PasswordBox, ColorPicker, ComboBox, RatingControl
                        }
                        catch
                        {
                            column = new GridTextColumn
                            {
                                MappingName = table.Columns[i].ColumnName,
                                HeaderText  = table.Columns[i].ColumnName
                            };

                            dataGrid.Columns.Add(column);
                        }
                    }
                }
                else
                {
                    foreach (DataColumn column in table.Columns)
                    {
                        GridColumn gridColumn = new GridTextColumn
                        {
                            MappingName = column.ColumnName,
                            HeaderText  = column.ColumnName
                        };

                        dataGrid.Columns.Add(gridColumn);
                    }
                }

                conn.Close();
            }
        }
Example #6
0
        private void InitializeDataGrid(SfDataGrid masterDataGrid, SfDataGrid detailDataGrid)
        {
            Appearances.DataGrid(masterDataGrid);
            Appearances.DataGrid(detailDataGrid);

            var numberFormat = new NumberFormatInfo();

            numberFormat.NumberDecimalDigits = 0;
            numberFormat.NumberGroupSizes    = new int[] { 3 };

            var numberFormat2 = new NumberFormatInfo();

            numberFormat2.NumberDecimalDigits = 2;
            numberFormat2.NumberGroupSizes    = new int[] { 3 };

            masterDataGrid.AutoGenerateColumns = false;
            masterDataGrid.Columns.Add(new GridTextColumn()
            {
                HeaderText = "진단구역", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.Zone)
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "평균표고(m)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.InputAvgPressure), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "평균수압(m)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.AvgPressure), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "유입유량(m³/일)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.InFlow), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "사용량(m³/일)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.Usage), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "무수수량(m³/일)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.AnhydrouAmount), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "배수관", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.Col6), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "급수시설", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.Col7), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "옥내", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.Col8), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "배경누수량(m³/일)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.Col9), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "파열누수량(m³/일)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.RuptureLeakage), NumberFormatInfo = numberFormat2
            });
            masterDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "누수량(m³/일)", AutoSizeColumnsMode = AutoSizeColumnsMode.ColumnHeader, MappingName = nameof(PipeGroup.Leakage), NumberFormatInfo = numberFormat2
            });

            var stackedHeaderRow = new StackedHeaderRow();

            stackedHeaderRow.StackedColumns.Add(new StackedColumn()
            {
                HeaderText   = "배경누수량(m³/일)",
                ChildColumns = $"{nameof(PipeGroup.Col6)},{nameof(PipeGroup.Col7)},{nameof(PipeGroup.Col8)}",
            });
            masterDataGrid.StackedHeaderRows.Add(stackedHeaderRow);

            detailDataGrid.AutoGenerateColumns = false;
            _pipeTypeComboBoxColumn            = new GridComboBoxColumn()
            {
                HeaderText = "관재질", MappingName = nameof(Pipe.PP_TYPE)
            };
            detailDataGrid.Columns.Add(new GridTextColumn()
            {
                HeaderText = "관로ID", MappingName = nameof(Pipe.ID)
            });
            detailDataGrid.Columns.Add(new GridTextColumn()
            {
                HeaderText = "관리번호", MappingName = nameof(Pipe.MGR_ID)
            });
            detailDataGrid.Columns.Add(_pipeTypeComboBoxColumn);
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "관경", MappingName = nameof(Pipe.PP_CIR), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "관로길이", MappingName = nameof(Pipe.PP_LEN), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "매설년수", MappingName = nameof(Pipe.NYEAR), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "급수관연장", MappingName = nameof(Pipe.Col1), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "급수전수", MappingName = nameof(Pipe.Col2), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "배경누수량", MappingName = nameof(Pipe.LEAK_BASE), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "파열누수량", MappingName = nameof(Pipe.LEAK_BREAK), NumberFormatInfo = numberFormat2
            });
            detailDataGrid.Columns.Add(new GridNumericColumn()
            {
                HeaderText = "누수량", MappingName = nameof(Pipe.LEAK_SUM), NumberFormatInfo = numberFormat2
            });


            var detailsView = new GridViewDefinition();

            detailsView.RelationalColumn = nameof(PipeGroup.Pipes);
            detailsView.DataGrid         = detailDataGrid;

            masterDataGrid.DetailsViewDefinitions.Add(detailsView);
            //dataGrid.SelectionChanged   += OnPatternMasterDataGridSelectionChanged;
        }