|
@@ -7,6 +7,8 @@ using Microsoft.EntityFrameworkCore;
|
|
|
using ReactiveUI;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
+using MsBox.Avalonia.Enums;
|
|
|
+using MsBox.Avalonia;
|
|
|
|
|
|
namespace AvaloniaApplication5.ViewModels
|
|
|
{
|
|
@@ -36,7 +38,7 @@ namespace AvaloniaApplication5.ViewModels
|
|
|
TeacherCourses = NewTeacher.TeacherCourses.ToList();
|
|
|
TeacherDisciplines = NewTeacher.TeacherDisciplines.ToList();
|
|
|
|
|
|
- TextButton = "Ðåäàêòèðîâàòü";
|
|
|
+ TextButton = "Ñîõðàíèòü èçìåíåíèÿ";
|
|
|
|
|
|
}
|
|
|
public List<Gender> Genders => MainWindowViewModel.myConnection.Genders.ToList();
|
|
@@ -97,13 +99,61 @@ namespace AvaloniaApplication5.ViewModels
|
|
|
TeacherCourses = NewTeacher.TeacherCourses.ToList();
|
|
|
this.RaisePropertyChanged(nameof(Courses));
|
|
|
}
|
|
|
- public void AddTeacher()
|
|
|
+
|
|
|
+ public async void AddTeacher()
|
|
|
{
|
|
|
- if(NewTeacher.Id == 0)
|
|
|
- {
|
|
|
- MainWindowViewModel.myConnection.Teachers.Add(NewTeacher);
|
|
|
+
|
|
|
+ if (NewTeacher.Id == 0 && TextButton == "Äîáàâèòü")
|
|
|
+
|
|
|
+ {
|
|
|
+ ButtonResult result = await MessageBoxManager.GetMessageBoxStandard("Ïîäòâåðæäåíèå äîáàâëåíèÿ",
|
|
|
+ "Ïîäòâåðäèòü äîáàâëåíèå ó÷èòåëÿ?", ButtonEnum.YesNo).ShowAsync();
|
|
|
+ if (result == ButtonResult.Yes)
|
|
|
+ {
|
|
|
+
|
|
|
+ MainWindowViewModel.myConnection.Teachers.Add(NewTeacher);
|
|
|
+ await MessageBoxManager.GetMessageBoxStandard("Ñîîáùåíèå", "Ó÷èòåëü äîáàâëåí", ButtonEnum.Ok).ShowAsync();
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await MessageBoxManager.GetMessageBoxStandard("Îòìåíà", "Äîáàâëåíèå îòìåíåî", ButtonEnum.Ok).ShowAsync();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- MainWindowViewModel.myConnection.SaveChanges();
|
|
|
- }
|
|
|
+
|
|
|
+ else {
|
|
|
+ ButtonResult result = await MessageBoxManager.GetMessageBoxStandard("Ïîäòâåðæäåíèå ðåäàêòèðîâàíèÿ",
|
|
|
+ "Ïîäòâåðäèòü ðåäàêòèðîâàíèå ó÷èòåëÿ?", ButtonEnum.YesNo).ShowAsync();
|
|
|
+ if (result == ButtonResult.Yes)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ await MessageBoxManager.GetMessageBoxStandard("Ñîîáùåíèå", "Ó÷èòåëü îòðåäàêòèðîâàí", ButtonEnum.Ok).ShowAsync();
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await MessageBoxManager.GetMessageBoxStandard("Îòìåíà", "Ðåäàêòèðîâàíèå îòìåíåíî", ButtonEnum.Ok).ShowAsync();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ MainWindowViewModel.myConnection.SaveChanges();
|
|
|
+ MainWindowViewModel.Instance.PageContent = new Show();
|
|
|
+ }
|
|
|
+ public void ToAddDisCurs()
|
|
|
+ {
|
|
|
+ MainWindowViewModel.Instance.PageContent = new AddDisCurs();
|
|
|
+ }
|
|
|
+ string _message = "";
|
|
|
+
|
|
|
+ public string Message
|
|
|
+ {
|
|
|
+ get => _message;
|
|
|
+ set => this.RaiseAndSetIfChanged(ref _message, value);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|