private void LoadSerialEntryInformation() { if (this.DistinctListingFunctionNames.Count > 0) { foreach (string functionName in this.DistinctListingFunctionNames) { UPSEColumn column = this.SerialEntry.ColumnForFunctionName(functionName); if (column != null) { this.rowColumnsForFunctionNames[functionName] = column; } } } if (this.ListingFieldMatchHierarchy.Count > 0) { foreach (UPSEListingFieldMatch item in this.ListingFieldMatchHierarchy) { foreach (string functionName in item.FunctionNames) { if (this.rowColumnsForFunctionNames.ContainsKey(functionName)) { UPSEColumn column = this.SerialEntry.ColumnForFunctionName(functionName); if (column != null) { this.rowColumnsForFunctionNames[functionName] = column; } } } } } }
private void ProcessNetValueColumn(UPSEColumn netValueColumn, double endPrice) { if (netValueColumn != null) { double netPrice = endPrice; if (netPrice != 0) { var rebateFieldNames = new List <string> { "Discount", "Rebate", "Rebate1", "Rebate2", "DiscountCondition", "DiscountBundle" }; foreach (var rebateFieldName in rebateFieldNames) { var rebateColumn = SerialEntry.DestColumnsForFunction.ValueOrDefault(rebateFieldName); if (rebateColumn != null) { var rebateRowValue = RowValues[rebateColumn.Index]; object rebate = rebateRowValue.Value; if (rebate != null) { netPrice *= 1 - GetDouble(rebate); } } } } var netPriceRowValue = RowValues[netValueColumn.Index]; netPriceRowValue.Value = netPrice; } }
private void ProcessUnitPriceColumn( UPSEColumn unitPriceColumn, UPSEColumn pricingUnitPriceColumn, UPSEColumn disablePricingColumn, ref double price) { if (unitPriceColumn != null || pricingUnitPriceColumn != null) { UPSERowValue unitPriceRowValue = null; UPSERowValue pricingUnitPriceRowValue = null; UPSERowValue readPrice = null; if (unitPriceColumn != null) { readPrice = RowValues[unitPriceColumn.Index]; unitPriceRowValue = readPrice; } if (unitPriceRowValue != null && disablePricingColumn != null) { if (BoolValueFromColumn((UPSEDestinationColumn)disablePricingColumn)) { unitPriceRowValue = null; } } if (pricingUnitPriceColumn != null) { pricingUnitPriceRowValue = RowValues[pricingUnitPriceColumn.Index]; if (readPrice == null) { readPrice = pricingUnitPriceRowValue; } } if (price > 0.0000001 || price < -0.0000001) { if (pricingUnitPriceRowValue != null) { pricingUnitPriceRowValue.Value = price; } if (unitPriceRowValue != null) { unitPriceRowValue.Value = price; } else if (readPrice != null && (readPrice.Value is float || readPrice.Value is string)) { price = GetDouble(readPrice.Value); } } else if (readPrice.Value is float || readPrice.Value is string) { price = GetDouble(readPrice.Value); } } }
private int IntegerValueFromColumn(UPSEColumn column) { if (column == null) { return(0); } var valueAtIndex = this.ValueAtIndex(column.Index); return(Convert.ToInt32(valueAtIndex)); }
private void ProcessSerialEntryColumns(UPCRMRecord rootRecord) { for (var columnIndex = 0; columnIndex < this.count; columnIndex++) { this.column = this.SerialEntry.Columns[columnIndex]; this.destinationColumn = this.column as UPSEDestinationColumnBase; if (this.destinationColumn != null) { if (this.destinationColumn.DontCacheOffline && this.destinationColumn.DontSave) { continue; } this.rowValue = this.RowValues[columnIndex]; var originalVal = this.destinationColumn.StringValueFromObject(this.rowValue.OriginalValue); var stringValue = this.destinationColumn.StringValueFromObject(this.rowValue.Value); var changedValue = this.column.IsValueDifferentThan(stringValue, originalVal); if (!changedValue && !this.rowValue.SaveUnchanged) { continue; } if (!changedValue) { originalVal = null; } if (this.column.ColumnFrom == UPSEColumnFrom.DestChild) { this.ProcessUpseColumnFromDestChild(rootRecord, changedValue, stringValue, originalVal); } else { if (this.destinationColumn.DontSave) { this.destinationRootRecord.NewValueFromValueFieldIdOnlyOffline( stringValue, originalVal, this.column.FieldId, true); } else { this.destinationRootRecord.NewValueFromValueFieldId(stringValue, originalVal, this.column.FieldId); } if (changedValue) { this.destinationRootRecord.HasValues = true; } } } } }
/// <summary> /// Initializes a new instance of the <see cref="UPSEColumn"/> class. /// </summary> /// <param name="fieldConfig">The field configuration.</param> /// <param name="column">The column.</param> public UPSEColumn(UPConfigFieldControlField fieldConfig, UPSEColumn column) { this.FieldConfig = fieldConfig; this.CrmField = column.CrmField; this.PositionInControl = column.PositionInControl; this.Index = column.Index; this.Function = column.Function; this.InitialValue = column.InitialValue; this.SortInfo = column.SortInfo; this.Hidden = column.Hidden; this.ListingDestinationFunctionName = column.ListingDestinationFunctionName; }
/// <summary> /// Initializes a new instance of the <see cref="UPSEColumnSortInfo"/> class. /// </summary> /// <param name="column">The column.</param> /// <param name="fieldConfig">The field configuration.</param> /// <exception cref="Exception">SortIndex is null</exception> public UPSEColumnSortInfo(UPSEColumn column, UPConfigFieldControlField fieldConfig) { string sortIndexString = fieldConfig.Attributes.ExtendedOptionForKey("SortIndex"); if (string.IsNullOrEmpty(sortIndexString)) { return; // throw new Exception("SortIndex is null"); } this.SortIndex = Convert.ToInt32(sortIndexString); this.Column = column; this.Descending = fieldConfig.Attributes.ExtendedOptionIsSet("SortDescending"); this.CompareType = fieldConfig.Field.IsNumericField ? UPSEColumnInfoCompareType.Number : UPSEColumnInfoCompareType.StringsInsensitive; }
/// <summary> /// Results for row row. /// </summary> /// <param name="_serialEntry">The serial entry.</param> /// <param name="row">The row.</param> /// <returns></returns> public UPCRMResult ResultForRowRow(UPSerialEntry _serialEntry, UPSERow row) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; FieldControl documentFieldControl = configStore.FieldControlByNameFromGroup("List", "D1DocData"); UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(documentFieldControl); UPConfigFilter filter = configStore.FilterByName(this.FilterName); if (filter != null) { Dictionary <string, object> valuesForFunction = new Dictionary <string, object>(); Dictionary <string, UPSEColumn> columnsForFunction = _serialEntry.DestColumnsForFunction; foreach (string functionName in columnsForFunction.Keys) { UPSEColumn column = columnsForFunction.ValueOrDefault(functionName) ?? columnsForFunction.ValueOrDefault($"$par{functionName}"); if (column != null) { string value = row.StringValueAtIndex(column.Index); if (!string.IsNullOrEmpty(value)) { valuesForFunction.SetObjectForKey(value, functionName); } } } UPConfigFilter replacedFilter = filter.FilterByApplyingValueDictionaryDefaults(valuesForFunction, true); crmQuery.ApplyFilter(replacedFilter); } else { crmQuery.MaxResults = 10; } UPCRMResult crmResult = crmQuery.Find(); return(crmResult); }
/// <summary> /// Rowses the loaded. /// </summary> public void RowsLoaded() { List <string> _unknown = null; List <string> itemNumbers = this.ItemNumbers; int count = itemNumbers.Count; Dictionary <string, UPSERow> rowsForItemNumber = new Dictionary <string, UPSERow>(this.Rows.Count); foreach (UPSERow row in this.Rows) { row.EnsureLoaded(); string itemNumber = row.ValueForFunctionName(this.ItemNumberDestination); if (string.IsNullOrEmpty(itemNumber)) { continue; } rowsForItemNumber.SetObjectForKey(row, itemNumber); } this.RowsCreated = 0; List <int> columnIndices = new List <int>(); for (int i = 0; i < this.FillColumns.Count; i++) { string columnName = this.FillColumns[i]; List <UPSEColumn> childColumnArray = this.SerialEntry.DestChildColumnsForFunction[columnName]; UPSEColumn col = childColumnArray.Count > 0 ? childColumnArray[0] : this.SerialEntry.DestColumnsForFunction.ValueOrDefault(columnName); if (col != null) { columnIndices.Add(col.Index); } else { columnIndices.Add(-1); } } for (int i = 0; i < count; i++) { string itemNumber = itemNumbers[i]; UPSERow row = rowsForItemNumber.ValueOrDefault(itemNumber); if (row == null) { if (_unknown == null) { _unknown = new List <string> { itemNumber }; } else { _unknown.Add(itemNumber); } continue; } int fillColumnIndex = 0; foreach (string col in this.FillColumns) { int columnIndex = columnIndices[fillColumnIndex++]; if (columnIndex < 0 || col == this.ItemNumberSource) { continue; } List <string> v = this.FillData.ValueOrDefault(col) as List <string>; if (v.Count > i) { string value = v[i]; UPSERowOperation rowOperation = row.NewValueForColumnIndexReturnAffectedRows(value, columnIndex, null); if (rowOperation == UPSERowOperation.Add) { this.SerialEntry.AddPosition(row); this.SerialEntry.SaveAllExecuted = false; } } } } this.SerialEntry.AutoFillFinished(); }
/// <summary> /// Initializes a new instance of the <see cref="UPSESourceColumn"/> class. /// </summary> /// <param name="fieldConfig">The field configuration.</param> /// <param name="column">The column.</param> public UPSESourceColumn(UPConfigFieldControlField fieldConfig, UPSEColumn column) : base(fieldConfig, column) { }