} //выбор сотрудника private void SeeAllWokers_SelectionChanged(object sender, SelectionChangedEventArgs e) { RefreshAllDataTab(); Woker shef = new Woker(); if (SeeAllWokers.SelectedIndex != -1) { shef = SeeAllWokers.Items[SeeAllWokers.SelectedIndex] as Woker; Subordinations.ItemsSource = DB.Wokers.Where(c => c.IsSubShef(shef)).ToList(); FIO.Content = shef.ToString(); Begins.Content = "В компании с: " + shef.Begin.ToString("d"); SalaryView.Content = "Зарплата: " + shef.ShowSalary(date); if (shef.Shef != null) { ShefFIO.Content = "Начальник: " + shef.Shef.Name + " " + shef.Surname; } else { ShefFIO.Content = "работает без начальника"; } log.Content = "Логин: " + shef.Accaunt.Login; pas.Content = "Пароль: " + shef.Accaunt.Password; double summ = 0; foreach (Woker w in SeeAllWokers.ItemsSource) { summ += System.Convert.ToDouble(w.ShowSalary(date)); } AllSalary.Content = "Затраты на зарплату составляют: " + summ; } } //выбор сотрудника
private void AllWokers_SelectionChanged(object sender, SelectionChangedEventArgs e) { selectedWoker = AllWokers.Items[AllWokers.SelectedIndex] as Woker; if (selectedWoker != null) { RefreshContentSuborinteTab(); } } //выбор сотрудника
} //открытие и заполнение формы private void Subordinations_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (Subordinations.SelectedIndex != -1) { sub = Subordinations.Items[Subordinations.SelectedIndex] as Woker; SFIO.Content = sub.Name + " " + sub.Surname; SSalaryView.Content = "Зарплата: " + sub.ShowSalary(date); SBegins.Content = "В кмпании с " + sub.Begin.ToString("d"); } } //выбор подчиненного и вывод информации о нем
public bool IsSubShef(Woker he) { if (Shef == he) { return(true); } if (Shef == null) { return(false); } return(Shef.IsSubShef(he)); } //проверка на наличие подчиненности любого уровня
} //выбор сотрудника private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { Woker sub = new Woker(); if (Subordinations.SelectedIndex != -1 && Subordinations.SelectedIndex != -1) { sub = Subordinations.Items[Subordinations.SelectedIndex] as Woker; SFIO.Content = sub.ToString(); SBegins.Content = "В компании с: " + sub.Begin; SSalaryView.Content = "Зарплата: " + sub.ShowSalary(date); } } //выбор подчиненного
private void SetShef(object sender, RoutedEventArgs e) { if (ShefList.SelectedIndex > -1) { Woker myShef = ShefList.Items[ShefList.SelectedIndex] as Woker; if (myShef != null && selectedWoker != null) { selectedWoker.Shef = myShef; } DB.SaveChanges(); RefreshContentSuborinteTab(); } }
} //обновление формы с натройки "подчиненности" private void AssSubordination(object sender, RoutedEventArgs e) { if (notSubordinate.SelectedIndex > -1) { Woker subordinateWoker = notSubordinate.Items[notSubordinate.SelectedIndex] as Woker; if (selectedWoker != null && subordinateWoker != null) { subordinateWoker.Shef = selectedWoker; DB.SaveChanges(); RefreshContentSuborinteTab(); } } }
string date; //переменные для этого окна public UserWindow(Woker w) { InitializeComponent(); Me = w; this.Show(); FIO.Content = Me.Name + " " + Me.Surname; TypeInfo.Content = Me.Type; if (Me.Shef != null) { ShefFIO.Content = "Начальник: " + Me.Shef.Name + " " + Me.Shef.Surname; } else { ShefFIO.Content = "У вас нет начальника"; } Begin.Content = "В компании с " + Me.Begin.ToString("d"); List <Woker> list = new List <Woker>(); Me.RekSub(list); Subordinations.ItemsSource = list; SalaryView.Content = "Зарплата: " + Me.ShowSalary(date); } //открытие и заполнение формы
private void Add_woker(object sender, RoutedEventArgs e) { Accaunt newAccaunt = new Accaunt { Login = loginBox.Text, Password = passwordBox.Text }; DB.Accaunts.Add(newAccaunt); DB.SaveChanges(); Woker newWoker = new Woker { Name = nameBox.Text, Surname = surnameBox.Text, Rate = System.Convert.ToInt32(rateBox.Text), Type = typeCombo.SelectedItem.ToString(), Begin = Convert.ToDateTime(beginBox.Text), AccauntId = newAccaunt.Id, Accaunt = newAccaunt }; DB.Wokers.Add(newWoker); DB.SaveChanges(); RefreshAll(); } //добавление работника в базу данных