Example #1
0
        public void canselCreateTask(bool state)
        {
            if (state)
            {
                //cancel
                tasksDataGridView.Rows.RemoveAt(tasksDataGridView.RowCount - 1);
                creatingNewTask = false;
                sqlManager.EndTransaction(false);
                createNewTaskBtn.Enabled = true;
                ShowOtherForm = false;
                CurrentActiveForm = null;
                creationEndBtn.Enabled = false;
            }
            else
            {
                //продолжение создания
                if (CurrentActiveForm.GetType() == typeof(ParametersForm))
                {
                    DataGridViewRow row = tasksDataGridView.Rows[tasksDataGridView.RowCount - 1];

                    SelectionForm selectionForm = new SelectionForm();
                    selectionForm.CountSelections = int.Parse(row.Cells[2].Value.ToString());
                    selectionForm.SetCreateNewTask(true);
                    selectionForm.SetTaskID(curTaskID);
                    selectionForm.Show();

                    selectionForm.MainForm = this;
                    ShowOtherForm = true;

                    CurrentActiveForm = selectionForm;
                }
                else if (CurrentActiveForm.GetType() == typeof(SelectionForm))
                {
                    //окончание создания
                    CurrentActiveForm = null;
                    creatingNewTask = false;
                    sqlManager.EndTransaction(true);
                    createNewTaskBtn.Enabled = true;
                    ShowOtherForm = false;
                    tasksDataGridView.Rows.Clear();
                    ShowAllTasks();
                }
            }
        }
Example #2
0
        public void canselCreateTask(bool state)
        {
            if (state)
            {
                //cancel
                tasksDataGridView.Rows.RemoveAt(tasksDataGridView.RowCount - 1);
                creatingNewTask = false;
                sqlManager.EndTransaction(false);
                createNewTaskBtn.Enabled = true;
                ShowOtherForm            = false;
                CurrentActiveForm        = null;
                creationEndBtn.Enabled   = false;
            }
            else
            {
                //продолжение создания
                if (CurrentActiveForm.GetType() == typeof(ParametersForm))
                {
                    DataGridViewRow row = tasksDataGridView.Rows[tasksDataGridView.RowCount - 1];

                    SelectionForm selectionForm = new SelectionForm();
                    selectionForm.CountSelections = int.Parse(row.Cells[2].Value.ToString());
                    selectionForm.SetCreateNewTask(true);
                    selectionForm.SetTaskID(curTaskID);
                    selectionForm.Show();

                    selectionForm.MainForm = this;
                    ShowOtherForm          = true;

                    CurrentActiveForm = selectionForm;
                }
                else if (CurrentActiveForm.GetType() == typeof(SelectionForm))
                {
                    //окончание создания
                    CurrentActiveForm = null;
                    creatingNewTask   = false;
                    sqlManager.EndTransaction(true);
                    createNewTaskBtn.Enabled = true;
                    ShowOtherForm            = false;
                    tasksDataGridView.Rows.Clear();
                    ShowAllTasks();
                }
            }
        }
Example #3
0
        private void tasksDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (ShowOtherForm)
                return;
            if (creatingNewTask)
            {
                if (e.ColumnIndex == 4 && e.RowIndex == tasksDataGridView.RowCount - 1)
                {
                    //cancel
                    canselCreateTask(false);
                }
                if (e.ColumnIndex == 5 && e.RowIndex == tasksDataGridView.RowCount - 1)
                {
                    //create
                    DataGridViewRow row = tasksDataGridView.Rows[tasksDataGridView.RowCount - 1];
                    if (row.Cells[0].Value.ToString() != "" && row.Cells[1].Value.ToString() != "" && row.Cells[2].Value.ToString() != "")
                    {
                        createNewTask(row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString()); //insert in db
                        ParametersForm paramForm = new ParametersForm();
                        paramForm.CountParams = int.Parse(row.Cells[1].Value.ToString());
                        paramForm.SetCreateNewTask(true);
                        paramForm.SetTaskID(curTaskID);
                        paramForm.Show();

                        paramForm.MainForm = this;
                        ShowOtherForm = true;

                        CurrentActiveForm = paramForm;
                    }
                }
            }
            else
            {
                if (e.ColumnIndex == 3)
                {
                    //show parameters of task
                    Task task = arrTask[e.RowIndex];
                    ParametersForm paramForm = new ParametersForm();
                    paramForm.SetTaskID(task.ID);
                    paramForm.SetCreateNewTask(false);
                    paramForm.Show();

                    paramForm.MainForm = this;
                }
                if (e.ColumnIndex == 4)
                {
                    //show selections of task
                    Task task = arrTask[e.RowIndex];
                    SelectionForm paramForm = new SelectionForm();
                    paramForm.SetTaskID(task.ID);
                    paramForm.SetCreateNewTask(false);
                    paramForm.Show();

                    paramForm.MainForm = this;
                }
                if (e.ColumnIndex == 5)
                {
                    //delete current task
                    Task task = arrTask[e.RowIndex];
                    DeleteTask(task);
                    tasksDataGridView.Rows.Clear();
                    ShowAllTasks();
                }
            }
        }
Example #4
0
        private void tasksDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (ShowOtherForm)
            {
                return;
            }
            if (creatingNewTask)
            {
                if (e.ColumnIndex == 4 && e.RowIndex == tasksDataGridView.RowCount - 1)
                {
                    //cancel
                    canselCreateTask(false);
                }
                if (e.ColumnIndex == 5 && e.RowIndex == tasksDataGridView.RowCount - 1)
                {
                    //create
                    DataGridViewRow row = tasksDataGridView.Rows[tasksDataGridView.RowCount - 1];
                    if (row.Cells[0].Value.ToString() != "" && row.Cells[1].Value.ToString() != "" && row.Cells[2].Value.ToString() != "")
                    {
                        createNewTask(row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString()); //insert in db
                        ParametersForm paramForm = new ParametersForm();
                        paramForm.CountParams = int.Parse(row.Cells[1].Value.ToString());
                        paramForm.SetCreateNewTask(true);
                        paramForm.SetTaskID(curTaskID);
                        paramForm.Show();

                        paramForm.MainForm = this;
                        ShowOtherForm      = true;

                        CurrentActiveForm = paramForm;
                    }
                }
            }
            else
            {
                if (e.ColumnIndex == 3)
                {
                    //show parameters of task
                    Task           task      = arrTask[e.RowIndex];
                    ParametersForm paramForm = new ParametersForm();
                    paramForm.SetTaskID(task.ID);
                    paramForm.SetCreateNewTask(false);
                    paramForm.Show();

                    paramForm.MainForm = this;
                }
                if (e.ColumnIndex == 4)
                {
                    //show selections of task
                    Task          task      = arrTask[e.RowIndex];
                    SelectionForm paramForm = new SelectionForm();
                    paramForm.SetTaskID(task.ID);
                    paramForm.SetCreateNewTask(false);
                    paramForm.Show();

                    paramForm.MainForm = this;
                }
                if (e.ColumnIndex == 5)
                {
                    //delete current task
                    Task task = arrTask[e.RowIndex];
                    DeleteTask(task);
                    tasksDataGridView.Rows.Clear();
                    ShowAllTasks();
                }
            }
        }