private async Task<bool> InitiateList() { bool retValue = false; try { retValue = await _datasource.ReloadTimeSheetProgress(selectedDateTime, _departstructure, 0, Login.UserAccount.CurProjectID, Login.UserAccount.CurModuleID); } catch (Exception e) { (new WinAppLibrary.Utilities.Helper()).ExceptionHandler(e, "InputTimeProgress _InitiateList", "There was an error to reload timesheet and component. \n Please contact administrator", "Error"); } _selectedgroup = null; SelectedGroupIndex = -1; OperationType = Lib.UI.InputTemplate.OperationType.Normal; SelectComponentCrew.RefreshData = true; return retValue; }
private async void EditTimeSheetAndProgress(Lib.UI.InputTemplate selectedgroup, Lib.UI.InputTemplate.OperationType type) { if (OperationType == Lib.UI.InputTemplate.OperationType.Normal) { _selectedgroup = selectedgroup; if (_selectedgroup != null) { SelectedGroupIndex = (_selectedgroup.DataContext as TimesheetAndProgress).DataID; _selectedgroup.EnableInputTemplate(true); OperationType = type; } else SelectedGroupIndex = -1; } else { bool excute = false; if (_selectedgroup == null) excute = true; else if (await WinAppLibrary.Utilities.Helper.YesOrNoMessage("If you don't save previous work you will lose all of them. Would you like to proceed?", "Caution!") == true) { //_datasource.RollBack(SelectedGroupIndex); _selectedgroup.EnableInputTemplate(false); excute = true; } if (excute) { _selectedgroup = selectedgroup; if (_selectedgroup != null) { SelectedGroupIndex = (_selectedgroup.DataContext as TimesheetAndProgress).DataID; _selectedgroup.EnableInputTemplate(true); OperationType = type; } else SelectedGroupIndex = -1; } } }
private async void InputTemplate_OperationClicked(object sender, object e) { var type = (Lib.UI.InputTemplate.OperationType)e; var selectedgroup = sender as Lib.UI.InputTemplate; switch (type) { case Lib.UI.InputTemplate.OperationType.Edit: EditTimeSheetAndProgress(selectedgroup, type); break; case Lib.UI.InputTemplate.OperationType.Add: OpenAddingTimeSheetAndProgress(type); break; case Lib.UI.InputTemplate.OperationType.DeleteAll: if (SelectedGroupIndex > -1) { if (await WinAppLibrary.Utilities.Helper.YesOrNoMessage("You can't recover once removing all data. Would you like to proceed?", "Caution!") == true) DeleteTimeSheetAndProgress(SelectedGroupIndex); } break; case Lib.UI.InputTemplate.OperationType.Save: if (SelectedGroupIndex > -1) { OperationType = type; SaveTimeSheetAndProgress(SelectedGroupIndex); } break; case Lib.UI.InputTemplate.OperationType.Cancel: if (selectedgroup != null) { if ((selectedgroup.DataContext as TimesheetAndProgress).DataID > 0) { _datasource.RollBack(SelectedGroupIndex); selectedgroup.EnableInputTemplate(false); SelectedGroupIndex = 0; _selectedgroup = null; } OperationType = Lib.UI.InputTemplate.OperationType.Normal; } break; } }