Exemplo n.º 1
0
        public CosmeticFieldM(AbsM.ITableBaseM table,
                              string name, string text, AbsM.EFieldType type, bool isReadOnly = false)
        {
            var cosmTable = table as CosmeticTableBaseM;

            if (cosmTable == null)
            {
                throw new ArgumentNullException("Нет ссылки на таблицу");
            }
            _id         = CosmeticFieldM.cosmeticFieldId++;
            _table      = cosmTable;
            _idTable    = _table.Id;
            _name       = name;
            _text       = text;
            _type       = type;
            _isReadOnly = isReadOnly;
        }
Exemplo n.º 2
0
        //TODO: Сделать вывод связанной таблицы

        #region Статические методы
        public static DbType GetDbType(AbsM.EFieldType type)
        {
            switch (type)
            {
            case AbsM.EFieldType.Integer:
                return(System.Data.DbType.Int32);

            case AbsM.EFieldType.Text:
                return(System.Data.DbType.String);

            case AbsM.EFieldType.Date:
                return(System.Data.DbType.DateTime);

            case AbsM.EFieldType.DateTime:
                return(System.Data.DbType.DateTime);

            case AbsM.EFieldType.Real:
                return(System.Data.DbType.Double);

            default:
                return(System.Data.DbType.String);
            }
        }
Exemplo n.º 3
0
        public void Create(object parameter = null)
        {
            if (CanCreate)
            {
                cti.ThreadProgress.ShowWait(_progressKey);
                try
                {
                    CanLoad    = false;
                    _tableInfo = CreateTable();

                    if (_tableInfo != null)
                    {
                        DataGrid importGrid = parameter as DataGrid;
                        var      headers    = FindChild <StackPanel>(importGrid, "HeaderStackPanel");

                        List <FieldMatch> fields = new List <FieldMatch>();
                        for (int i = 0; i < headers.Count - 1; i++)
                        {
                            bool loadField = (bool)FindChild <CheckBox>(importGrid, "LoadField")[i + 1].IsChecked;
                            if (!loadField)
                            {
                                continue;
                            }
                            string          nameDB      = FindChild <TextBox>(importGrid, "headerDBName")[i + 1].Text;
                            string          nameSystem  = FindChild <TextBox>(importGrid, "headerSystemName")[i + 1].Text;
                            string          name        = (string)importGrid.Columns[i].Header;
                            var             type_item   = FindChild <ComboBox>(importGrid, "headerFieldTypeCb")[i + 1].SelectedValue;
                            EnumWrapper     enumWrapper = type_item as EnumWrapper;
                            AbsM.EFieldType eFieldType  = (AbsM.EFieldType)enumWrapper.Value;

                            if (loadField)
                            {
                                var field = CreateField(nameDB, nameSystem, (int)eFieldType, name, _tableInfo);
                                if (field != null)
                                {
                                    fields.Add(field);
                                }
                            }
                        }

                        var cls = new classesOfMetods();
                        Program.field_info = cls.loadFieldInfo();

                        _importer.SetTableInfo(_tableInfo);
                        if (_importer is SHPImporter)
                        {
                            (_importer as SHPImporter).Load(fields, _tableType == AbsM.ETableType.MapLayer);
                        }
                        else
                        {
                            _importer.Load(fields);
                        }
                        if (Program.sscUser != null)
                        {
                            DBTablesEdit.SyncController.RegisterTable(_tableInfo.idTable, Group.name);
                        }
                    }
                    else
                    {
                        cti.ThreadProgress.Close(_progressKey);
                        CanLoad = true;
                    }
                }
                catch (Exception ex)
                {
                    cti.ThreadProgress.Close(_progressKey);
                    CanLoad = true;
                    MessageBox.Show(ex.Message, Resources.AET_CreatingTable, MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }