public void RecreateGrid(bool resetQueryRun = true) { if (RecordType != null) { DynamicGridViewModel = new DynamicGridViewModel(ApplicationController) { PageSize = StandardPageSize, ViewType = ViewType.MainApplicationView, RecordService = RecordService, RecordType = RecordType, IsReadOnly = true, FormController = new FormController(RecordService, null, ApplicationController), GetGridRecords = (b) => GetGridRecords(b), DisplayTotalCount = false, GetTotalCount = GetGridTotalCount, MultiSelect = true, GridLoaded = false, FieldMetadata = ExplicitlySelectedColumns }; var customFunctionList = new List <CustomGridFunction>() { new CustomGridFunction("QUERY", "Run Query", QuickFind), new CustomGridFunction("BACKTOQUERY", "Back To Query", (g) => { ResetToQueryEntry(); }, (g) => !IsQuickFind && QueryRun), new CustomGridFunction("EDITCOLUMNS", "Edit Columns", (g) => LoadColumnEdit(), (g) => DynamicGridViewModel != null), new CustomGridFunction("DISPLAYTOTALS", (g) => g.DisplayTotalCount ? "Hide Totals" : "Display Totals", (g) => { g.DisplayTotalCount = !g.DisplayTotalCount; g.ReloadGrid(); }, (g) => DynamicGridViewModel != null) }; if (FormService != null && AllowCrud) { DynamicGridViewModel.EditRow = (g) => { var formMetadata = FormService.GetFormMetadata(RecordType, RecordService); var formController = new FormController(RecordService, FormService, ApplicationController); var selectedRow = g; if (selectedRow != null) { Action onSave = () => { ClearChildForm(); ClearNotInIds(); DynamicGridViewModel.ReloadGrid(); }; var record = selectedRow.Record; var createOrUpdateRecord = RecordService.Get(record.Type, record.Id); new[] { createOrUpdateRecord }.PopulateEmptyLookups(RecordService, null); var newForm = new CreateOrUpdateViewModel(createOrUpdateRecord, formController, onSave, ClearChildForm); ClearNotInIds(); LoadChildForm(newForm); } }; DynamicGridViewModel.EditRowNew = (g) => { var formMetadata = FormService.GetFormMetadata(RecordType, RecordService); var formController = new FormController(RecordService, FormService, ApplicationController); var selectedRow = g; if (selectedRow != null) { var record = selectedRow.Record; CreateOrUpdateViewModel vmRef = null; var createOrUpdateRecord = RecordService.Get(record.Type, record.Id); new[] { createOrUpdateRecord }.PopulateEmptyLookups(RecordService, null); vmRef = new CreateOrUpdateViewModel(createOrUpdateRecord, formController, () => { vmRef.ValidationPrompt = "Changes Have Been Saved"; ClearNotInIds(); DynamicGridViewModel.ReloadGrid(); }, () => ApplicationController.Remove(vmRef), cancelButtonLabel: "Close"); ApplicationController.NavigateTo(vmRef); //LoadChildForm(newForm); } }; DynamicGridViewModel.AddRow = () => { var formMetadata = FormService.GetFormMetadata(RecordType, RecordService); var formController = new FormController(RecordService, FormService, ApplicationController); Action onSave = () => { ClearChildForm(); ClearNotInIds(); DynamicGridViewModel.ReloadGrid(); }; var newForm = new CreateOrUpdateViewModel(RecordService.NewRecord(RecordType), formController, onSave, ClearChildForm, explicitIsCreate: true); LoadChildForm(newForm); }; } customFunctionList.Add(new CustomGridFunction("DOWNLOAD", "Download", new[] { new CustomGridFunction("DOWNLOADEXCEL", "Excel", (g) => g.DownloadExcel(), (g) => g.GridRecords != null && g.GridRecords.Any()), new CustomGridFunction("DOWNLOADCSV", "CSV", (g) => g.DownloadCsv(), (g) => g.GridRecords != null && g.GridRecords.Any()) })); if (CustomFunctions != null) { foreach (var item in CustomFunctions) { customFunctionList.Add(item); } } DynamicGridViewModel.AddGridButtons(customFunctionList); if (LoadInitially) { DynamicGridViewModel.ReloadGrid(); } RefreshConditionButtons(); RefreshConditionButtons(isNotIn: true); if (resetQueryRun) { QueryRun = false; } } }
public void RecreateGrid() { if (RecordType != null) { DynamicGridViewModel = new DynamicGridViewModel(ApplicationController) { PageSize = StandardPageSize, ViewType = ViewType.MainApplicationView, RecordService = RecordService, RecordType = RecordType, IsReadOnly = true, FormController = new FormController(RecordService, null, ApplicationController), GetGridRecords = GetGridRecords, MultiSelect = true, GridLoaded = false }; var customFunctionList = new List <CustomGridFunction>() { new CustomGridFunction("QUERY", "Run Query", QuickFind) }; if (FormService != null) { DynamicGridViewModel.EditRow = (g) => { var formMetadata = FormService.GetFormMetadata(RecordType, RecordService); var formController = new FormController(this.RecordService, FormService, ApplicationController); var selectedRow = g; if (selectedRow != null) { Action onSave = () => { ClearChildForm(); DynamicGridViewModel.ReloadGrid(); }; var record = selectedRow.Record; var newForm = new CreateOrUpdateViewModel(RecordService.Get(record.Type, record.Id), formController, onSave, ClearChildForm); LoadChildForm(newForm); } }; DynamicGridViewModel.AddRow = () => { var formMetadata = FormService.GetFormMetadata(RecordType, RecordService); var formController = new FormController(RecordService, FormService, ApplicationController); Action onSave = () => { ClearChildForm(); DynamicGridViewModel.ReloadGrid(); }; var newForm = new CreateOrUpdateViewModel(RecordService.NewRecord(RecordType), formController, onSave, ClearChildForm, explicitIsCreate: true); LoadChildForm(newForm); }; } customFunctionList.Add(new CustomGridFunction("CSV", "Download CSV", (g) => g.DownloadCsv(), (g) => g.GridRecords != null && g.GridRecords.Any())); if (CustomFunctions != null) { foreach (var item in CustomFunctions) { customFunctionList.Add(item); } } DynamicGridViewModel.AddGridButtons(customFunctionList); if (LoadInitially) { DynamicGridViewModel.ReloadGrid(); } RefreshConditionButtons(); } }
private void RecreateGrid() { if (DynamicGridViewModel != null) { Controller.RemoveFromUi(DynamicGridViewModel); } try { //okay lets somehow load the results for this row into a crud dialog view //which loads a dynamic grid - similar to query but no query - DynamicGridViewModel = new DynamicGridViewModel(ApplicationController) { PageSize = 25, RecordService = RecordService, RecordType = SummaryItem.RecordTypeSchemaName, IsReadOnly = true, FormController = new FormController(RecordService, null, ApplicationController), GetGridRecords = (b) => { return(DynamicGridViewModel.GetGridRecord(GetAllTheseRecords(), b)); }, DisplayTotalCount = true, GetTotalCount = () => GetAllTheseRecords().Count(), MultiSelect = true, GridLoaded = false, FieldMetadata = ExplicitlySelectedColumns }; var customFunctionList = new List <CustomGridFunction>() { new CustomGridFunction("BACKTOSUMMARY", "Back To Summary", Remove), new CustomGridFunction("EDITCOLUMNS", "Edit Columns", (g) => LoadColumnEdit(), (g) => DynamicGridViewModel != null), new CustomGridFunction("DOWNLOAD", "Download", new[] { new CustomGridFunction("DOWNLOADEXCEL", "Excel", (g) => g.DownloadExcel(), (g) => g.GridRecords != null && g.GridRecords.Any()), new CustomGridFunction("DOWNLOADCSV", "CSV", (g) => g.DownloadCsv(), (g) => g.GridRecords != null && g.GridRecords.Any()) }), new CustomGridFunction("REPLACE", "Bulk Replace", new [] { new CustomGridFunction("BULKREPLACESELECTED", "Selected Only", (g) => { TriggerBulkReplace(true); }, (g) => g.SelectedRows.Any()), new CustomGridFunction("BULKREPLACEALL", "All Results", (g) => { TriggerBulkReplace(false); }, (g) => g.GridRecords != null && g.GridRecords.Any()), }) }; var formService = RecordService.GetFormService() as FormServiceBase; if (formService != null) { DynamicGridViewModel.EditRow = (g) => { var formMetadata = formService.GetFormMetadata(SummaryItem.RecordTypeSchemaName, RecordService); var formController = new FormController(RecordService, formService, ApplicationController); var selectedRow = g; if (selectedRow != null) { Action onSave = () => { ClearChildForm(); _cachedRecords = null; DynamicGridViewModel.ReloadGrid(); }; var record = selectedRow.Record; var newForm = new CreateOrUpdateViewModel(RecordService.Get(record.Type, record.Id), formController, onSave, ClearChildForm); LoadChildForm(newForm); } }; } DynamicGridViewModel.AddGridButtons(customFunctionList); DynamicGridViewModel.ReloadGrid(); Controller.LoadToUi(DynamicGridViewModel); } catch (Exception ex) { ApplicationController.ThrowException(ex); } }
/// <summary> /// Entry Main point /// </summary> /// <param name="args"></param> static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json"); Configuration = builder.Build(); IRecordData _data = new RecordData(); RecordService _service = new RecordService(_data); while (true) { Console.WriteLine("Please select Your Options!"); Console.WriteLine("Hello , you can choose 1-3 to continue with default data."); Console.WriteLine("If you want to upload your own data then visit optoin 4"); Console.WriteLine("Press 1 for sorting by gender (females before males) then by last name ascending."); Console.WriteLine("Press 2 for sorting by birth date, ascending."); Console.WriteLine("Press 3 for sorting by last name, descending."); Console.WriteLine("Press 4 for uploading new records"); Console.WriteLine("\n"); ConsoleKeyInfo result = Console.ReadKey(); Console.WriteLine("\n"); IEnumerable <RecordDto> records = _service.Get(); //RecordData.Current.Records.ToList(); switch (result.KeyChar) { case '1': { records = _service.Get().OrderBy(a => a.Gender).ThenBy(a => a.LastName).ToList(); break; } case '2': { records = _service.Get().AsQueryable().OrderBy(a => a.DOB).ToList(); break; } case '3': { records = _service.Get().AsQueryable().OrderByDescending(a => a.LastName).ToList(); break; } case '4': { UploadFiles(); records = _service.Get().ToList(); break; } default: Console.WriteLine("Wrong Selection , Display Record by FirstName Ascending"); records = RecordData.Current.Records.AsQueryable().OrderBy(a => a.FirstName).ToList(); break; } Display(records); Console.WriteLine("Going for another round"); Console.WriteLine("\n"); } }