Beispiel #1
0
        protected override void OnEdit(object sender, EventArgs args)
        {
            EditModelFrm  frm           = new EditModelFrm();
            ColumnSetNode columnSetNode = (ColumnSetNode)this.Reslove(typeof(ColumnSetNode), this.ColumnSetName);

            frm.UpdateModel(this, columnSetNode);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                this.Children.Clear();

                //更新模型
                IList <EditModelFrm.FieldItem> items = frm.FieldItems;

                foreach (EditModelFrm.FieldItem item in items)
                {
                    FieldNode node = NodeFactory.CreateNode <FieldNode>();// new FieldNode();
                    node.Name        = item.Name;
                    node.ColumnName  = item.ColumnName;
                    node.Description = item.Description;
                    node.NullAble    = item.NullAble;
                    node.SystemType  = SchemaUtility.GetSystemType(DBGlobalService.DbType, item.SystemType);
                    node.Parent      = this;
                }
            }
            base.OnEdit(sender, args);
        }
Beispiel #2
0
 public PostgresColumnSchema(bool isPK, string name, string dataType, string nativeType, int size, byte precision, int scale, bool allowDBNull)
     : base(isPK, name, dataType, nativeType, size, precision, scale, allowDBNull)
 {
     this.SystemType = SchemaUtility.GetSystemType(DatabaseType.Postgres, _nativeType);
 }
Beispiel #3
0
        public void AddPropertiesForSelectedColumns()
        {
            if (frmGenerator.ColumnList.SelectedIndices.Count > 0)
            {
                StringCollection addedProps = new StringCollection();
                foreach (int index in frmGenerator.ColumnList.SelectedIndices)
                {
                    DictionaryEntry e = (DictionaryEntry)frmGenerator.ColumnList.Items[index];
                    // use name of column to see if a property of the same name exists
                    if (!PropertyExists((string)e.Value))
                    {
                        object prop = e.Key;
                        if (prop is ColumnSchema)
                        {
                            ValueProperty newProp = new ValueProperty();
                            newProp.DbBindColumn.TableSchema = ((ColumnSchema)prop).Table;
                            newProp.DbBindColumn.TableColumn = (ColumnSchema)prop;
                            newProp.Name         = ((ColumnSchema)prop).Name;
                            newProp.PropertyType = TypeHelper.GetTypeCodeEx(SchemaUtility.GetSystemType(((ColumnSchema)prop).DataType));
                            if (newProp.DbBindColumn.Identity || newProp.DbBindColumn.NativeType == "timestamp")
                            {
                                newProp.ReadOnly          = true;
                                newProp.MarkDirtyOnChange = false;
                                newProp.Undoable          = false;
                            }
                            if (((ColumnSchema)prop).IsUnique && newProp.PropertyType == TypeCodeEx.Guid)
                            {
                                newProp.DefaultValue = "Guid.NewGuid()";
                            }
                            _currentCslaObject.ValueProperties.Add(newProp);
                            addedProps.Add(newProp.Name);
                        }
                        else if (prop is ViewColumnSchema)
                        {
                            ValueProperty newProp = new ValueProperty();
                            newProp.DbBindColumn.ViewSchema = ((ViewColumnSchema)prop).View;
                            newProp.DbBindColumn.ViewColumn = (ViewColumnSchema)prop;
                            newProp.Name         = ((ViewColumnSchema)prop).Name;
                            newProp.PropertyType = TypeHelper.GetTypeCodeEx(SchemaUtility.GetSystemType(((ViewColumnSchema)prop).DataType));
                            if (newProp.DbBindColumn.NativeType == "timestamp")
                            {
                                newProp.ReadOnly          = true;
                                newProp.MarkDirtyOnChange = false;
                                newProp.Undoable          = false;
                            }
                            _currentCslaObject.ValueProperties.Add(newProp);
                            addedProps.Add(newProp.Name);
                        }
                        else if (prop is CommandResultColumnSchema)
                        {
                            ValueProperty newProp = new ValueProperty();
                            newProp.DbBindColumn.SpSchema      = ((CommandResultColumnSchema)prop).Command.CommandResults[GetCurrentResultSetIndex()];
                            newProp.DbBindColumn.SpColumn      = (CommandResultColumnSchema)prop;
                            newProp.DbBindColumn.SpResultIndex = GetCurrentResultSetIndex();
                            newProp.Name         = ((CommandResultColumnSchema)prop).Name;
                            newProp.PropertyType = TypeHelper.GetTypeCodeEx(SchemaUtility.GetSystemType(((CommandResultColumnSchema)prop).DataType));
                            if (newProp.DbBindColumn.NativeType == "timestamp")
                            {
                                newProp.ReadOnly          = true;
                                newProp.MarkDirtyOnChange = false;
                                newProp.Undoable          = false;
                            }
                            _currentCslaObject.ValueProperties.Add(newProp);
                            addedProps.Add(newProp.Name);
                        }
                        else
                        {
                            throw new InvalidOperationException("Unexpected column schema type.");
                        }
                    }
                }

                // Add Get-, New- and DeleteObjectCriteria and linked parameters
                AddCriteriaAndParameters();

                // Display message to the user
                if (addedProps.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("Successfully added the following properties:" + Environment.NewLine);
                    foreach (string propName in addedProps)
                    {
                        sb.Append("\t" + propName + Environment.NewLine);
                    }
                    MessageBox.Show(frmGenerator, sb.ToString(), "Properties Added Successfully");
                }
                else
                {
                    MessageBox.Show(frmGenerator, "All columns selected already have corresponding properties", "Properties Already Exist");
                }
            }
        }