Beispiel #1
0
        /// <summary>
        /// Добавить отдел
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void BtnAddDepartment_Click(object sender, RoutedEventArgs e)
        {
            DataRow          newRow           = deptDatatTable.NewRow();
            DepartmentWindow departmentWindow = new DepartmentWindow(newRow);

            departmentWindow.Owner = mainWindow;
            departmentWindow.ShowDialog();
            if (departmentWindow.DialogResult.HasValue && departmentWindow.DialogResult.Value)
            {
                deptDatatTable.Rows.Add(newRow);
                sqlDepartmentAdapter.Update(deptDatatTable);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Редактировать отдел
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void BtnEditDepartment_Click(object sender, RoutedEventArgs e)
        {
            DataRowView      newRow           = (DataRowView)mainWindow.lbDepartments.SelectedItem;
            DepartmentWindow departmentWindow = new DepartmentWindow(newRow.Row);

            newRow.BeginEdit();
            departmentWindow.Owner = mainWindow;
            departmentWindow.ShowDialog();
            if (departmentWindow.DialogResult.HasValue && departmentWindow.DialogResult.Value)
            {
                newRow.EndEdit();
                sqlDepartmentAdapter.Update(deptDatatTable);
            }
            else
            {
                newRow.CancelEdit();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Редактировать отдел
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void BtnEditDepartment_Click(object sender, RoutedEventArgs e)
        {
            DepartmentWindow departmentWindow = new DepartmentWindow((mainWindow.lbDepartments.SelectedItem as Department).DepartmentName);

            departmentWindow.btnCancel.Click        += (o, h) => departmentWindow.Close();
            departmentWindow.btnAddDepartment.Click += (o, h) =>
            {
                if (org.ChangeDepartmentName((mainWindow.lbDepartments.SelectedItem as Department).DepartmentId, departmentWindow.tbDeparmentName.Text))
                {
                    departmentWindow.Close();
                }
                else
                {
                    MessageBox.Show("Такой отдел уже есть");
                }
            };
            departmentWindow.Owner = mainWindow;
            departmentWindow.ShowDialog();
        }
Beispiel #4
0
        /// <summary>
        /// Добавить отдел
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void BtnAddDepartment_Click(object sender, RoutedEventArgs e)
        {
            DepartmentWindow departmentWindow = new DepartmentWindow();

            departmentWindow.btnCancel.Click        += (o, h) => departmentWindow.Close();
            departmentWindow.btnAddDepartment.Click += (o, h) =>
            {
                if (org.AddDeparment(new Department(departmentWindow.tbDeparmentName.Text)))
                {
                    departmentWindow.Close();
                }
                else
                {
                    MessageBox.Show("Такой отдел уже есть");
                }
            };
            departmentWindow.Owner = mainWindow;
            departmentWindow.ShowDialog();
        }
Beispiel #5
0
        /// <summary>
        /// Редактировать отдел
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void BtnEditDepartment_Click(object sender, RoutedEventArgs e)
        {
            DepartmentWindow departmentWindow = new DepartmentWindow((mainWindow.lbDepartments.SelectedItem as Department).DepartmentName);

            departmentWindow.btnCancel.Click        += (o, h) => departmentWindow.Close();
            departmentWindow.btnAddDepartment.Click += (o, h) =>
            {
                (mainWindow.lbDepartments.SelectedItem as Department).DepartmentName = departmentWindow.tbDeparmentName.Text;
                StringContent content =
                    new StringContent(org.GetJSONDept(mainWindow.lbDepartments.SelectedItem as Department), Encoding.UTF8, "application/json");
                var r = httpClient.PostAsync(baseAddress + @"ModifyDepartment", content).Result;
                departmentWindow.DialogResult = true;
                departmentWindow.Close();
            };
            departmentWindow.Owner = mainWindow;
            departmentWindow.ShowDialog();
            if (departmentWindow.DialogResult == true)
            {
                RefreshDepartments();
            }
        }