Exemplo n.º 1
0
        public void AddEntity()
        {
            IEntityObject result = null;

            _window.DisplayName = string.Format("Add {0}", _entityName);
            _collection.AddNew();

            OpenModalWindow();
        }
Exemplo n.º 2
0
        private static void AddItemsToCollection()
        {
            //This should always be called on the logical thread
            Debug.Assert(_collection.Screen.Details.Dispatcher.CheckAccess(), "Expected to run on the logical thread");

            //Add Items to Collection
            dynamic numRows = _excelDocRange.GetLength(0) - 1;

            for (var i = 1; i <= numRows; i++)
            {
                var   newRow             = _collection.AddNew() as IEntityObject;
                Int32 currentRow         = i;
                Int32 nOfficeColumnIndex = default(Int32);
                foreach (ColumnMapping mapping in _columnMappings)
                {
                    if (mapping.TableField != null && mapping.TableField.Name != "<Ignore>")
                    {
                        nOfficeColumnIndex = GetColumnIndex(mapping.OfficeColumn);
                        if (nOfficeColumnIndex >= 0)
                        {
                            string value = _excelDocRange[currentRow, nOfficeColumnIndex];
                            if (string.IsNullOrEmpty(value) && mapping.TableField.IsNullable)
                            {
                                newRow.Details.Properties[mapping.TableField.Name].Value = null;
                            }
                            else if (mapping.TableField.EntityType != null)
                            {
                                //Get cached results
                                if (navProperties.ContainsKey(String.Format("{0}_{1}", mapping.TableField.Name, value)))
                                {
                                    newRow.Details.Properties[mapping.TableField.Name].Value = navProperties[String.Format("{0}_{1}", mapping.TableField.Name, value)];
                                }
                            }
                            else
                            {
                                var propValue = newRow.Details.Properties[mapping.TableField.Name].Value;
                                LightSwitchHelper.TryConvertValue(mapping.TableField.TypeName, value, ref propValue);
                            }
                        }
                    }
                }
            }
        }