예제 #1
0
        /// <summary>
        /// Добавление позиции в таблицу
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddClick(object sender, RoutedEventArgs e)
        {
            if (DgDepartments.SelectedItem != null)
            {
                if (TcTables.SelectedIndex == 2)
                {
                    //получим отдел, в который добавить сотрудника
                    var selectedDepartament = DgDepartments.SelectedItem as Department;
                    var wnd = new UI.Windows.Employee();

                    //добавим в указанный отдел или в общий список
                    if (selectedDepartament != null)
                    {
                        wnd.Content = new UI.Pages.AddEmployee
                        {
                            Dep     = selectedDepartament,
                            ConnStr = ConnStr
                        };
                    }
                    wnd.ShowDialog();
                }
                else if (TcTables.SelectedIndex == 3)
                {
                    if (DgEmployees.SelectedItem != null)
                    {
                        //получаем сотрудника, которому добавить отпуск
                        var selectedEmployee = DgEmployees.SelectedItem as Employee;
                        var wnd = new UI.Windows.Vacation();

                        if (selectedEmployee != null)
                        {
                            wnd.Content = new UI.Pages.AddVacation
                            {
                                Emp     = selectedEmployee,
                                ConnStr = ConnStr
                            };
                            wnd.ShowDialog();
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Редактирование позиции в таблице
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditClick(object sender, RoutedEventArgs e)
        {
            var dgTable = new DataGrid();

            if (TcTables.SelectedIndex == 2)
            {
                dgTable = DgEmployees;
                if (dgTable.SelectedItem is Employee emp)
                {
                    var wnd = new UI.Windows.Employee
                    {
                        Content = new UI.Pages.EditEmployee
                        {
                            Emp     = emp,
                            ConnStr = ConnStr,
                            Context = Context
                        }
                    };
                    wnd.ShowDialog();
                }
            }
            if (TcTables.SelectedIndex == 3)
            {
                dgTable = DgVacations;
                if (dgTable.SelectedItem is Vacation vac)
                {
                    var wnd = new UI.Windows.Vacation
                    {
                        Content = new UI.Pages.EditVacation
                        {
                            Vac     = vac,
                            ConnStr = ConnStr,
                            Context = Context
                        }
                    };
                    wnd.ShowDialog();
                }
            }
            Context.InitializeContext();
        }