[#43] AreaComAdminWindow: Do not use Context from ContextWindow any more
This commit is contained in:
		| @@ -576,7 +576,7 @@ namespace Elwig.Helpers { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static ValidationResult CheckFbNr(TextBox input, bool required, AppDbContext ctx, AreaCom? c) { |         public static ValidationResult CheckFbNr(TextBox input, bool required, AreaCom? c) { | ||||||
|             var res = CheckInteger(input, required); |             var res = CheckInteger(input, required); | ||||||
|             if (!res.IsValid) { |             if (!res.IsValid) { | ||||||
|                 return res; |                 return res; | ||||||
| @@ -584,6 +584,7 @@ namespace Elwig.Helpers { | |||||||
|                 return new(true, null); |                 return new(true, null); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             using var ctx = new AppDbContext(); | ||||||
|             int nr = int.Parse(input.Text); |             int nr = int.Parse(input.Text); | ||||||
|             if (nr != c?.FbNr && ctx.FbNrExists(nr).GetAwaiter().GetResult()) { |             if (nr != c?.FbNr && ctx.FbNrExists(nr).GetAwaiter().GetResult()) { | ||||||
|                 return new(false, "Flächenbindungsnummer wird bereits verwendet"); |                 return new(false, "Flächenbindungsnummer wird bereits verwendet"); | ||||||
|   | |||||||
| @@ -7,7 +7,6 @@ using Elwig.Models.Entities; | |||||||
| using System; | using System; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using Microsoft.EntityFrameworkCore.ChangeTracking; |  | ||||||
| using Xceed.Wpf.Toolkit.Primitives; | using Xceed.Wpf.Toolkit.Primitives; | ||||||
|  |  | ||||||
| namespace Elwig.Windows { | namespace Elwig.Windows { | ||||||
| @@ -20,7 +19,8 @@ namespace Elwig.Windows { | |||||||
|  |  | ||||||
|         public AreaComAdminWindow(int mgnr) { |         public AreaComAdminWindow(int mgnr) { | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
|             Member = Context.Members.Find(mgnr) ?? throw new ArgumentException("MgNr argument has invalid value"); |             using var ctx = new AppDbContext(); | ||||||
|  |             Member = ctx.Members.Find(mgnr) ?? throw new ArgumentException("MgNr argument has invalid value"); | ||||||
|             Title = $"Flächenbindungen - {Member.AdministrativeName} - Elwig"; |             Title = $"Flächenbindungen - {Member.AdministrativeName} - Elwig"; | ||||||
|             ExemptInputs = [ |             ExemptInputs = [ | ||||||
|                 MgNrInput, AreaCommitmentList, NewAreaCommitmentButton,  |                 MgNrInput, AreaCommitmentList, NewAreaCommitmentButton,  | ||||||
| @@ -39,13 +39,16 @@ namespace Elwig.Windows { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         private async Task RefreshAreaCommitmentList() { |         private async Task RefreshAreaCommitmentList() { | ||||||
|             await Context.AreaCommitments.LoadAsync(); |  | ||||||
|             await RefreshAreaCommitmentListQuery(); |             await RefreshAreaCommitmentListQuery(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private async Task RefreshAreaCommitmentListQuery(bool updateSort = false) { |         private async Task RefreshAreaCommitmentListQuery(bool updateSort = false) { | ||||||
|             var (_, areaComQuery, filter) = await GetFilters(); |             using var ctx = new AppDbContext(); | ||||||
|             var areaComs = await areaComQuery.ToListAsync(); |             var (_, areaComQuery, filter) = await GetFilters(ctx); | ||||||
|  |             var areaComs = await areaComQuery | ||||||
|  |                 .Include(a => a.Kg.AtKg) | ||||||
|  |                 .Include(a => a.Rd!.Kg.AtKg) | ||||||
|  |                 .ToListAsync(); | ||||||
|  |  | ||||||
|             if (filter.Count > 0 && areaComs.Count > 0) { |             if (filter.Count > 0 && areaComs.Count > 0) { | ||||||
|                 var dict = areaComs.AsParallel() |                 var dict = areaComs.AsParallel() | ||||||
| @@ -75,9 +78,9 @@ namespace Elwig.Windows { | |||||||
|             StatusContracts.ToolTip = $"Vertragsarten: {groups.Count}\n" + string.Join($"\n", groups.Select(g => $"{g.Key}: {g.Item2:N0} m²")); |             StatusContracts.ToolTip = $"Vertragsarten: {groups.Count}\n" + string.Join($"\n", groups.Select(g => $"{g.Key}: {g.Item2:N0} m²")); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private async Task<(List<string>, IQueryable<AreaCom>, List<string>)> GetFilters() { |         private async Task<(List<string>, IQueryable<AreaCom>, List<string>)> GetFilters(AppDbContext ctx) { | ||||||
|             List<string> filterNames = []; |             List<string> filterNames = []; | ||||||
|             IQueryable<AreaCom> areaComQuery = Context.AreaCommitments.Where(a => a.MgNr == Member.MgNr).OrderBy(a => a.FbNr); |             IQueryable<AreaCom> areaComQuery = ctx.AreaCommitments.Where(a => a.MgNr == Member.MgNr).OrderBy(a => a.FbNr); | ||||||
|             if (ActiveAreaCommitmentInput.IsChecked == true) { |             if (ActiveAreaCommitmentInput.IsChecked == true) { | ||||||
|                 areaComQuery = areaComQuery.Where(a => (a.YearFrom <= Utils.CurrentYear) && (a.YearTo == null || a.YearTo >= Utils.CurrentYear)); |                 areaComQuery = areaComQuery.Where(a => (a.YearFrom <= Utils.CurrentYear) && (a.YearTo == null || a.YearTo >= Utils.CurrentYear)); | ||||||
|                 filterNames.Add("aktiv"); |                 filterNames.Add("aktiv"); | ||||||
| @@ -90,8 +93,8 @@ namespace Elwig.Windows { | |||||||
|  |  | ||||||
|             var filter = TextFilter.ToList(); |             var filter = TextFilter.ToList(); | ||||||
|             if (filter.Count > 0) { |             if (filter.Count > 0) { | ||||||
|                 var var = await Context.WineVarieties.ToDictionaryAsync(v => v.SortId, v => v); |                 var var = await ctx.WineVarieties.ToDictionaryAsync(v => v.SortId, v => v); | ||||||
|                 var attr = await Context.WineAttributes.ToDictionaryAsync(a => a.Name.ToLower().Split(" ")[0], a => a); |                 var attr = await ctx.WineAttributes.ToDictionaryAsync(a => a.Name.ToLower().Split(" ")[0], a => a); | ||||||
|  |  | ||||||
|                 for (int i = 0; i < filter.Count; i++) { |                 for (int i = 0; i < filter.Count; i++) { | ||||||
|                     var e = filter[i]; |                     var e = filter[i]; | ||||||
| @@ -150,13 +153,21 @@ namespace Elwig.Windows { | |||||||
|             YearFromInput.Text = a.YearFrom.ToString(); |             YearFromInput.Text = a.YearFrom.ToString(); | ||||||
|             YearToInput.Text = a.YearTo.ToString(); |             YearToInput.Text = a.YearTo.ToString(); | ||||||
|  |  | ||||||
|             KgInput.SelectedItem = a.Kg.AtKg; |             ControlUtils.SelectComboBoxItem(KgInput, k => (k as AT_Kg)?.KgNr, a.KgNr); | ||||||
|             RdInput.SelectedItem = a.Rd ?? RdInput.Items[0]; |             if (a.RdNr != null) { | ||||||
|  |                 ControlUtils.SelectComboBoxItem(RdInput, r => (r as WbRd)?.RdNr, a.RdNr); | ||||||
|  |             } else { | ||||||
|  |                 RdInput.SelectedIndex = 0; | ||||||
|  |             } | ||||||
|             GstNrInput.Text = a.GstNr; |             GstNrInput.Text = a.GstNr; | ||||||
|             AreaInput.Text = a.Area.ToString(); |             AreaInput.Text = a.Area.ToString(); | ||||||
|  |  | ||||||
|             AreaComTypeInput.SelectedItem = a.AreaComType; |             ControlUtils.SelectComboBoxItem(AreaComTypeInput, t => (t as AreaComType)?.VtrgId, a.VtrgId); | ||||||
|             WineCultivationInput.SelectedItem = a.WineCult ?? WineCultivationInput.Items[0]; |             if (a.CultId != null) { | ||||||
|  |                 ControlUtils.SelectComboBoxItem(WineCultivationInput, c => (c as WineCult)?.CultId, a.CultId); | ||||||
|  |             } else { | ||||||
|  |                 WineCultivationInput.SelectedIndex = 0; | ||||||
|  |             } | ||||||
|  |  | ||||||
|             CommentInput.Text = a.Comment; |             CommentInput.Text = a.Comment; | ||||||
|  |  | ||||||
| @@ -167,10 +178,12 @@ namespace Elwig.Windows { | |||||||
|             ClearOriginalValues(); |             ClearOriginalValues(); | ||||||
|             ClearDefaultValues(); |             ClearDefaultValues(); | ||||||
|  |  | ||||||
|             FbNrInput.Text = (await Context.NextFbNr()).ToString(); |             using (var ctx = new AppDbContext()) { | ||||||
|             MgNrInput.Text = Member.MgNr.ToString(); |                 FbNrInput.Text = (await ctx.NextFbNr()).ToString(); | ||||||
|             YearFromInput.Text = DateTime.Now.Year.ToString(); |                 MgNrInput.Text = Member.MgNr.ToString(); | ||||||
|             WineCultivationInput.SelectedIndex = 0; |                 YearFromInput.Text = DateTime.Now.Year.ToString(); | ||||||
|  |                 WineCultivationInput.SelectedIndex = 0; | ||||||
|  |             } | ||||||
|  |  | ||||||
|             SetDefaultValue(FbNrInput); |             SetDefaultValue(FbNrInput); | ||||||
|             ValidateRequiredInputs(); |             ValidateRequiredInputs(); | ||||||
| @@ -178,9 +191,20 @@ namespace Elwig.Windows { | |||||||
|  |  | ||||||
|         protected override async Task OnRenewContext() { |         protected override async Task OnRenewContext() { | ||||||
|             await base.OnRenewContext(); |             await base.OnRenewContext(); | ||||||
|             ControlUtils.RenewItemsSource(KgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr); |             using var ctx = new AppDbContext(); | ||||||
|             ControlUtils.RenewItemsSource(AreaComTypeInput, await Context.AreaCommitmentTypes.OrderBy(v => v.VtrgId).ToListAsync(), i => (i as AreaComType)?.VtrgId); |             ControlUtils.RenewItemsSource(KgInput, await ctx.WbKgs | ||||||
|             var cultList = await Context.WineCultivations.OrderBy(c => c.Name).Cast<object>().ToListAsync(); |                 .Include(k => k.AtKg.WbKg!.Rds) | ||||||
|  |                 .Select(k => k.AtKg) | ||||||
|  |                 .OrderBy(k => k.Name) | ||||||
|  |                 .ToListAsync(), i => (i as AT_Kg)?.KgNr); | ||||||
|  |             ControlUtils.RenewItemsSource(AreaComTypeInput, await ctx.AreaCommitmentTypes | ||||||
|  |                 .Include(c => c.WineVar) | ||||||
|  |                 .Include(c => c.WineAttr) | ||||||
|  |                 .OrderBy(v => v.VtrgId) | ||||||
|  |                 .ToListAsync(), i => (i as AreaComType)?.VtrgId); | ||||||
|  |             var cultList = await ctx.WineCultivations | ||||||
|  |                 .OrderBy(c => c.Name) | ||||||
|  |                 .Cast<object>().ToListAsync(); | ||||||
|             cultList.Insert(0, new NullItem()); |             cultList.Insert(0, new NullItem()); | ||||||
|             ControlUtils.RenewItemsSource(WineCultivationInput, cultList, i => (i as WineCult)?.CultId, null, ControlUtils.RenewSourceDefault.First); |             ControlUtils.RenewItemsSource(WineCultivationInput, cultList, i => (i as WineCult)?.CultId, null, ControlUtils.RenewSourceDefault.First); | ||||||
|             await RefreshAreaCommitmentList(); |             await RefreshAreaCommitmentList(); | ||||||
| @@ -218,71 +242,65 @@ namespace Elwig.Windows { | |||||||
|                 $"Soll die Flächenbindung {a.GstNr} ({a.Area} m²) wirklich unwiderruflich gelöscht werden?", |                 $"Soll die Flächenbindung {a.GstNr} ({a.Area} m²) wirklich unwiderruflich gelöscht werden?", | ||||||
|                 "Flächenbindung löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No); |                 "Flächenbindung löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No); | ||||||
|             if (r == MessageBoxResult.Yes) { |             if (r == MessageBoxResult.Yes) { | ||||||
|                 Context.Remove(a); |                 using var ctx = new AppDbContext(); | ||||||
|                 Context.SaveChanges(); |                 ctx.Remove(a); | ||||||
|  |                 await ctx.SaveChangesAsync(); | ||||||
|                 await RefreshAreaCommitmentList(); |                 await RefreshAreaCommitmentList(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private async Task<AreaCom> UpdateAreaCom(AreaCom a) { |         private async Task<int> UpdateAreaCom(int? oldFbNr) { | ||||||
|  |             using var ctx = new AppDbContext(); | ||||||
|             int newFbNr = int.Parse(FbNrInput.Text); |             int newFbNr = int.Parse(FbNrInput.Text); | ||||||
|             a.MgNr = int.Parse(MgNrInput.Text); |  | ||||||
|             a.YearFrom = int.Parse(YearFromInput.Text); |  | ||||||
|             a.YearTo = (YearToInput.Text == "") ? null : int.Parse(YearToInput.Text); |  | ||||||
|             a.KgNr = ((AT_Kg)KgInput.SelectedItem).KgNr; |  | ||||||
|             a.RdNr = RdInput.SelectedItem.GetType() == typeof(NullItem) ? null : ((WbRd)RdInput.SelectedItem).RdNr; |  | ||||||
|             a.GstNr = GstNrInput.Text; |  | ||||||
|             a.Area = int.Parse(AreaInput.Text); |  | ||||||
|             a.VtrgId = (AreaComTypeInput.SelectedItem as AreaComType)!.VtrgId; |  | ||||||
|             a.CultId = (WineCultivationInput.SelectedItem as WineCult)?.CultId; |  | ||||||
|             a.Comment = (CommentInput.Text == "") ? null : CommentInput.Text; |  | ||||||
|  |  | ||||||
|             EntityEntry<AreaCom>? tr = null; |             var a = new AreaCom { | ||||||
|  |                 FbNr = oldFbNr ?? newFbNr, | ||||||
|  |                 MgNr = int.Parse(MgNrInput.Text), | ||||||
|  |                 YearFrom = int.Parse(YearFromInput.Text), | ||||||
|  |                 YearTo = (YearToInput.Text == "") ? null : int.Parse(YearToInput.Text), | ||||||
|  |                 KgNr = ((AT_Kg)KgInput.SelectedItem).KgNr, | ||||||
|  |                 RdNr = (RdInput.SelectedItem as WbRd)?.RdNr, | ||||||
|  |                 GstNr = GstNrInput.Text.Trim(), | ||||||
|  |                 Area = int.Parse(AreaInput.Text), | ||||||
|  |                 VtrgId = (AreaComTypeInput.SelectedItem as AreaComType)!.VtrgId, | ||||||
|  |                 CultId = (WineCultivationInput.SelectedItem as WineCult)?.CultId, | ||||||
|  |                 Comment = (CommentInput.Text == "") ? null : CommentInput.Text.Trim(), | ||||||
|  |             }; | ||||||
|  |  | ||||||
|  |             if (RdInput.SelectedItem is WbRd rd) { | ||||||
|  |                 if (rd.RdNr == 0) { | ||||||
|  |                     rd.RdNr = await ctx.NextRdNr(a.KgNr); | ||||||
|  |                     a.RdNr = rd.RdNr; | ||||||
|  |                     ctx.Add(rd); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             if (oldFbNr != null) { | ||||||
|  |                 ctx.Update(a); | ||||||
|  |             } else { | ||||||
|  |                 ctx.Add(a); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             await ctx.SaveChangesAsync(); | ||||||
|  |  | ||||||
|  |             if (newFbNr != a.FbNr) { | ||||||
|  |                 await ctx.Database.ExecuteSqlAsync($"UPDATE area_commitment SET fbnr = {newFbNr} WHERE fbnr = {oldFbNr}"); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             await App.HintContextChange(); | ||||||
|  |  | ||||||
|  |             return newFbNr; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private async void AreaCommitmentSaveButton_Click(object sender, RoutedEventArgs evt) { | ||||||
|  |             int? fbnr = null; | ||||||
|             try { |             try { | ||||||
|                 if (RdInput.SelectedItem is WbRd wbRd) { |                 fbnr = await UpdateAreaCom((AreaCommitmentList.SelectedItem as AreaCom)?.FbNr); | ||||||
|                     a.RdNr = wbRd.RdNr; |  | ||||||
|                     var e = Context.Entry(wbRd); |  | ||||||
|                     if (e.State == EntityState.Detached) { |  | ||||||
|                         await Context.AddAsync(wbRd); |  | ||||||
|                     } |  | ||||||
|                 } else { |  | ||||||
|                     a.RdNr = null; |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 if (IsEditing) { |  | ||||||
|                     tr = Context.Update(a); |  | ||||||
|                 } else if (IsCreating) { |  | ||||||
|                     a.FbNr = newFbNr; |  | ||||||
|                     tr = await Context.AddAsync(a); |  | ||||||
|                 } else { |  | ||||||
|                     throw new Exception(); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 await Context.SaveChangesAsync(); |  | ||||||
|  |  | ||||||
|                 if (newFbNr != a.FbNr) { |  | ||||||
|                     await Context.Database.ExecuteSqlAsync($"UPDATE area_commitment SET fbnr = {newFbNr} WHERE fbnr = {a.FbNr}"); |  | ||||||
|                     tr.State = EntityState.Detached; |  | ||||||
|                     await Context.SaveChangesAsync(); |  | ||||||
|                     await tr.ReloadAsync(); |  | ||||||
|                     a = await Context.AreaCommitments.FindAsync(newFbNr); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|             } catch (Exception exc) { |             } catch (Exception exc) { | ||||||
|                 if (tr != null) { |  | ||||||
|                     tr.State = EntityState.Detached; |  | ||||||
|                     await tr.ReloadAsync(); |  | ||||||
|                 } |  | ||||||
|                 var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message; |                 var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message; | ||||||
|                 if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message; |                 if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message; | ||||||
|                 MessageBox.Show(str, "Flächenbindung aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error); |                 MessageBox.Show(str, "Flächenbindung aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             return a!; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private async void AreaCommitmentSaveButton_Click(object sender, RoutedEventArgs evt) { |  | ||||||
|             AreaCom a = await UpdateAreaCom(IsEditing ? (AreaCom)AreaCommitmentList.SelectedItem : Context.CreateProxy<AreaCom>()); |  | ||||||
|             IsEditing = false; |             IsEditing = false; | ||||||
|             IsCreating = false; |             IsCreating = false; | ||||||
|             AreaCommitmentList.IsEnabled = true; |             AreaCommitmentList.IsEnabled = true; | ||||||
| @@ -290,8 +308,11 @@ namespace Elwig.Windows { | |||||||
|             ShowAreaCommitmentNewEditDeleteButtons(); |             ShowAreaCommitmentNewEditDeleteButtons(); | ||||||
|             LockInputs(); |             LockInputs(); | ||||||
|             UnlockSearchInputs(); |             UnlockSearchInputs(); | ||||||
|             await App.HintContextChange(); |             FinishInputFilling(); | ||||||
|             AreaCommitmentList.SelectedItem = a; |             await RefreshAreaCommitmentList(); | ||||||
|  |             RefreshInputs(); | ||||||
|  |             SearchInput.Text = ""; | ||||||
|  |             AreaCommitmentList.SelectedItem = AreaCommitmentList.ItemsSource.Cast<AreaCom>().Where(a => a.FbNr == fbnr).FirstOrDefault(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private void AreaCommitmentResetButton_Click(object sender, RoutedEventArgs evt) { |         private void AreaCommitmentResetButton_Click(object sender, RoutedEventArgs evt) { | ||||||
| @@ -393,9 +414,9 @@ namespace Elwig.Windows { | |||||||
|             await RefreshAreaCommitmentListQuery(true); |             await RefreshAreaCommitmentListQuery(true); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private async void KgInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) { |         private void KgInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) { | ||||||
|             if (KgInput.SelectedItem is AT_Kg curr_kg) { |             if (KgInput.SelectedItem is AT_Kg kg) { | ||||||
|                 var rdList = await Context.WbRde.Where(r => r.KgNr == curr_kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToListAsync(); |                 var rdList = kg.WbKg!.Rds.OrderBy(r => r.Name).Cast<object>().ToList(); | ||||||
|                 rdList.Insert(0, new NullItem()); |                 rdList.Insert(0, new NullItem()); | ||||||
|                 ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr, null, ControlUtils.RenewSourceDefault.First); |                 ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr, null, ControlUtils.RenewSourceDefault.First); | ||||||
|             } else { |             } else { | ||||||
| @@ -417,21 +438,25 @@ namespace Elwig.Windows { | |||||||
|             RdAddButton.IsEnabled = RdInput.SelectedIndex == -1; |             RdAddButton.IsEnabled = RdInput.SelectedIndex == -1; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private async void RdAddButton_Click(object sender, RoutedEventArgs evt) { |         private void RdAddButton_Click(object sender, RoutedEventArgs evt) { | ||||||
|             if (KgInput.SelectedItem is not AT_Kg kg) return; |             if (KgInput.SelectedItem is not AT_Kg kg) return; | ||||||
|             string name = RdInput.Text.Trim(); |             string name = RdInput.Text.Trim(); | ||||||
|             if (name.Length == 0) return; |             if (name.Length == 0) return; | ||||||
|             var s = RdInput.ItemsSource.Cast<object?>(); |             var s = RdInput.ItemsSource.Cast<object?>(); | ||||||
|             RdInput.ItemsSource = s.Append(new WbRd() { KgNr = kg.KgNr, Name = name, RdNr = await Context.NextRdNr(kg.KgNr)}); |             RdInput.ItemsSource = s.Append(new WbRd { | ||||||
|  |                 KgNr = kg.KgNr, | ||||||
|  |                 RdNr = 0, | ||||||
|  |                 Name = name, | ||||||
|  |             }); | ||||||
|             RdInput.SelectedIndex = s.Count(); |             RdInput.SelectedIndex = s.Count(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected void InputTextChanged(TextBox input, Func<TextBox, bool, AppDbContext, AreaCom?, ValidationResult> checker) { |         protected void InputTextChanged(TextBox input, Func<TextBox, bool, AreaCom?, ValidationResult> checker) { | ||||||
|             InputTextChanged(input, checker(input, SenderIsRequired(input), Context, (AreaCom)AreaCommitmentList.SelectedItem)); |             InputTextChanged(input, checker(input, SenderIsRequired(input), (AreaCom)AreaCommitmentList.SelectedItem)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected void InputLostFocus(TextBox input, Func<TextBox, bool, AppDbContext, AreaCom?, ValidationResult> checker, string? msg = null) { |         protected void InputLostFocus(TextBox input, Func<TextBox, bool, AreaCom?, ValidationResult> checker, string? msg = null) { | ||||||
|             InputLostFocus(input, checker(input, SenderIsRequired(input), Context, (AreaCom)AreaCommitmentList.SelectedItem), msg); |             InputLostFocus(input, checker(input, SenderIsRequired(input), (AreaCom)AreaCommitmentList.SelectedItem), msg); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private void FbNrInput_TextChanged(object sender, RoutedEventArgs evt) { |         private void FbNrInput_TextChanged(object sender, RoutedEventArgs evt) { | ||||||
|   | |||||||
| @@ -657,6 +657,8 @@ namespace Elwig.Windows { | |||||||
|                 await ctx.Database.ExecuteSqlAsync($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {oldMgNr}"); |                 await ctx.Database.ExecuteSqlAsync($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {oldMgNr}"); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             await App.HintContextChange(); | ||||||
|  |  | ||||||
|             return newMgNr; |             return newMgNr; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user