public void OnEdit(GridRowViewModel gridRow)
        {
            var dialog = CreateEditDialog(gridRow.GetRecord().Id);

            dialog.OverideCompletionScreenMethod = ClearChildFormAndRefresh;
            dialog.OnCancel = ClearChildForm;
            ListViewModel.LoadChildForm(dialog);
        }
        public override void AddSelectedItem(GridRowViewModel selectedRow, RecordEntryViewModelBase recordForm, string subGridReference)
        {
            var gridField          = GetEntryViewModel(recordForm).GetEnumerableFieldViewModel(subGridReference);
            var targetPropertyname = GetTargetProperty(recordForm, subGridReference).Name;
            var newRecord          = recordForm.RecordService.NewRecord(GetEnumeratedType(recordForm, subGridReference).AssemblyQualifiedName);

            var selectedRowrecord = selectedRow.GetRecord() as ObjectRecord;

            if (selectedRowrecord != null)
            {
                var newRecordType = new RecordField();
                newRecordType.Key   = (string)selectedRowrecord.Instance.GetPropertyValue(nameof(IFieldMetadata.SchemaName));
                newRecordType.Value = (string)selectedRowrecord.Instance.GetPropertyValue(nameof(IFieldMetadata.DisplayName));
                newRecord.SetField(targetPropertyname, newRecordType, recordForm.RecordService);

                //if (gridField.GridRecords.Any(g => g.GetRecordFieldFieldViewModel(targetPropertyname).Value == newRecordType))
                //    return;
                InsertNewItem(recordForm, subGridReference, newRecord);
            }
        }
예제 #3
0
        public override RecordEntryFormViewModel GetEditRowViewModel(string subGridName, RecordEntryViewModelBase parentForm, Action <IRecord> onSave, Action onCancel, GridRowViewModel gridRow)
        {
            var record = gridRow.GetRecord();

            if (!(record is ObjectRecord))
            {
                throw new NotSupportedException(string.Format("Error Expected Object Of Type {0}", typeof(ObjectRecord).Name));
            }
            var newRecord = (ObjectRecord)record;
            //need to load the existing row to this
            //lets start a dialog to add it on complete
            var mapper        = new ClassSelfMapper();
            var newObject     = mapper.Map(newRecord.Instance);
            var recordService = new ObjectRecordService(newObject, ObjectRecordService.LookupService, ObjectRecordService.OptionSetLimitedValues, ObjectRecordService, subGridName, parentForm.ApplicationController);
            var viewModel     = new ObjectEntryViewModel(
                () => onSave(new ObjectRecord(newObject)),
                onCancel,
                newObject, new FormController(recordService, new ObjectFormService(newObject, recordService), parentForm.FormController.ApplicationController), parentForm, subGridName, parentForm.OnlyValidate);

            return(viewModel);
        }
        public override void AddSelectedItem(GridRowViewModel selectedRow, RecordEntryViewModelBase recordForm, string subGridReference)
        {
            var gridField          = GetEntryViewModel(recordForm).GetEnumerableFieldViewModel(subGridReference);
            var targetPropertyname = GetTargetProperty(recordForm, subGridReference).Name;
            var newRecord          = recordForm.RecordService.NewRecord(GetEnumeratedType(recordForm, subGridReference).AssemblyQualifiedName);
            var lookup             = GetLookupService(recordForm, subGridReference).ToLookup(selectedRow.GetRecord());

            newRecord.SetField(targetPropertyname, lookup, recordForm.RecordService);
            //if (gridField.GridRecords.Any(g => g.GetLookupFieldFieldViewModel(targetPropertyname).Value == lookup))
            //    return;
            //gridField.InsertRecord(newRecord, 0);
            InsertNewItem(recordForm, subGridReference, newRecord);
        }