123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using esoft.Class;
- using esoft.Entities;
- using System;
- using System.CodeDom.Compiler;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.NetworkInformation;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace esoft.Pages
- {
- /// <summary>
- /// Логика взаимодействия для EditPriceCoefficient.xaml
- /// </summary>
- public partial class EditPriceCoefficient : Page
- {
- ActualContext actualContext = new ActualContext();
- public EditPriceCoefficient()
- {
- InitializeComponent();
- FillForm();
- }
- private void FillForm()
- {
- List<User> usersManager = actualContext.Users.Where(user => actualContext.Manager.Any(manager => manager.ID == user.ID)).ToList(); // Получение списка менеджеров
- cbManager.ItemsSource = UserInFIO.GroupUser(usersManager);
- }
- private void BtnSaveSalaryCoeff_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- // Получаем значения из элементов интерфейса
- int managerId = (int)(cbManager.SelectedItem as ComboBoxItem)?.Tag;
- int juniorMin = (int)IUDJuniorMin.Value;
- int middleMin = (int)IUDMiddleMin.Value;
- int seniorMin = (int)IUDSeniorMin.Value;
- double analysisCoeff = (double)IUDAnalysisCoefficient.Value;
- double installationCoeff = (double)IUDInstallationCoefficient.Value;
- double supportCoeff = (double)IUDSupportCoefficient.Value;
- double timeCoeff = (double)IUDTimeCoefficient.Value;
- double difficultyCoeff = (double)IUDDifficultyCoefficient.Value;
- double toMoneyCoeff = (double)IUDToMoneyCoefficient.Value;
- // Обновляем коэффициенты менеджера
- UpdateManagerCoefficients(managerId, juniorMin, middleMin, seniorMin, analysisCoeff, installationCoeff, supportCoeff, timeCoeff, difficultyCoeff, toMoneyCoeff);
- MessageBox.Show("Коэффициенты сохранены успешно!");
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Ошибка при сохранении коэффициентов: {ex.Message}", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- public void UpdateManagerCoefficients(int managerId, int juniorMin, int middleMin, int seniorMin, double analysisCoeff, double installationCoeff, double supportCoeff, double timeCoeff, double difficultyCoeff, double toMoneyCoeff)
- {
- try
- {
- // Получаем контекст базы данных и находим менеджера по ID
- var context = esoftEntities.GetContext();
- {
- Manager targetManager = context.Manager.FirstOrDefault(m => m.ID == managerId);
- if (targetManager != null)
- {
- // Обновляем значения коэффициентов менеджера
- targetManager.JuniorMinimum = juniorMin;
- targetManager.MiddleMinimum = middleMin;
- targetManager.SeniorMinimum = seniorMin;
- targetManager.AnalysisCoefficient = analysisCoeff;
- targetManager.InstallationCoefficient = installationCoeff;
- targetManager.SupportCoefficient = supportCoeff;
- targetManager.TimeCoefficient = timeCoeff;
- targetManager.DifficultyCoefficient = difficultyCoeff;
- targetManager.ToMoneyCoefficient = toMoneyCoeff;
- // Сохраняем изменения в базе данных
- context.SaveChanges();
- }
- else
- {
- MessageBox.Show("Менеджер не найден!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Ошибка обновления коэффициентов: {ex.Message}", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- }
- }
|