You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

54 lines
1.9 KiB

using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace eCompanies
{
/// <summary>
/// Логика взаимодействия для UsersWindow.xaml
/// </summary>
public partial class UsersWindow : Window
{
Company currentCompany;
public UsersWindow(Company c)
{
InitializeComponent();
currentCompany = c;
currentCompany.Users = App.getUsers(currentCompany.CompanyId);
companyNameBox.Text = c.Name;
contractStatusComboBox.SelectedIndex = c.ContractStatus;
usersGrid.DataContext = new ObservableCollection<Users>(c.Users.AsEnumerable());
}
private void usersGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
MessageBoxResult mbr = MessageBox.Show("Вы закрываете окно с компанией. Хотите сохранить результаты?", "Сохранение изменений", MessageBoxButton.YesNo);
if (mbr == MessageBoxResult.No)
return;
currentCompany.ContractStatus = contractStatusComboBox.SelectedIndex;
currentCompany.Name = companyNameBox.Text;
foreach (Users u in (ObservableCollection<Users>)usersGrid.DataContext)
{
u.CompanyId = currentCompany.CompanyId;
u.Company = currentCompany;
currentCompany.Users.Add(u);
}
App.updateCompany(currentCompany);
}
private void usersGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
}
private void usersGrid_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
}
}
}