Ejemplo n.º 1
0
        private void Edit_button_Click(object sender, EventArgs e)
        {
            dataSet            = BusinessLogic.ReadWorkers();
            LastSelectionIndex = Workers_dataGridView.SelectedRows[0].Index;
            string            Post = Workers_dataGridView.SelectedRows[0].Cells["PostColumn"].Value.ToString();
            AddEditWorkerForm EditWorker;

            if (Post == "преподаватель теории")
            {
                EditWorker = new AddEditWorkerForm(Post, dataSet.TheoryTeachers.Rows.Find(Workers_dataGridView.SelectedRows[0].Cells["ID"].Value), dataSet.WorkStatuses, dataSet);
            }
            else if (Post == "инструктор")
            {
                EditWorker = new AddEditWorkerForm(Post, dataSet.Instructors.Rows.Find(Workers_dataGridView.SelectedRows[0].Cells["ID"].Value), dataSet.WorkStatuses, dataSet);
            }
            else if (Post == "мастер сервиса")
            {
                EditWorker = new AddEditWorkerForm(Post, dataSet.ServiceMasters.Rows.Find(Workers_dataGridView.SelectedRows[0].Cells["ID"].Value), dataSet.WorkStatuses, dataSet);
            }
            else
            {
                EditWorker = null;
                MessageBox.Show("Произошла непредвиденная ошибка", "Ошибка редактирования");
                return;
            }
            EditWorker.Text = "Редактирование сотрудника";
            this.Enabled    = false;
            EditWorker.ShowDialog();
            if (EditWorker.DialogResult == DialogResult.OK)
            {
                dataSet = BusinessLogic.WriteWorkers(dataSet);
                ReloadWorkers();
            }
            this.Enabled = true;
        }
Ejemplo n.º 2
0
        private void Add_button_Click(object sender, EventArgs e)
        {
            dataSet = BusinessLogic.ReadWorkers();
            AddEditWorkerForm AddWorker = new AddEditWorkerForm(null, null, dataSet.WorkStatuses, dataSet);

            AddWorker.Text = "Добавление сотрудника";
            this.Enabled   = false;
            AddWorker.ShowDialog();
            if (AddWorker.DialogResult == DialogResult.OK)
            {
                dataSet = BusinessLogic.WriteTheoryTeachers(dataSet);
                dataSet = BusinessLogic.WriteInstructors(dataSet);
                dataSet = BusinessLogic.WriteServiceMasters(dataSet);
                ReloadWorkers();
            }
            this.Enabled = true;
        }