Ejemplo n.º 1
0
        /// <summary>
        /// Sets key and lookup values in <see cref="ColumnValueBag"/>.
        /// </summary>
        /// <param name="valueBag">The <see cref="ColumnValueBag"/>.</param>
        /// <param name="key">The key.</param>
        /// <param name="lookup">The lookup projection.</param>
        public void SetValueBag(ColumnValueBag valueBag, CandidateKey key, Projection lookup)
        {
            if (valueBag == null)
            {
                throw new ArgumentNullException(nameof(valueBag));
            }
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            for (int i = 0; i < key.Count; i++)
            {
                var column = key[i].Column;
                SetValueBag(valueBag, column);
            }

            if (lookup != null)
            {
                var columns = lookup.Columns;
                for (int i = 0; i < columns.Count; i++)
                {
                    SetValueBag(valueBag, columns[i]);
                }
            }
        }
Ejemplo n.º 2
0
 private static void Refresh(CustomerBox v, ColumnValueBag valueBag, Customer.Lookup _)
 {
     v._companyName.Text   = valueBag.GetValue(_.CompanyName);
     v._contactPerson.Text = Customer.GetContactPerson(valueBag.GetValue(_.LastName), valueBag.GetValue(_.FirstName), valueBag.GetValue(_.Title));
     v._phone.Text         = valueBag.GetValue(_.Phone);
     v._email.Text         = valueBag.GetValue(_.EmailAddress);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Ends the lookup operation and updates this <see cref="ForeignKeyBox"/>.
 /// </summary>
 /// <param name="valueBag">The <see cref="ColumnValueBag"/> that contains foreign key and lookup data.</param>
 public void EndLookup(ColumnValueBag valueBag)
 {
     if (valueBag != null)
     {
         ValueBag = valueBag;
         DataPresenter?.InvalidateView();
     }
 }
Ejemplo n.º 4
0
            public ColumnValueBag[] Submit()
            {
                RowValidation.SetAsyncErrors(DataValidationResults.Empty);

                if (!SubmitInput())
                {
                    return(null);
                }

                var result            = new ColumnValueBag[DataSet.Count];
                var serializers       = GetColumnSerializers();
                var validationResults = DataValidationResults.Empty;

                for (int i = 0; i < DataSet.Count; i++)
                {
                    var validationErrors = DataValidationErrors.Empty;
                    var columnValueBag   = new ColumnValueBag();
                    result[i] = columnValueBag;
                    for (int j = 0; j < serializers.Count; j++)
                    {
                        var serializer = serializers[j];
                        if (serializer == null)
                        {
                            continue;
                        }

                        var textColumn = _.TextColumns[j];
                        try
                        {
                            serializer.Deserialize(textColumn[i], columnValueBag);
                        }
                        catch (Exception ex)
                        {
                            validationErrors = validationErrors.Add(new DataValidationError(ex.Message, textColumn));
                        }
                    }

                    if (validationErrors.Count > 0)
                    {
                        validationResults = validationResults.Add(new DataValidationResult(DataSet[i], validationErrors));
                    }
                }

                if (validationResults.Count > 0)
                {
                    RowValidation.SetAsyncErrors(validationResults);
                    return(null);
                }

                var pasteAppendService = _sourcePresenter.GetService <DataView.IPasteAppendService>(false);

                if (pasteAppendService != null && !pasteAppendService.Verify(result))
                {
                    return(null);
                }
                return(result);
            }
Ejemplo n.º 5
0
 private static void Refresh(AddressBox v, ColumnValueBag valueBag, Address.Lookup _)
 {
     v._addressLine1.Text  = valueBag.GetValue(_.AddressLine1);
     v._addressLine2.Text  = valueBag.GetValue(_.AddressLine2);
     v._city.Text          = valueBag.GetValue(_.City);
     v._stateProvince.Text = valueBag.GetValue(_.StateProvince);
     v._countryRegion.Text = valueBag.GetValue(_.CountryRegion);
     v._postalCode.Text    = valueBag.GetValue(_.PostalCode);
 }
Ejemplo n.º 6
0
 public override void Deserialize(string s, ColumnValueBag columnValueBag)
 {
     if (s == null)
     {
         columnValueBag[_column] = null;
     }
     else
     {
         var converter = TypeDescriptor.GetConverter(_column.DataType);
         var value     = converter.ConvertFromString(s);
         columnValueBag[_column] = value;
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates column value bag with specified key and lookup.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="lookup">The lookup projection.</param>
        /// <returns>The created <see cref="ColumnValueBag"/>.</returns>
        public ColumnValueBag MakeValueBag(CandidateKey key, Projection lookup)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            var result = new ColumnValueBag();

            result.AutoSelect(key, DataRow);
            if (lookup != null)
            {
                result.AutoSelect(lookup, DataRow);
            }
            return(result);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Sets column value in <see cref="ColumnValueBag"/>.
 /// </summary>
 /// <param name="valueBag">The <see cref="ColumnValueBag"/>.</param>
 /// <param name="column">The column.</param>
 public void SetValueBag(ColumnValueBag valueBag, Column column)
 {
     if (valueBag == null)
     {
         throw new ArgumentNullException(nameof(valueBag));
     }
     column = VerifyColumn(column, nameof(column));
     if (DataRow != null)
     {
         valueBag.SetValue(column, DataRow);
     }
     else
     {
         valueBag[column] = column.GetDefaultValue();
     }
 }
Ejemplo n.º 9
0
            private bool PasteAppend(IReadOnlyList <Column> columns, ColumnValueBag data)
            {
                var presenter = DataPresenter;
                var row       = presenter.VirtualRow;

                row.BeginEdit();
                for (int i = 0; i < columns.Count; i++)
                {
                    var column = columns[i];
                    if (data.ContainsKey(column))
                    {
                        row[column] = data[column];
                    }
                }
                row.EndEdit();
                return(!presenter.IsEditing);
            }
Ejemplo n.º 10
0
 public override Object Calculate(AggregateValueBag aggregateValues, ColumnValueBag <Row> columnValues) => columnValues.Input.Number * columnValues.Input.Number;
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of <see cref="ForeignKeyBox"/> class.
 /// </summary>
 public ForeignKeyBox()
 {
     ValueBag = new ColumnValueBag();
 }
Ejemplo n.º 12
0
            public override void Deserialize(string s, ColumnValueBag columnValueBag)
            {
                var value = _deserializer(s);

                columnValueBag.SetValue(_column, value);
            }
Ejemplo n.º 13
0
 /// <summary>
 /// Deserializes string into column.
 /// </summary>
 /// <param name="value">The value of the string.</param>
 /// <param name="columnValueBag">The <see cref="ColumnValueBag"/> that will contain the column and deserialized value.</param>
 public abstract void Deserialize(string value, ColumnValueBag columnValueBag);
Ejemplo n.º 14
0
 private static string GetProductNumber(ColumnValueBag valueBag, Product.PK productKey, Product.Lookup productLookup)
 {
     return(valueBag.GetValue(productLookup.ProductNumber));
 }