public DialogResult ShowInRecordDialog() { RecordForm.TopMost = true; RecordForm.TopLevel = true; DialogResult dialogResult = RecordForm.ShowDialog(); RecordForm.BringToFront(); return(dialogResult); }
public EnumerableFieldViewModel(string fieldName, string label, RecordEntryViewModelBase recordForm, string linkedRecordType) : base(fieldName, label, recordForm) { if (recordForm is RecordEntryFormViewModel) { LinkedRecordType = linkedRecordType; RecordForm = (RecordEntryFormViewModel)recordForm; DynamicGridViewModel = new DynamicGridViewModel(ApplicationController) { PageSize = RecordForm.GridPageSize, DisplayTotalCount = RecordForm.GridPageSize > 0, GetTotalCount = () => GetGridRecords(true).Records.Count(), ViewType = ViewType.AssociatedView, DeleteRow = !recordForm.IsReadOnly && FormService.AllowDelete(ReferenceName, GetRecordType()) ? RemoveRow : (Action <GridRowViewModel>)null, EditRow = FormService.AllowGridOpen(ReferenceName, RecordForm) ? EditRow : (Action <GridRowViewModel>)null, AddRow = !recordForm.IsReadOnly && FormService.AllowAddNew(ReferenceName, GetRecordType()) ? AddRow : (Action)null, AddMultipleRow = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel), ExpandGrid = FormService.AllowGridFullScreen(FieldName) ? LoadGridEditDialog : (Action)null, IsReadOnly = !FormService.AllowGridFieldEditEdit(FieldName) || recordForm.IsReadOnly, ParentForm = recordForm, ReferenceName = ReferenceName, RecordType = linkedRecordType, RecordService = recordForm.RecordService, GetGridRecords = GetGridRecords, LoadRecordsAsync = true, FormController = recordForm.FormController, OnReloading = () => { _isLoaded = false; }, LoadedCallback = () => { _isLoaded = true; RecordForm.OnSectionLoaded(); }, OnlyValidate = recordForm.OnlyValidate, MaxHeight = 600, LoadDialog = (d) => { RecordEntryViewModel.LoadChildForm(d); }, RemoveParentDialog = () => { RecordEntryViewModel.ClearChildForms(); } }; DynamicGridViewModel.AddMultipleRow = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel); DynamicGridViewModel.ExpandGrid = FormService.AllowGridFullScreen(FieldName) ? LoadGridEditDialog : (Action)null; } else { var bulkAddFunction = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel); if (bulkAddFunction != null) { BulkAddButton = new XrmButtonViewModel("BULKADD", "BULK ADD", bulkAddFunction, ApplicationController); } EditAction = !RecordEntryViewModel.IsReadOnly && FormService.AllowNestedGridEdit(RecordEntryViewModel.ParentFormReference, FieldName) ? LoadGridEditDialog : (Action)null; } }
protected override IsValidResponse ValidateExtention() { var record = RecordForm.GetRecord(); var response = new IsValidResponse(); if (!PropertyValidator.IsValid(record.GetField(ChangedField.ReferenceName))) { response.AddInvalidReason(PropertyValidator.GetErrorMessage(RecordForm.RecordService.GetFieldMetadata(ChangedField.ReferenceName, RecordForm.GetRecordType()).DisplayName)); } return(response); }
public void EditRecord(Record aRecord) { RecordForm recordForm = new RecordForm(aRecord); recordForm.StartPosition = FormStartPosition.CenterParent; recordForm.ShowDialog(); if (recordForm.DialogResult == DialogResult.OK) { this.RecordModel.Edit(recordForm.CurRecord); } }
public EnumerableFieldViewModel(string fieldName, string label, RecordEntryViewModelBase recordForm, string linkedRecordType) : base(fieldName, label, recordForm) { if (recordForm is RecordEntryFormViewModel) { RecordForm = (RecordEntryFormViewModel)recordForm; LinkedRecordType = linkedRecordType; DynamicGridViewModel = new DynamicGridViewModel(ApplicationController) { PageSize = RecordForm.GridPageSize, ViewType = ViewType.AssociatedView, DeleteRow = !recordForm.IsReadOnly && FormService.AllowDelete(ReferenceName, GetRecordType()) ? RemoveRow :(Action <GridRowViewModel>)null, EditRow = EditRow, AddRow = !recordForm.IsReadOnly && FormService.AllowAddNew(ReferenceName, GetRecordType()) ? AddRow : (Action)null, AddMultipleRow = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel), IsReadOnly = recordForm.IsReadOnly, ParentForm = recordForm, ReferenceName = ReferenceName, RecordType = linkedRecordType, RecordService = recordForm.RecordService, GetGridRecords = GetGridRecords, LoadRecordsAsync = true, FormController = recordForm.FormController, OnReloading = () => { _isLoaded = false; }, LoadedCallback = () => { _isLoaded = true; RecordForm.OnSectionLoaded(); }, OnlyValidate = recordForm.OnlyValidate, MaxHeight = 600, LoadDialog = (d) => { RecordEntryViewModel.LoadChildForm(d); } }; DynamicGridViewModel.AddMultipleRow = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel); } else { var bulkAddFunction = FormService.GetBulkAddFunctionFor(ReferenceName, RecordEntryViewModel); if (bulkAddFunction != null) { BulkAddButton = new XrmButtonViewModel("BULKADD", "BULK ADD", bulkAddFunction, ApplicationController); } } }
internal override bool Validate() { var isValid = true; foreach (var recordField in Fields) { if (RecordForm.OnlyValidate != null && (!RecordForm.OnlyValidate.ContainsKey(RecordForm.GetRecordType()) || !RecordForm.OnlyValidate[RecordForm.GetRecordType()].Contains(recordField.FieldName))) { continue; } if (recordField.IsVisible && !recordField.Validate()) { isValid = false; } } return(isValid); }