Exemple #1
0
        /// <summary>
        /// Обработчик события нажатия клавиши мыши на кнопку,
        /// который выполняет сохранение изменений
        /// </summary>
        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (UsedPersonal.Count == 0)
            {
                MessageBox.Show("Добавьте к задействованному персоналу сотурдников", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            try
            {
                SelectedServiceIdle.User.Clear();
                UsedPersonal.ToList().ForEach(up => SelectedServiceIdle.User.Add(up));
                _ctx.UpdateServiceIdle(SelectedServiceIdle);
                DialogResult = DialogResult.OK;
                MessageBox.Show("Изменения успешно сохранены!", "Информация", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                Close();
            }
            catch
            {
                MessageBox.Show("Не удалось сохранить изменения!", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        /// <summary>
        /// Обработчик события нажатия клавиши мыши на кнопку,
        /// который осуществляет добавление к выбранным сервисам
        /// </summary>
        private void btn_AddToUsed_Click(object sender, EventArgs e)
        {
            if (SelectedAvalibleUser == null || dg_AvalibleUser.CurrentRow != null)
            {
                MessageBox.Show("Пользователь не выбран!", "Предупреждение", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return;
            }

            UsedPersonal.Add(SelectedAvalibleUser);
            AvaliblePersonal.Remove(SelectedAvalibleUser);
        }
Exemple #3
0
        /// <summary>
        /// Обработчик события нажатия клавиши мыши на кнопку,
        /// который выполняет сохранение изменений
        /// </summary>
        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (_beginDateTime >= _endDateTime)
            {
                MessageBox.Show("Конечная дата должна быть больше начальной!", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (_endDateTime >= DateTime.Now)
            {
                MessageBox.Show("Конечная дата должна быть меньше текущей!", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (SelectedIdleType == null || comboBox1.SelectedIndex < 0)
            {
                MessageBox.Show("Выберите тип простоя!", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (SelectedIdleReason == null || comboBox2.SelectedIndex < 0)
            {
                MessageBox.Show("Выберите причину простоя!", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (UsedPersonal.Count == 0)
            {
                MessageBox.Show("Добавьте к задействованному персоналу сотрудников", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            try
            {
                List <Service> services = null;
                if (_server != null)
                {
                    services = _ctx.GetServicesByServer(_server);
                }
                else
                {
                    services = _ctx.GetServicesBySAN(_san);
                }

                _ctx.RegisterNewIdle(services, UsedPersonal.ToList(), _beginDateTime, _endDateTime,
                                     SelectedIdleType, SelectedIdleReason);
                MessageBox.Show("Простой оборудования успешно зарегистрирован!", "Информация", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
                Close();
            }
            catch
            {
                MessageBox.Show("Произошла ошибка при регистрации нового простоя! Изменения не сохранены!", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }