f9ea678e00
- minor fixes
50 lines
1.8 KiB
C#
50 lines
1.8 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Input;
|
|
using Avalonia.Interactivity;
|
|
using LeanderShiftPlannerV2.Model;
|
|
using LeanderShiftPlannerV2.Service;
|
|
using LeanderShiftPlannerV2.Util;
|
|
|
|
namespace LeanderShiftPlannerV2.View.PersonView;
|
|
|
|
public partial class PersonEditor : Window
|
|
{
|
|
private readonly AppService _appService;
|
|
private readonly Person _model;
|
|
|
|
public PersonEditor(AppService appService, Person person)
|
|
{
|
|
InitializeComponent();
|
|
|
|
this._model = person;
|
|
this._appService = appService;
|
|
|
|
TextBoxName.Text = _model.FirstName;
|
|
TextBoxSurname.Text = _model.Surname;
|
|
TextBoxHours.Text = _model.Hours.ToString();
|
|
|
|
ComboBoxTimeSheetSource.Items.Add(Constants.TimeSheetSourceRandom);
|
|
ComboBoxTimeSheetSource.Items.Add(Constants.TimeSheetSourceGoogle);
|
|
ComboBoxTimeSheetSource.Items.Add(Constants.TimeSheetSourceRandomGoogle);
|
|
}
|
|
|
|
private void ButtonEditPerson_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (TextBoxName.Text != "" && TextBoxHours.Text != "" && TextBoxSurname.Text != ""
|
|
&& TextBoxName.Text != null && TextBoxHours.Text != null && TextBoxSurname.Text != null
|
|
&& ComboBoxTimeSheetSource.SelectedItem != null)
|
|
{
|
|
_appService.PersonService.EditPerson(_model, TextBoxName.Text, TextBoxSurname.Text, int.Parse(TextBoxHours.Text), ComboBoxTimeSheetSource.SelectedItem.ToString()!);
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
ViewService.ShowNoInputError(this);
|
|
}
|
|
}
|
|
|
|
private void TextBoxHours_PreviewTextInput(object sender, TextInputEventArgs e)
|
|
{
|
|
if (e.Text != null) e.Handled = ViewUtil.CheckNumericText(e.Text);
|
|
}
|
|
} |