コード例 #1
0
 public FieldObjectSwapper(IMatrixStorageSwappable <IGameObjectable> fieldMatrix, FieldProperties fieldProperties, ICoroutinePlayer coroutinePlayer, float swapDuration)
 {
     this.fieldMatrix     = fieldMatrix;
     this.fieldProperties = fieldProperties;
     this.coroutinePlayer = coroutinePlayer;
     this.swapDuration    = swapDuration;
 }
コード例 #2
0
        RowLayout ParseLayout(string tableName, XElement xLayout)
        {
            var fields     = new List <FieldProperties>();
            int fieldCount = int.Parse(xLayout.Attribute("FieldCount").Value);

            foreach (XElement element in xLayout.Elements())
            {
                switch (element.Name.LocalName)
                {
                case "Field":
                    FieldProperties field = ParseField(tableName, element);
                    fields.Add(field);
                    break;

                default: throw new InvalidDataException(string.Format("Unknown tree type {0}", element.Name.LocalName));
                }
            }

            if (fields.Count != fieldCount)
            {
                throw new InvalidDataException();
            }

            return(RowLayout.CreateUntyped(tableName, fields.ToArray()));
        }
コード例 #3
0
ファイル: DBInfoDao.cs プロジェクト: GlibWild/SQL-Op-Tool
        public List <ServerEntity> SearchFieldProperties(List <ServerEntity> ServerList)
        {
            IDbConnection       conn = null;
            List <ServerEntity> list = new List <ServerEntity>(ServerList);

            foreach (ServerEntity item in ServerList)
            {
                FieldProperties temp = new FieldProperties();
                try
                {
                    string con = "Server=" + item.ServerIP + "," + item.ServerPort + "; UID=" + item.ServerUserName + ";PWD=" + item.ServerPassword + ";Initial Catalog=" + item.ServerDBName[0] + ";";
                    conn = new SqlConnection(con);
                    string sql = "SELECT a.name FieldName,COLUMNPROPERTY(a.id,a.name,'IsIdentity') SelfPropagation, (case when (SELECT count(*) FROM sysobjects WHERE (name in (SELECT name FROM sysindexes WHERE (id = a.id) AND (indid in (SELECT indid FROM sysindexkeys WHERE (id = a.id) AND (colid in (SELECT colid FROM syscolumns WHERE (id = a.id) AND (name = a.name))))))) AND (xtype = 'PK'))>0 then '1' else '0' end) IsPrimaryKey, b.name FieldType, COLUMNPROPERTY(a.id,a.name,'PRECISION') as FieldLength, (case when a.isnullable=1 then '1'else '0' end) FieldValueNull FROM  syscolumns  a  left join systypes b on  a.xtype=b.xusertype inner join sysobjects d on a.id=d.id  and  d.xtype='U' and  d.name<>'dtproperties' left join syscomments e on a.cdefault=e.id left join sys.extended_properties  g on a.id=g.class AND a.colid = g.minor_id  where d.name = @TableName and a.name = @FieldName order by a.id,a.colorder";
                    temp = conn.Query <FieldProperties>(sql, new { TableName = item.ServerTBName[0], FieldName = item.Field[0].FieldName }).Single();
                    item.Field.Add(temp);
                    LogHelper.Log("数据库" + item.ServerIP + "," + item.ServerPort + ":" + item.ServerDBName[0] + ":" + item.ServerTBName[0] + "查询成功");
                }
                catch (Exception ex)
                {
                    temp.Tag = ex.Message;
                    item.Field.Add(temp);
                    LogHelper.Log("数据库" + item.ServerIP + "," + item.ServerPort + ":" + item.ServerDBName[0] + ":" + item.ServerTBName[0] + " 查询失败。\r\n原因:" + ex.Message);
                }
                finally
                {
                    conn.Close();
                }
            }
            return(list);
        }
コード例 #4
0
        /// <summary>Converts FieldProperties to an XElement.</summary>
        /// <param name="field">The field.</param>
        /// <returns></returns>
        public static XElement ToXElement(this FieldProperties field)
        {
            var xfield = new XElement("Field");

            xfield.SetAttributeValue("Name", field.Name);
            xfield.SetAttributeValue("DataType", field.DataType);
            if (field.Flags != 0)
            {
                xfield.Add(new XElement("Flags", field.Flags));
            }

            if (field.ValueType != null)
            {
                xfield.Add(new XElement("ValueType", field.ValueType.FullName));
            }

            if (field.StringEncoding != 0)
            {
                xfield.Add(new XElement("StringEncoding", field.StringEncoding));
            }

            if (field.MaximumLength > 0)
            {
                xfield.Add(new XElement("MaximumLength", field.MaximumLength));
            }

            switch (field.DataType)
            {
            case DataType.DateTime:
                xfield.Add(new XElement("DateTimeType", field.DateTimeType));
                xfield.Add(new XElement("DateTimeKind", field.DateTimeKind));
                break;
            }
            return(xfield);
        }
コード例 #5
0
    public FieldObjectMarker(GameObject mark, Transform markParentTransform, FieldProperties fieldProperties)
    {
        this.mark = mark;
        this.markParentTransform = markParentTransform;
        this.fieldProperties     = fieldProperties;

        InitializeMark();
    }
コード例 #6
0
 public void InitializeController(FieldProperties fieldProperties, IFieldObjectMarker fieldObjectMarker, IFieldObjectSwapper fieldObjectSwapper,
                                  IFieldUpdater fieldUpdater, ICombinationsFinder combinationsFinder)
 {
     this.fieldProperties    = fieldProperties;
     this.fieldObjectMarker  = fieldObjectMarker;
     this.fieldObjectSwapper = fieldObjectSwapper;
     this.fieldUpdater       = fieldUpdater;
     this.combinationsFinder = combinationsFinder;
 }
コード例 #7
0
        protected override string GetFieldCreationAttributes()
        {
            var result = base.GetFieldCreationAttributes();

            if (KeyScheme == KeyScheme.Identity)
            {
                return(result + FieldProperties.GetIdentity());
            }
            return(result);
        }
コード例 #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Reports()
 {
     CanCreateNewReport            = new CanCreateNewReport();
     DataSources                   = new DataSources();
     ReportPartTypes               = new ReportPartTypes();
     ReportCategoriesSubcategories = new ReportCategoriesSubcategories();
     FilterProperties              = new FilterProperties();
     FieldProperties               = new FieldProperties();
     Actions = new Actions();
 }
コード例 #9
0
 /// <summary>Writes an array.</summary>
 /// <param name="writer">The writer.</param>
 /// <param name="name">The name of the array.</param>
 /// <param name="field">The field properties.</param>
 /// <param name="values">The values.</param>
 public static void Array(this JsonWriter writer, string name, FieldProperties field, IEnumerable values)
 {
     writer.BeginArray(name);
     foreach (object val in values)
     {
         string value = field.GetString(val, "\"", true);
         writer.ArrayValue(value, false, false);
     }
     writer.EndArray();
 }
コード例 #10
0
 public static IEnumerable <ValidationError> Validate(FieldProperties properties)
 {
     if (properties != null)
     {
         foreach (var error in properties.Accept(Instance))
         {
             yield return(error);
         }
     }
 }
コード例 #11
0
        private static bool IsRequired(FieldProperties properties, ValidatorContext context)
        {
            var isRequired = properties.IsRequired;

            if (context.Action == ValidationAction.Publish)
            {
                isRequired = isRequired || properties.IsRequiredOnPublish;
            }

            return(isRequired);
        }
コード例 #12
0
        private ProxyFieldProperties ConverFieldProperties(FieldProperties properties)
        {
            ProxyFieldProperties p = new ProxyFieldProperties();

            p.Field    = properties.Field;
            p.Indexed  = properties.Indexed;
            p.Public   = properties.Public;
            p.DataType = properties.DataType;
            p.Type     = new ProxyType().CovertITypeToProxyType(properties.Type);
            return(p);
        }
コード例 #13
0
 public FieldUpdater(IMatrixStorageSwappable <IGameObjectable> fieldMatrix, ICombinationsFinder combinationsFinder, IFieldObjectCreator fieldObjectCreator,
                     IFieldObjectRemover fieldObjectRemover, ICoroutinePlayer coroutinePlayer, FieldProperties fieldProperties, float fieldObjectFallingStartSpeed, float fieldObjectFallingVelocity)
 {
     this.fieldMatrix                  = fieldMatrix;
     this.combinationsFinder           = combinationsFinder;
     this.fieldObjectCreator           = fieldObjectCreator;
     this.fieldObjectRemover           = fieldObjectRemover;
     this.coroutinePlayer              = coroutinePlayer;
     this.fieldProperties              = fieldProperties;
     this.fieldObjectFallingStartSpeed = fieldObjectFallingStartSpeed;
     this.fieldObjectFallingVelocity   = fieldObjectFallingVelocity;
 }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultField"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="dataType">Type of the data.</param>
        /// <param name="size">The size of the field.</param>
        /// <param name="properties">The properties.</param>
        public DefaultField(string name, Type dataType, int size, FieldProperties properties)
        {
            if (String.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");
            if (dataType == null)
                throw new ArgumentNullException("dataType");

            Name = name;
            DataType = dataType;
            Properties = properties;
            Size = size;
        }
コード例 #15
0
ファイル: PrimaryKey.cs プロジェクト: sGeeK44/Orm
        protected override string GetFieldCreationAttributes()
        {
            var result = base.GetFieldCreationAttributes();

            if (KeyScheme == KeyScheme.Identity)
            {
                result += FieldProperties.GetIdentity();
            }
            result += FieldProperties.PrimaryKeyConstraint(ConstraintName, FieldName);

            return(result);
        }
コード例 #16
0
 protected void generateFieldProperties()
 {
     foreach (DBField currField in Fields)
     {
         if (getProperties(currField.Name) == null)
         {
             FieldProperty metaData = new FieldProperty();
             metaData.FieldName = currField.Name;
             metaData.Visible   = true;
             FieldProperties.Add(metaData);
         }
     }
 }
コード例 #17
0
        public ArrayList  GetFieldProperties(string className)

        {
            ArrayList arr1             = new ArrayList();
            List <FieldProperties> arr = FieldProperties.FieldsFrom(className);

            foreach (FieldProperties f in arr)
            {
                ProxyFieldProperties p = ConverFieldProperties(f);
                arr1.Add(p);
            }
            return(arr1);
        }
コード例 #18
0
        static void CreateField(ref List <IFieldProperties> fields, FieldFlags flags, DataType dataType, string name, Type valueType = null)
        {
            var field = new FieldProperties()
            {
                Index     = fields.Count,
                Name      = name,
                Flags     = flags,
                DataType  = dataType,
                ValueType = valueType,
            }.Validate();

            fields.Add(field);
        }
コード例 #19
0
        /// <summary>
        /// 根据数据库表字段创建数据表对象。
        /// </summary>
        /// <returns>包含数据库表字段的数据表对象。</returns>
        public static DataTable CreateDataTable(TableFields fields)
        {
            DataTable dtRetrun = new DataTable();

            dtRetrun.TableName = fields.TABLE_NAME;
            foreach (string key in fields.FIELDS.Keys)
            {
                FieldProperties properties = fields.FIELDS[key];
                DataColumn      dc         = dtRetrun.Columns.Add(key, properties.DATATYPE);
                dc.AllowDBNull  = properties.CanNull;
                dc.DefaultValue = properties.DefaultValue;
            }
            return(dtRetrun);
        }
コード例 #20
0
        public static IEnumerable <ValidationError> Validate(FieldProperties properties)
        {
            if (properties != null)
            {
                if (!properties.IsForApi() && properties.IsListField)
                {
                    yield return(new ValidationError("UI field cannot be a list field.", nameof(properties.IsListField)));
                }

                foreach (var error in properties.Accept(Instance))
                {
                    yield return(error);
                }
            }
        }
コード例 #21
0
ファイル: DefaultField.cs プロジェクト: KerwinMa/Umbraco
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultField"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="dataType">Type of the data.</param>
        /// <param name="size">The size of the field.</param>
        /// <param name="properties">The properties.</param>
        public DefaultField(string name, Type dataType, int size, FieldProperties properties)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            if (dataType == null)
            {
                throw new ArgumentNullException("dataType");
            }

            Name       = name;
            DataType   = dataType;
            Properties = properties;
            Size       = size;
        }
コード例 #22
0
        XElement SerializeRow(RowLayout layout, Row row)
        {
            if (layout.IDFieldIndex < 0)
            {
                throw new Exception($"Structure {layout} needs to define an ID field!");
            }

            var xRow = new XElement("Row");

            for (int i = 0; i < layout.FieldCount; i++)
            {
                FieldProperties field = layout.GetProperties(i);
                string          value = field.GetString(row.GetValue(i), "'", false);
                xRow.SetAttributeValue(field.Name, value);
            }
            return(xRow);
        }
コード例 #23
0
ファイル: FieldManager.cs プロジェクト: mebikrouse/match3
    private void Awake()
    {
        MatrixStorage <FieldObject> fieldMatrix = new MatrixStorage <FieldObject>(fieldSize);

        FieldProperties     fieldProperties    = new FieldProperties(fieldContainer, fieldSize, fieldScale);
        ICombinationsFinder combinationsFinder = new CombinationsFinder(fieldMatrix);

        IFieldObjectMarker  fieldObjectMarker  = new FieldObjectMarker(fieldObjectMarkerGameObject, fieldObjectMarkerContainer, fieldProperties);
        IFieldObjectSwapper fieldObjectSwapper = new FieldObjectSwapper(fieldMatrix, fieldProperties, coroutinePlayer, swapDuration);
        IFieldObjectCreator fieldObjectCreator = new FieldObjectCreator(fieldMatrix, fieldProperties, fieldObjects);
        IFieldObjectRemover fieldObjectRemover = new FieldObjectRemover(fieldMatrix);
        IFieldUpdater       fieldUpdater       = new FieldUpdater(fieldMatrix, combinationsFinder, fieldObjectCreator, fieldObjectRemover, coroutinePlayer,
                                                                  fieldProperties, fieldObjectFallingStartSpeed, fieldObjectFallingVelocity);

        controller.InitializeController(fieldProperties, fieldObjectMarker, fieldObjectSwapper, fieldUpdater, combinationsFinder);

        FillFieldWithObjects(fieldObjectCreator);
    }
コード例 #24
0
        void SerializeRow(RowLayout layout, Row row)
        {
            switch (Version)
            {
            case 1: result.Append("["); break;

            case 2:
            case 3: result.Append("{"); break;

            default: throw new NotImplementedException(string.Format("JSonVersion {0} not implemented!", Version));
            }
            for (int i = 0; i < layout.FieldCount; i++)
            {
                try
                {
                    FieldProperties field = layout.GetProperties(i);
                    string          value = field.GetString(row.GetValue(i), "\"", true);
                    if (i > 0)
                    {
                        result.Append(',');
                    }

                    if (Version >= 2)
                    {
                        result.Append($"\"{layout.GetName(i)}\":");
                    }

                    result.Append(value);
                }
                catch (Exception ex)
                {
                    throw new InvalidDataException(string.Format("Error during serialization of layout {0} row {1}", layout, row), ex);
                }
            }
            switch (Version)
            {
            case 1: result.Append("]"); break;

            case 2:
            case 3: result.Append("}"); break;

            default: throw new NotImplementedException(string.Format("JSonVersion {0} not implemented!", Version));
            }
        }
コード例 #25
0
ファイル: RowLayout.cs プロジェクト: elfen20/clone-cave-data
        /// <summary>Loads the row layout from the specified reader.</summary>
        /// <param name="reader">The reader.</param>
        /// <returns>A new <see cref="RowLayout" /> instance.</returns>
        public static RowLayout Load(DataReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            var count           = reader.Read7BitEncodedInt32();
            var tableName       = reader.ReadString();
            var fieldProperties = new FieldProperties[count];

            for (var i = 0; i < count; i++)
            {
                var field = fieldProperties[i] = new FieldProperties();
                field.Load(reader, i);
            }

            return(new RowLayout(tableName, fieldProperties, null));
        }
コード例 #26
0
ファイル: NamingConvention.cs プロジェクト: wangfujia/iridium
        public virtual FieldProperties GetFieldProperties(TableSchema schema, TableSchema.Field field)
        {
            var fieldProperties = new FieldProperties();

            if (Regex.IsMatch(field.FieldName, IsFieldIndexedRegex, RegexOptions.IgnoreCase))
            {
                fieldProperties.Indexed = true;
            }

            string pkName = PrimaryKeyName.Replace(CLASS_NAME, schema.ObjectType.Name);

            if (field.FieldName.Equals(pkName, StringComparison.OrdinalIgnoreCase))
            {
                fieldProperties.PrimaryKey    = true;
                fieldProperties.AutoIncrement = UseAutoIncrement && field.FieldInfo.Inspector().Type.Inspector().Is(TypeFlags.Integer);
                fieldProperties.Indexed       = false;
            }

            return(fieldProperties);
        }
コード例 #27
0
ファイル: RowLayout.cs プロジェクト: elfen20/clone-cave-data
        /// <summary>Creates an alien row layout without using any field properies.</summary>
        /// <param name="type">Type to parse fields from.</param>
        /// <param name="onlyPublic">if set to <c>true</c> [use only public].</param>
        /// <param name="namingStrategy">Naming strategy for fields.</param>
        /// <returns>A new <see cref="RowLayout" /> instance.</returns>
        public static RowLayout CreateAlien(Type type, bool onlyPublic, NamingStrategy namingStrategy)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            var bindingFlags = BindingFlags.Public | BindingFlags.Instance;

            if (onlyPublic)
            {
                bindingFlags |= BindingFlags.NonPublic;
            }

            var rawInfos   = type.GetFields(bindingFlags);
            var properties = new FieldProperties[rawInfos.Length];

            for (var i = 0; i < rawInfos.Length; i++)
            {
                var fieldInfo = rawInfos[i];
                try
                {
                    if (fieldInfo.FieldType.IsArray)
                    {
                        continue;
                    }

                    var field = new FieldProperties();
                    field.LoadFieldInfo(i, fieldInfo, namingStrategy);
                    properties[i] = field;
                }
                catch (Exception ex)
                {
                    throw new InvalidDataException(
                              $"Error while loading field properties of type {type.FullName} field {fieldInfo}!", ex);
                }
            }

            return(new RowLayout(type.Name, properties, type));
        }
コード例 #28
0
        private void btn_AddField_Click(object sender, EventArgs e)
        {
            if (ServerList.Count == 0 && GetServerInfo())
            {
                MessageBox.Show("请选择数据库以及服务器");
                return;
            }
            if (string.IsNullOrEmpty(tb_TableName.Text) || string.IsNullOrWhiteSpace(tb_TableName.Text))
            {
                MessageBox.Show("请输入添加字段的表");
                return;
            }
            if (string.IsNullOrEmpty(tb_AddFieldName.Text) || string.IsNullOrWhiteSpace(tb_AddFieldName.Text))
            {
                MessageBox.Show("请输入添加字段");
                return;
            }
            if (string.IsNullOrEmpty(comboBox_FieldType.Text) || string.IsNullOrWhiteSpace(comboBox_FieldType.Text))
            {
                MessageBox.Show("请输入添加字段类型");
                return;
            }
            foreach (var item in ServerList)
            {
                item.Field.Clear();
                item.ServerTBName.Add(tb_TableName.Text);
                string          FieldType = comboBox_FieldType.Text;
                FieldProperties fp        = new FieldProperties();

                fp.FieldName       = tb_AddFieldName.Text;
                fp.FieldType       = FieldType;
                fp.FieldValueNull  = cb_NullValue.Checked == true ? 1 : 0;
                fp.IsPrimaryKey    = cb_PrimaryKey.Checked == true ? 1 : 0;
                fp.SelfPropagation = cb_SelfPropagation.Checked == true ? 1 : 0;
                item.Field.Add(fp);
            }
            string result = service.AddTableField(ServerList);

            MessageBox.Show(result);
        }
コード例 #29
0
        object ConvertValue(object value)
        {
            try
            {
                if (FieldProperties.ValueType.IsPrimitive && FieldProperties.ValueType.IsValueType)
                {
                    try
                    {
                        if (value is IConvertible conv)
                        {
                            return(conv.ToType(FieldProperties.ValueType, CultureInfo.InvariantCulture));
                        }
                    }
                    catch { }
                }

                return(FieldProperties.ParseValue(value.ToString(), null, CultureInfo.InvariantCulture));
            }
            catch (Exception ex)
            {
                throw new InvalidDataException($"Search {this} cannot convert value {value} to type {FieldProperties}!", ex);
            }
        }
コード例 #30
0
ファイル: SqlTable.cs プロジェクト: elfen20/clone-cave-data
        /// <inheritdoc />
        public override IList <TValue> Distinct <TValue>(string fieldname, Search search = null)
        {
            var escapedFieldName = Storage.EscapeFieldName(Layout[fieldname]);
            var field            = new FieldProperties
            {
                Name           = fieldname,
                NameAtDatabase = fieldname,
                Flags          = FieldFlags.None,
                DataType       = DataType.String,
                TypeAtDatabase = DataType.String
            };

            field.Validate();
            string query;

            if (search == null)
            {
                query = $"SELECT DISTINCT {escapedFieldName} FROM {FQTN}";
            }
            else
            {
                var s = ToSqlSearch(search);
                query = $"SELECT DISTINCT {escapedFieldName} FROM {FQTN} WHERE {s}";
            }

            var rows   = Storage.Query(query, Database.Name, Name);
            var result = new Set <TValue>();

            foreach (var row in rows)
            {
                var value = (TValue)Fields.ConvertValue(typeof(TValue), row[0], CultureInfo.InvariantCulture);
                result.Include(value);
            }

            return(result.AsList());
        }
コード例 #31
0
 /// <summary>
 /// Creates a new field.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="dataType">The field data type.</param>
 /// <param name="properties">The properties.</param>
 /// <returns>A new field.</returns>
 public virtual IField CreateField(string name, Type dataType, FieldProperties properties)
 {
     return CreateField(name, dataType, 0, properties);
 }
コード例 #32
0
 /// <summary>
 /// Creates a new field.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="dataType">The field data type.</param>
 /// <param name="size">The size.</param>
 /// <param name="properties">The properties.</param>
 /// <returns>A new field.</returns>
 public virtual IField CreateField(string name, Type dataType, int size, FieldProperties properties)
 {
     return new DefaultField(name, dataType, size, properties);
 }
コード例 #33
0
 public void Should_freeze_field_properties(FieldProperties action)
 {
     TestUtils.TestFreeze(action);
 }
コード例 #34
0
ファイル: NamingConvention.cs プロジェクト: abrobston/DB
        public virtual FieldProperties GetFieldProperties(OrmSchema schema, OrmSchema.Field field)
        {
            var fieldProperties = new FieldProperties();

            if (Regex.IsMatch(field.FieldName, IsFieldIndexedRegex, RegexOptions.IgnoreCase))
                fieldProperties.Indexed = true;

            string pkName = PrimaryKeyName.Replace(CLASS_NAME, schema.ObjectType.Name);

            if (field.FieldName.Equals(pkName, StringComparison.OrdinalIgnoreCase))
            {
                fieldProperties.PrimaryKey = true;
                fieldProperties.AutoIncrement = UseAutoIncrement && field.FieldInfo.TypeInspector.Is(TypeFlags.Integer);
                fieldProperties.Indexed = false;
            }

            return fieldProperties;
        }
コード例 #35
0
ファイル: HelperFunctions.cs プロジェクト: johanericsson/code
        public static FieldProperties[] GetProperties(ref string[] fieldNames,bool isKg)
        {
            FieldProperties[] properties = new FieldProperties[fieldNames.Length];
            for (int i=0;i<properties.Length;i++)
            {
                FieldProperties prop = new FieldProperties();
                prop.width = 70;
                prop.isKeyField = false;
                prop.readOnly = false;
                prop.type = typeof(string);
                prop.columnStyle = ColumnStyle.Text;
                prop.alignment = HorizontalAlignment.Left;
                prop.formatString = null;
                string fieldName = fieldNames[i];
                if (fieldName[0]=='*') // * indicates read only field
                {
                    fieldName = fieldName.Substring(1); // Pull the * off of the string
                    prop.readOnly = true;
                    fieldNames[i] = fieldName;
                }
                switch (fieldName)
                {
                    case "ContainerBundleID":
                        prop.isKeyField= true;
                        prop.type = typeof(int);
                        break;
                    case "ContID":
                        prop.isKeyField = true;
                        prop.type = typeof(int);
                        break;
                    case "BOLID":
                        prop.isKeyField = true;
                        prop.type = typeof(int);
                        break;
                    case "POItemNumber":
                        prop.isKeyField = true;
                        prop.type = typeof(int);
                        break;
                    case "SeqNumber":
                        prop.isKeyField = true;
                        prop.type = typeof(int);
                        break;
                    case "ContainerWeight":
                        prop.width = 170;
                        prop.type = typeof(decimal);
                        prop.formatString = "N0";
                        prop.columnHeading = "Total weight in containers" + GetSuffix(isKg);
                        break;
                    case "BOLWeight":
                        prop.width = 170;
                        prop.type = typeof(decimal);
                        prop.formatString = "N0";
                        prop.columnHeading = "Total weight picked up" + GetSuffix(isKg);
                        break;
                    case "TotalContainerWeight":
                        prop.width = 170;
                        prop.type = typeof(decimal);
                        prop.formatString = "N0";
                        prop.columnHeading = "Total weight in containers" + GetSuffix(isKg);
                        break;
                    case "EnglishShipQty":
                        prop.type = typeof(decimal);
                        prop.columnHeading = "Ship Qty(lbs)";
                        prop.width = 80;
                        prop.formatString = "N0";
                        break;
                    case "MetricShipQty":
                        prop.type = typeof(decimal);
                        prop.columnHeading = "Ship Qty(kg)";
                        prop.width = 80;
                        prop.formatString = "N0";
                        break;
                    case "ContNumber":
                        prop.columnHeading = "Container Number";
                        prop.width = 120;
                        break;
                    case "ETA":
                        prop.columnHeading = "ETA";
                        break;
                    case "ShipDate":
                        prop.columnHeading = "Ship Date";
                        prop.width = 90;
                        break;
                    case "PONumber":
                        prop.columnHeading = "PONumber";
                        prop.width = 100;
                        break;
                    case "ItemName":
                        prop.columnHeading = "Grade";
                        prop.columnStyle = ColumnStyle.Item;
                        prop.width = 95;
                        break;
                    case "ItemDesc":
                        prop.columnHeading = "Description";
                        prop.width = 250;
                        break;
                    case "PercentPickedUp":
                        prop.columnHeading = "% Picked Up";
                        prop.width = 90;
                        prop.type = typeof(decimal);
                        prop.formatString = "N2";
                        break;
                    case "Qty":
                        prop.columnHeading = "Weight" + GetSuffix(isKg);
                        prop.type = typeof(decimal);
                        prop.formatString = "N0";
                        break;
                    case "CustRate":
                        if (isKg)
                            prop.columnHeading = "Rate($/kg)";
                        else
                            prop.columnHeading = "Rate($/lbs)";
                        prop.type = typeof(decimal);
                        break;
                    case "CustAmount":
                        prop.columnHeading = "Amount";
                        prop.type = typeof(decimal);
                        prop.formatString = "N2";
                        break;
                    case "Length":
                        prop.columnHeading = "Length";
                        prop.width = 115;
                        break;
                    case "SizeOfItem":
                        prop.columnHeading = "Size";
                        prop.width = 55;
                        break;
                    case "ItemAccessCode":
                        prop.columnHeading = "IAC";
                        break;
                    case "DateRequired":
                        prop.columnHeading = "Date Required";
                        prop.width = 90;
                        prop.columnStyle = ColumnStyle.Date;
                        break;
                    case "PickupDate":
                        prop.columnHeading = "Pickup Date";
                        prop.width = 70;
                        prop.columnStyle = ColumnStyle.Date;
                        break;
                    case "PickupTerminal":
                        prop.columnHeading = "Terminal";
                        prop.width = 100;
                        break;
                    case "Heat":
                        prop.columnHeading = "Heat";
                        prop.width = 70;
                        break;
                    case "MillShipDate":
                        prop.columnHeading = "Ship Date";
                        prop.width = 90;
                        prop.columnStyle = ColumnStyle.Date;
                        break;
                    case "Comments":
                        prop.columnHeading = "Comments";
                        prop.width = 250;
                        prop.columnStyle = ColumnStyle.Text;
                        break;
                    case "CancelDate":
                        prop.columnHeading = "Cancel Date";
                        prop.width = 100;
                        prop.columnStyle = ColumnStyle.Date;
                        break;
                    case "AcknowledgeDate":
                        prop.columnHeading = "Acknowledge Date";
                        prop.width = 110;
                        prop.columnStyle = ColumnStyle.Date;
                        break;
                    case "MillConfirmationNumber":
                        prop.columnHeading = "Confirmation#";
                        prop.width = 110;
                        break;
                    case "MillAcknowledgeDate":
                        prop.columnHeading = "Confirmation Date";
                        prop.width = 110;
                        prop.columnStyle = ColumnStyle.Date;
                        break;
                    case "InvoiceNumber":
                        prop.columnHeading = "Inv#";
                        prop.width = 60;
                        break;
                    case "EMInvoiceNumber":
                        prop.columnHeading = "EM Inv";
                        prop.width = 40;
                        break;
                    case "MillInvoiceDate":
                        prop.columnHeading = "Inv Date";
                        prop.width = 70;
                        prop.columnStyle = ColumnStyle.Date;
                        break;
                    case "BundleAlloySurcharge":
                        prop.columnHeading = "Alloy/100Lbs";
                        prop.width = 100;
                        prop.formatString = "N2";
                        prop.type = typeof(decimal);
                        break;
                    case "BundleScrapSurcharge":
                        prop.columnHeading = "Scrap/100Lbs";
                        prop.width = 100;
                        prop.formatString = "N2";
                        prop.type = typeof(decimal);
                        break;

                    case "BundleSurcharge":
                        prop.columnHeading = "Surcharge/100Lbs";
                        prop.width = 120;
                        prop.formatString = "N2";
                        prop.type = typeof(decimal);
                        break;
                    case "TotalSurcharge":
                        prop.columnHeading = "Total Surcharge";
                        prop.width = 95;
                        prop.formatString = "N2";
                        prop.type = typeof(decimal);
                        break;
                    case "TotalWithSurcharge":
                        prop.columnHeading = "Full Total";
                        prop.width = 95;
                        prop.formatString = "N2";
                        prop.type = typeof(decimal);
                        break;
                    case "InvoiceDate":
                        prop.columnHeading = "Invoice Date";
                        prop.width = 100;
                        prop.columnStyle = ColumnStyle.Date;
                        break;
                    // Container item grid
                    case "BundleSeqNumber":
                        prop.columnHeading = "#";
                        prop.width = 30;
                        prop.type = typeof(int);
                        break;
                    case "ShipQty":
                        prop.columnHeading = "Ship Qty" + GetSuffix(isKg);
                        prop.type = typeof(decimal);
                        prop.width = 100;
                        break;
                    case "BayNumber":
                        prop.columnHeading = "Bay#";
                        prop.width = 40;
                        break;
                    case "BOLNumber":
                        prop.columnHeading = "Lading#";
                        prop.width = 100;
                        break;
                    case "Finish":
                        prop.columnHeading = "Finish";
                        prop.comboBoxItems = GetFinishItems("Finish");
                        prop.width = 40;
                        break;
                    case "Treatment":
                        prop.columnHeading = "Treat";
                        prop.comboBoxItems = GetFinishItems("Treatment");
                        prop.width = 45;
                        break;
                    case "Heading":
                        prop.columnHeading = "";
                        break;
                    case "FinishWeight":
                        prop.columnHeading = "Weight" + GetSuffix(isKg);
                        prop.type = typeof(decimal);
                        prop.formatString = "N0";
                        break;
                    case "FinishAmount":
                        prop.columnHeading = "Amount";
                        prop.type = typeof(decimal);
                        prop.formatString = "N2";
                        break;
                    case "ProofOfDelivery":
                        prop.columnHeading = "Bill of lading";
                        prop.type = typeof(string);
                        prop.width = 150;
                        break;
                    default:
                        throw new Exception("couldn't find field name");
                }
                float systemDPI = GetSystemDPI();
                float ratio = systemDPI / 96;
                prop.width = (int)(ratio * prop.width + .5);
                if (prop.columnStyle == ColumnStyle.Date)
                    prop.type = typeof(DateTime);
                if (prop.type == typeof(decimal))
                    prop.alignment = HorizontalAlignment.Right;
                properties[i] = prop;
            }
            return properties;
        }
コード例 #36
0
 /// <summary>
 /// Determines whether the field has the specified property.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <returns><c>true</c> if the field has the property; otherwise, <c>false</c>.</returns>
 public virtual bool HasProperty(FieldProperties property)
 {
     return (Properties & property) == property;
 }