Example #1
0
        private void TaskToDB()
        {
            if (!IfTaskGreedChanged())
                return;

            DataManager dm = new DataManager();
            MathManager mm = new MathManager();
            //int col = 4;
            //int rows = taskDataGridView.Rows.Count;
            //int col;
            int rows;

            if (Convert.ToInt32(updatedTaskIndexes.Count.ToString()) == 0) // no changes were found, there fore no need to save any data
                return;

            //string[] read = new string[4];

            for(int i = 0; i < Convert.ToInt32(updatedTaskIndexes.Count.ToString()); i++)
                {
                    rows = updatedTaskIndexes.ElementAt(i).getRow();
                    int task_ID = Convert.ToInt32(taskDataGridView.Rows[rows].Cells[1].Value.ToString());
                    if (mm.isTask_Id_Exist(task_ID) >= 0)
                    { //     task already exist, therefore we need only to update
                        int storyId = Convert.ToInt32(taskDataGridView.Rows[rows].Cells[0].Value.ToString());
                        if (mm.isTask_Story_IDValid(storyId) >= 0)
                        {
                            int ans = dm.TaskSetTaskStoryID(task_ID, storyId);
                        }
                        else
                        {
                            MessageBox.Show("Invalid Story id at line:" + (rows + 1));
                            updatedTaskIndexes.RemoveAt(i);
                            return;
                        }

                        int priority = Convert.ToInt32(taskDataGridView.Rows[rows].Cells[2].Value.ToString());
                        if (mm.isTask_PriorityValid(priority) >= 0)
                        {
                            dm.TaskSetTaskPriority(task_ID, priority);
                        }
                        else
                        {
                            MessageBox.Show("Invalid Priority value at line:" + (rows + 1));
                            updatedTaskIndexes.RemoveAt(i);
                            return;
                        }

                        string descriptions = taskDataGridView.Rows[rows].Cells[5].Value.ToString();
                        dm.TaskSetTaskDescription(task_ID, descriptions);

                        int ownerId = Convert.ToInt32(taskDataGridView.Rows[rows].Cells[3].Value.ToString());
                        if (mm.isTask_Ovner_IdValid(ownerId) >= 0)
                        {
                            dm.TaskSetTaskOwner(task_ID, ownerId);
                        }
                        else
                        {
                            MessageBox.Show("Invalid Owner Id at line:" + (rows + 1));
                            updatedTaskIndexes.RemoveAt(i);
                            return;
                        }
                    }
                    else
                    {
                        int storyId = Convert.ToInt32(taskDataGridView.Rows[rows].Cells[0].Value.ToString());
                        int priority = Convert.ToInt32(taskDataGridView.Rows[rows].Cells[2].Value.ToString());
                        string descriptions = taskDataGridView.Rows[rows].Cells[5].Value.ToString();
                        int ownerId = Convert.ToInt32(taskDataGridView.Rows[rows].Cells[3].Value.ToString());

                        int ans = dm.TaskAddNewTask(storyId, priority, descriptions,
                                                    ownerId);

                        MessageBox.Show("Added");
                        if (ans == -1)
                        {
                            MessageBox.Show("Error while creating new task");
                            updatedTaskIndexes.RemoveAt(i);
                            return;
                        }
                    }
            }
            int size = Convert.ToInt32(updatedTaskIndexes.Count.ToString());
            for (int i = 0; i < size; i++)
            {
                updatedTaskIndexes.RemoveAt(0);
            }
        }
Example #2
0
        private void StoryToDb()
        {
            //systemId = storydataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["SystemId"].Value.ToString();
            string id = storyDataGridView.Rows[0].Cells[0].Value.ToString();

            if (!IfStoryGreedChanged())
                return;
            DataManager dm = new DataManager();
            MathManager mm = new MathManager();

            int rows;

            if (Convert.ToInt32(updatedStoryIndexes.Count.ToString()) == 0) // no changes were found, there fore no need to save any data
                return;

            //string[] read = new string[4];

            for(int i = 0; i < Convert.ToInt32(updatedStoryIndexes.Count.ToString()); i++)
                {
                    rows = updatedStoryIndexes.ElementAt(i).getRow();
                    //MessageBox.Show("6: " + storyDataGridView.Rows[rows].Cells[6].Value.ToString() + "1: " + storyDataGridView.Rows[rows].Cells[1].Value.ToString());
                    int story_ID = Convert.ToInt32(storyDataGridView.Rows[rows].Cells[0].Value.ToString());
                    if (mm.isStory_Id_Exist(story_ID) >= 0)
                    {
                        int programmerID = Convert.ToInt32(storyDataGridView.Rows[rows].Cells[2].Value.ToString());
                        if (mm.isProgrammer_Id_Exist(Convert.ToInt32(programmerID)) >= 0)
                        {
                            dm.StorySetOwnerID(story_ID, programmerID);
                        }
                        else
                        {
                            MessageBox.Show("Invalid story owner ID at line: " + (rows + 1));
                            return;
                        }
                        // if (mm.isStory_current_Sprint_valid(DateTime.Parse(read[1])) >= 0)
                        //{
                        dm.StorySetCurrentSprint(story_ID, DateTime.Parse(storyDataGridView.Rows[rows].Cells[3].Value.ToString()));
                        //}
                        /*else
                        {
                            MessageBox.Show("Invalid date of story_current_sprint at line: " + (i + 1));
                            return;
                        }*/
                        //dm.StorySetStoryDemoDes(story_ID, storyDataGridView.Rows[rows].Cells[4].Value.ToString());
                        //dm.StorySetStoryDemoPic(story_ID);
                        dm.StorySetStoryDescription(story_ID, storyDataGridView.Rows[rows].Cells[6].Value.ToString());
                        //MessageBox.Show("Passed here");
                        int priority = Convert.ToInt32(storyDataGridView.Rows[rows].Cells[1].Value.ToString());
                        if (mm.isTask_PriorityValid(priority) >= 0)
                        {
                            dm.StorySetStoryPriority(story_ID, priority);
                        }
                        else
                        {
                            MessageBox.Show("Invalid priority value at line: " + (rows + 1));
                            return;
                        }
                        int workStatus = Convert.ToInt32(storyDataGridView.Rows[rows].Cells[7].Value.ToString());
                        dm.StorySetStoryWorkStatus(story_ID, workStatus);
                    }
                    else
                    {
                        int workStatus = Convert.ToInt32(storyDataGridView.Rows[rows].Cells[7].Value.ToString());
                        int priority = Convert.ToInt32(storyDataGridView.Rows[rows].Cells[1].Value.ToString());

                        int programmerID = Convert.ToInt32(storyDataGridView.Rows[rows].Cells[2].Value.ToString());

                        int ans = dm.StoryAddNewStory(programmerID, DateTime.Parse(storyDataGridView.Rows[rows].Cells[3].Value.ToString()), storyDataGridView.Rows[rows].Cells[4].Value.ToString(), null, storyDataGridView.Rows[rows].Cells[6].Value.ToString(),
                                                     priority, workStatus);
                        if (ans == -1)
                        {
                            MessageBox.Show("Error while creating new story");
                            return;
                        }
                    }
                }
        }