171 lines
5.3 KiB
C#
171 lines
5.3 KiB
C#
using BeWo.Core;
|
|
using BeWo.ServiceProxy;
|
|
using BS.Shared.Extensions;
|
|
using DevExpress.Utils;
|
|
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using BS.Shared.DataContracts.ClientPartials;
|
|
using BS.Shared.Translation;
|
|
using DevExpress.Data.Helpers;
|
|
using DevExpress.Xpf.Editors.Settings;
|
|
|
|
namespace BeWo.View.Controls
|
|
{
|
|
/// <summary>
|
|
/// Interaktionslogik für TestEMailControl.xaml
|
|
/// </summary>
|
|
public partial class GoalRatingControl : UserControl
|
|
{
|
|
private List<SupportConceptGoalDC> _Goals;
|
|
|
|
public event Action CancelButtonClicked;
|
|
public event Action ActionButtonClicked;
|
|
|
|
private List<GoalRating> _Ratings;
|
|
|
|
public GoalRatingControl()
|
|
{
|
|
InitializeComponent();
|
|
InitRatings();
|
|
ColumnRating.EditSettings = new ComboBoxEditSettings { ItemsSource = _Ratings, IsTextEditable = false };
|
|
IsDirty = false;
|
|
}
|
|
|
|
private void InitRatings()
|
|
{
|
|
_Ratings = new List<GoalRating>();
|
|
_Ratings.Add(new GoalRating { RatingValue = -1, RatingName = "Keine Bewertung"});
|
|
_Ratings.Add(new GoalRating { RatingValue = 0, RatingName = "xxx.0 - Problem nicht vorhanden (ohne, kein, unerheblich ...) 0 bis 4 %" });
|
|
_Ratings.Add(new GoalRating { RatingValue = 1, RatingName = "xxx.1 - Problem leicht ausgeprägt (schwach, gering ...) 5 bis 24 %" });
|
|
_Ratings.Add(new GoalRating { RatingValue = 2, RatingName = "xxx.2 - Problem mäßig ausgeprägt (mittel, ziemlich ...) 25 bis 49 %" });
|
|
_Ratings.Add(new GoalRating { RatingValue = 3, RatingName = "xxx.3 - Problem erheblich ausgeprägt (hoch, äußerst ...) 50 bis 95 %" });
|
|
_Ratings.Add(new GoalRating { RatingValue = 4, RatingName = "xxx.4 - Problem voll ausgeprägt (komplett, total ...) 96 bis 100 %" });
|
|
_Ratings.Add(new GoalRating { RatingValue = 8, RatingName = "xxx.8 - Nicht spezifiziert" });
|
|
_Ratings.Add(new GoalRating { RatingValue = 9, RatingName = "xxx.9 - Nicht anwendbar" });
|
|
}
|
|
|
|
public List<SupportConceptGoalDC> Goals
|
|
{
|
|
get { return _Goals;}
|
|
set
|
|
{
|
|
_Goals = value;
|
|
CreateList();
|
|
}
|
|
}
|
|
|
|
private void CreateList()
|
|
{
|
|
List<GoalRatingEntry> entries = new List<GoalRatingEntry>();
|
|
foreach (var goal in Goals)
|
|
{
|
|
GoalRatingEntry entry = new GoalRatingEntry();
|
|
entry.Goal = goal;
|
|
entry.Name = goal.DetailDescription;
|
|
if (goal.HasRating)
|
|
{
|
|
entry.GoalRating = _Ratings.FirstOrDefault(r => r.RatingValue == goal.GoalEntryDC.Rating.Value);
|
|
}
|
|
|
|
entries.Add(entry);
|
|
}
|
|
|
|
Entries = entries;
|
|
}
|
|
|
|
private void CancelButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (IsDirty)
|
|
{
|
|
if (MessageBox.Show(
|
|
Translator.Translate("Möchten Sie wirklich abbrechen und die Änderungen verwerfen?"),
|
|
"BeWoPlaner", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
CancelButtonClicked?.Invoke();
|
|
}
|
|
|
|
private void ActionButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
Save();
|
|
ActionButtonClicked?.Invoke();
|
|
}
|
|
|
|
private void TableView_CellValueChanged(object sender, DevExpress.Xpf.Grid.CellValueChangedEventArgs e)
|
|
{
|
|
IsDirty = true;
|
|
}
|
|
|
|
|
|
public bool IsDirty { get; set; }
|
|
|
|
|
|
public List<GoalRatingEntry> Entries
|
|
{
|
|
get { return DatagridRegions.ItemsSource as List<GoalRatingEntry>; }
|
|
set
|
|
{
|
|
DatagridRegions.ItemsSource = value;
|
|
}
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
foreach (var e in Entries)
|
|
{
|
|
if (e.GoalRating != null)
|
|
{
|
|
e.Goal.SetRating(e.GoalRating.RatingValue);
|
|
}
|
|
else
|
|
{
|
|
e.Goal.SetRating(null);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public class GoalRatingEntry
|
|
{
|
|
public SupportConceptGoalDC Goal { get; set; }
|
|
public String Name { get; set; }
|
|
public GoalRating GoalRating { get; set; }
|
|
}
|
|
|
|
public class GoalRating
|
|
{
|
|
public int RatingValue { get; set; }
|
|
public String RatingName { get; set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
return RatingName;
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
var gr = obj as GoalRating;
|
|
|
|
if (gr != null)
|
|
{
|
|
return this.RatingName.Equals(((GoalRating) obj).RatingName);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return RatingName.GetHashCode();
|
|
}
|
|
}
|
|
}
|