private void gvPAYERelief_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) { if (e.Row == null) { return; } SavingResult res = null; PAYEReliefeViewModel Row = (PAYEReliefeViewModel)e.Row; if (dePAYEReliefWED.EditValue == null) { res = new SavingResult(); res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Please enter Effective date."; } else { res = PAYEReliefDALObj.SaveNewRecord(Row, (DateTime)dePAYEReliefWED.EditValue); } Row.SavingError = null; if (res.ExecutionResult == eExecutionResult.CommitedSucessfuly) { var newRow = PAYEReliefDALObj.GetViewModelByID((int)res.PrimeKeyValue); if (newRow != null) { int newRowIndex = PAYEReliefeViewModelBindingSource.IndexOf(Row); //Row = newRow; PAYEReliefeViewModelBindingSource[newRowIndex] = newRow; } else { PAYEReliefeViewModelBindingSource.RemoveAt(gvPAYERelief.GetFocusedDataSourceRowIndex()); } } else if (res.ExecutionResult == eExecutionResult.ErrorWhileExecuting) { Row.SavingError = "Error while saving.\r\n" + res.Exception.Message; } else if (res.ExecutionResult == eExecutionResult.ValidationError) { Row.SavingError = "Validation Errors.\r\n" + res.ValidationError; } else if (!String.IsNullOrWhiteSpace(res.MessageAfterSave)) { Row.SavingError = "Please note:\r\n" + res.MessageAfterSave; } }
private void repositoryItemButtonEditRemovePAYERelief_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { PAYEReliefeViewModel Row = (PAYEReliefeViewModel)gvPAYERelief.GetFocusedRow(); if (Row == null) { return; } var resValidation = PAYEReliefDALObj.ValidateBeforeDelete(Row.PAYEReliefID); if (!resValidation.IsValidForDelete) { Row.SavingError = resValidation.ValidationMessage; return; } var res = PAYEReliefDALObj.DeleteRecord(Row.PAYEReliefID); if (res.ExecutionResult == eExecutionResult.CommitedSucessfuly) { PAYEReliefeViewModelBindingSource.RemoveAt(gvPAYERelief.GetFocusedDataSourceRowIndex()); gvPAYERelief.RefreshData(); } if (res.ExecutionResult == eExecutionResult.ErrorWhileExecuting) { Row.SavingError = "Error while saving.\r\n" + res.Exception.Message; } else if (res.ExecutionResult == eExecutionResult.ValidationError) { Row.SavingError = "Validation Errors.\r\n" + res.ValidationError; } else if (!String.IsNullOrWhiteSpace(res.MessageAfterSave)) { Row.SavingError = "Please note:\r\n" + res.MessageAfterSave; } }