private async Task SetSumPay() { FormattedString formatted = new FormattedString(); // string sumText = string.IsNullOrEmpty(EntrySum.Text) ? "0" : EntrySum.Text;//.Replace('.',','); decimal totalSum = 0; if (sumText.Equals("-")) { totalSum = 0; } else { try { var sumWithDot = sumText.Replace(',', '.'); var correctSum = decimal.TryParse(sumWithDot, NumberStyles.Any, CultureInfo.InvariantCulture, out totalSum); if (!correctSum) { Analytics.TrackEvent($"Оплата по ЛС. ошибка при конвертации в decimal числа {sumText}"); Device.BeginInvokeOnMainThread(async() => await DisplayAlert(AppResources.ErrorNumberSumm, null, "OK")); return; } } catch (Exception ex) { Analytics.TrackEvent($"Оплата по ЛС. ошибка при конвертации в decimal числа {sumText}"); Crashes.TrackError(ex); throw; } } // if (isComission) // { if (SwitchInsurance.IsToggled && SwitchInsurance.IsVisible) { //totalSum += account.InsuranceSum; } ComissionModel result = await server.GetSumWithComission(totalSum.ToString()); if (result.Error == null && !result.Comission.Equals("0")) { isComission = true; LabelCommision.Text = $"{AppResources.Commision} " + result.Comission + $" {AppResources.Currency}"; LabelCommision.IsVisible = !result.HideComissionInfo; totalSum = result.TotalSum + (SwitchInsurance.IsToggled ? account.InsuranceSum : 0); if (result.Comission == 0) { LabelCommision.Text = AppResources.NotComissions; } } // } await Task.Delay(TimeSpan.FromMilliseconds(100)); formatted.Spans.Add(new Span { Text = $"{AppResources.Total}: ", FontSize = 17, TextColor = Color.Black }); formatted.Spans.Add(new Span { Text = totalSum.ToString(), FontSize = 20, TextColor = (Color)Application.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold }); formatted.Spans.Add(new Span { Text = $" {AppResources.Currency}", FontSize = 15, TextColor = Color.Gray }); LabelTotal.FormattedText = formatted; }
async void SetPays() { EntrySum.Text = account.Sum.ToString(); FormattedString formatted = new FormattedString(); ComissionModel result = await server.GetSumWithComission(account.Sum.ToString()); string totalSum = EntrySum.Text; if (result.Error == null && result.Comission != 0) { isComission = true; LabelCommision.Text = $"{AppResources.Commision} " + result.Comission + $" {AppResources.Currency}"; LabelCommision.IsVisible = !result.HideComissionInfo; totalSum = result.TotalSum.ToString(); if (result.Comission == 0) { LabelCommision.Text = AppResources.NotComissions; } } LayoutInsurance.IsVisible = account.InsuranceSum != 0; InsuranceDoc.IsVisible = account.InsuranceSum != 0; SwitchInsurance.IsToggled = account.InsuranceSum != 0; LabelInsurance.Text = AppResources.InsuranceText.Replace("111", account.InsuranceSum.ToString()); formatted.Spans.Add(new Span { Text = $"{AppResources.Total}: ", FontSize = 17, TextColor = Color.Black }); formatted.Spans.Add(new Span { Text = totalSum, FontSize = 20, TextColor = (Color)Application.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold }); formatted.Spans.Add(new Span { Text = $" {AppResources.Currency}", FontSize = 15, TextColor = Color.FromHex("#777777") }); LabelTotal.FormattedText = formatted; String[] month = account.DebtActualDate.Split('.'); formatted = new FormattedString(); formatted.Spans.Add(new Span { Text = $"{AppResources.PaymentOf} ", FontSize = 12, TextColor = Color.Black }); formatted.Spans.Add(new Span { Text = Settings.months[Int32.Parse(month[1]) - 1] + " " + month[2], FontSize = 12, TextColor = Color.Black, FontAttributes = FontAttributes.Bold }); LabelMonth.FormattedText = formatted; Picker.Title = account.Ident; }