12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using Avalonia;
- using Avalonia.Controls;
- using Avalonia.Interactivity;
- using Avalonia.Markup.Xaml;
- using MsBox.Avalonia;
- using MsBox.Avalonia.Enums;
- using System.Collections.Generic;
- using System.IO;
- using Teachers.Models;
- using Teachers.ViewModels;
- namespace Teachers;
- public partial class AddCourseView : UserControl
- {
- public AddCourseView()
- {
- InitializeComponent();
- DataContext = new AddTeacherViewModel();
- }
- private async void bAddCourse(object sender, RoutedEventArgs e)
- {
- AddCourse();
- var window = this.VisualRoot as Window;
- ButtonResult result = await MessageBoxManager.GetMessageBoxStandard("Âíèìàíèå", "Ïðè äîáàâëåíèè êóðñà âñå çàïîëíåííûå ïîëÿ áóäóò î÷èùåíû. Âû óâåðåíû, ÷òî õîòèòå äîáàâèòü íîâûé êóðñ?", MsBox.Avalonia.Enums.ButtonEnum.YesNo).ShowAsync();
- switch (result)
- {
- case ButtonResult.Yes:
- {
- window?.Close();
- MainWindowViewModel.Instance.Us = new AddTeacherView();
- break;
- }
- case ButtonResult.No:
- {
- window?.Close();
- break;
- }
- }
- }
- public void AddCourse()
- {
- Course newCourse = new Course() { Name = tbCourse.Text, Duration = int.Parse(tbDuration.Text) };
- MainWindowViewModel.myConnection.Courses.Add(newCourse);
- MainWindowViewModel.myConnection.SaveChanges();
- }
- }
|