private async void frmRibbon_OnItemClicked(string ActionType) { if (ActionType == "Save") { if (!ValidateState()) { return; } if (otherAccountOpen && accountYears != null && accountYears.Count > 0 && Validate()) { CompanyFinanceYearClient editrowUpdate = null; foreach (var year in accountYears) { if (year._FromDate == editrow._FromDate && year._ToDate == editrow._ToDate) { editrowUpdate = year; } else if (year._Current) { year._Current = false; } } if (editrowUpdate != null) { accountYears[accountYears.IndexOf(editrowUpdate)] = editrow; accountYears.Sort(updateMainGrid.GridSorting.Compare); } else { var err3 = await api.Insert(editrow); if (err3 != ErrorCodes.Succes) { UnicontaMessageBox.Show(err3.ToString(), Uniconta.ClientTools.Localization.lookup("Error")); } else { accountYears.Add(editrow); accountYears.Sort(updateMainGrid.GridSorting.Compare); } } var err = await api.Update(accountYears); if (err != ErrorCodes.Succes) { UnicontaMessageBox.Show(err.ToString(), Uniconta.ClientTools.Localization.lookup("Error")); } else { if (updateMainGrid != null) { updateMainGrid.ItemsSource = accountYears; var err2 = await updateMainGrid.SaveData(); if (err2 == ErrorCodes.Succes) { updateMainGrid.Visibility = Visibility.Visible; CloseDockItem("FinanceYearPage2", null); } else { UnicontaMessageBox.Show(err2.ToString(), Uniconta.ClientTools.Localization.lookup("Error")); } } } } else if (Validate()) { frmRibbon_BaseActions(ActionType); } } else { frmRibbon_BaseActions(ActionType); } }