120 lines
2.5 KiB
C#
120 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.Extensions;
|
|
|
|
using BeWo.Core;
|
|
using BeWo.Core.Service;
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.Validation;
|
|
using BeWo.ViewModel;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
|
|
using DevExpress.Xpf.Editors.Settings;
|
|
using DevExpress.Xpf.Grid;
|
|
|
|
namespace BeWo.View.Detail
|
|
{
|
|
public partial class PreisView : BeWoView
|
|
{
|
|
private PreisListVM _ViewModel;
|
|
|
|
public PreisView(PreisListVM pViewModel)
|
|
{
|
|
InitializeComponent();
|
|
|
|
ViewModel = pViewModel;
|
|
}
|
|
|
|
public override bool IsDirty
|
|
{
|
|
get { return ViewModel != null && ViewModel.IsDirty; }
|
|
}
|
|
|
|
public override string Title
|
|
{
|
|
get { return "Preise"; }
|
|
}
|
|
|
|
internal override DependencyObject ValidationOnSaveRootElement
|
|
{
|
|
get { return button_addPreis; }
|
|
}
|
|
|
|
private PreisListVM ViewModel
|
|
{
|
|
get { return _ViewModel; }
|
|
|
|
set
|
|
{
|
|
_ViewModel = value;
|
|
root.DataContext = value;
|
|
}
|
|
}
|
|
|
|
protected override void Save()
|
|
{
|
|
var lToDos = new List<Action<IOperationsService>>();
|
|
|
|
if (ViewModel.AddedCount > 0)
|
|
{
|
|
lToDos.Add(s => s.InsertNewPreis(ViewModel.CommitAdded()));
|
|
}
|
|
|
|
if (ViewModel.RemovedCount > 0)
|
|
{
|
|
lToDos.Add(s => s.DeactivatePreis(ViewModel.GetRemoved().ToDictionary(dc => dc.PreisOid.Value, dc => dc.PreisVersion.Value)));
|
|
}
|
|
|
|
if (ViewModel.ChangedCount > 0)
|
|
{
|
|
lToDos.Add(s => s.UpdatePreis(ViewModel.CommitChanged()));
|
|
}
|
|
|
|
ServiceFacade.DoMultipleOperationsServicesAsync(lToDos, ReloadViewModel);
|
|
}
|
|
|
|
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
ViewModel.VMList.Remove(DatagridPreis.GetCurrentValue<PreisVM>());
|
|
BeWoWpfUtils.RefreshDXGrid(DatagridPreis);
|
|
}
|
|
|
|
private void ReloadViewModel()
|
|
{
|
|
VMFactory.CreatePreisListVMAsync(r => this.Dispatch(delegate { ViewModel = r; }));
|
|
}
|
|
|
|
private void Button_addPreis_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (ValidationTrigger.Validate(this))
|
|
{
|
|
ViewModel.AddNewVMToList();
|
|
}
|
|
}
|
|
|
|
private void PART_Editor_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
RowData data = DatagridPreis.View.FocusedRowData;
|
|
|
|
if (data != null && data.RowHandle != null)
|
|
{
|
|
var vm = DatagridPreis.GetRow(data.RowHandle.Value) as PreisVM;
|
|
|
|
if (vm != null)
|
|
{
|
|
ViewModel.EditVM = vm;
|
|
popup_costrateperiods.IsOpen = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void button_edit_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
popup_costrateperiods.IsOpen = false;
|
|
}
|
|
}
|
|
}
|