private void Btn_createProject_Click(object sender, RoutedEventArgs e) { try { int parsedValue; var pro = TestStorage.ReadXml <ObservableCollection <Project> >("Projects.xml"); var project = new ObservableCollection <Project>(); Project ps = new Project(); XmlDocument doc = new XmlDocument(); doc.Load("Projects.xml"); int count = 1; foreach (XmlNode xn in doc.SelectNodes("ArrayOfProject/Project")) { count = count + 1; } string projectID = Convert.ToString(count); ps.ProjectId = projectID; ps.ProjectTitle = projectTitle.Text; ps.ProjectDescription = projectDescription.Text; ps.StartDate = startDate.Text; ps.EndDate = endDate.Text; ps.ToDoLimit = toDoLimit.Text; ps.WorkInProgressLimit = workInProgressLimit.Text; ps.DoneLimit = doneLimit.Text; if (string.IsNullOrEmpty(projectTitle.Text) || string.IsNullOrEmpty(projectDescription.Text) || string.IsNullOrEmpty(startDate.Text) || string.IsNullOrEmpty(endDate.Text) || string.IsNullOrEmpty(toDoLimit.Text) || string.IsNullOrEmpty(workInProgressLimit.Text) || string.IsNullOrEmpty(doneLimit.Text)) { MessageBox.Show("Please enter all the values"); } else if (!int.TryParse(toDoLimit.Text, out parsedValue)) { MessageBox.Show("Please enter numeric value in set to do limit field "); return; } else if (!int.TryParse(workInProgressLimit.Text, out parsedValue)) { MessageBox.Show("Please enter numeric value in set work in progress limit field "); return; } else if (!int.TryParse(doneLimit.Text, out parsedValue)) { MessageBox.Show("Please enter numeric value in set done limit field "); return; } else { pro.Add(ps); TestStorage.WriteXml <ObservableCollection <Project> >(pro, "Projects.xml"); var gobacktomain = new MainWindow(); gobacktomain.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// update projectdetails private void Btn_updateproject_Click(object sender, RoutedEventArgs e) { int parsedValue; var pro = TestStorage.ReadXml <ObservableCollection <Project> >("Projects.xml"); var project = new ObservableCollection <Project>(); //Project ps = new Project(); var ps = pro.First(f => f.ProjectId == getprojectid.Text); ps.ProjectTitle = projectTitle.Text; ps.ProjectTitle = projectTitle.Text; ps.ProjectDescription = projectDescription.Text; ps.StartDate = startDate.Text; ps.EndDate = endDate.Text; ps.ToDoLimit = toDoLimit.Text; ps.WorkInProgressLimit = workInProgressLimit.Text; ps.DoneLimit = doneLimit.Text; if (string.IsNullOrEmpty(projectTitle.Text) || string.IsNullOrEmpty(projectDescription.Text) || string.IsNullOrEmpty(startDate.Text) || string.IsNullOrEmpty(endDate.Text) || string.IsNullOrEmpty(toDoLimit.Text) || string.IsNullOrEmpty(workInProgressLimit.Text) || string.IsNullOrEmpty(doneLimit.Text)) { MessageBox.Show("Please enter all the values "); } else if (!int.TryParse(toDoLimit.Text, out parsedValue)) { MessageBox.Show("Please enter numeric value in set to do limit field "); return; } else if (!int.TryParse(workInProgressLimit.Text, out parsedValue)) { MessageBox.Show("Please enter numeric value in work set in progress limit field "); return; } else if (!int.TryParse(doneLimit.Text, out parsedValue)) { MessageBox.Show("Please enter numeric value set in done limit field "); return; } else { TestStorage.WriteXml <ObservableCollection <Project> >(pro, "Projects.xml"); successMsg.Visibility = Visibility.Visible; var gotomainwindow = new MainWindow(); gotomainwindow.Show(); this.Close(); } }
//Update task private void Btn_updatetaskd_Click(object sender, RoutedEventArgs e) { // to get and the task status from the combobox to check work in progress condition var tsk = TestStorage.ReadXml <ObservableCollection <Task> >("Tasks.xml"); var tssk = new ObservableCollection <Task>(); var br = tsk.First(f => f.TaskId == updatetaskid.Text); br.TaskStatus = taskstatus.SelectionBoxItem.ToString(); // to get the value of work in progress for the project. var project = TestStorage.ReadXml <ObservableCollection <Project> >("Projects.xml"); var proj = new ObservableCollection <Project>(); var pr = project.First(f => f.ProjectId == id); string wipcount = pr.WorkInProgressLimit; int wipCount = Convert.ToInt32(wipcount); // MessageBox.Show(wipcount); // to get the number of tasks which have number of taskstatus as work in progress XmlDocument docu = new XmlDocument(); docu.Load("Tasks.xml"); int count = 0; string selectval = relatedtasks.SelectedItem.ToString(); foreach (XmlNode x in docu.SelectNodes("ArrayOfTask/Task")) { string taskstat = x.SelectSingleNode("TaskStatus").InnerText; string prid = x.SelectSingleNode("ProjectId").InnerText; string tsid = x.SelectSingleNode("TaskId").InnerText; if (taskstat == "workinprogress" && prid == id) { count = count + 1; } if (selectval == tsid) { selectedtaskstatus = x.SelectSingleNode("TaskStatus").InnerText; } } string value = Convert.ToString(count); // MessageBox.Show(value); if (relatedtasks.SelectedItem.ToString() != "No Selection" & (br.TaskStatus == "done" || br.TaskStatus == "workinprogress") & selectedtaskstatus != "done") { string selecttask = relatedtasks.SelectedItem.ToString(); MessageBox.Show("Sorry task is dependent on Task " + selecttask + " Complete it inorder to update"); } else if (wipCount == count & br.TaskStatus != "done") { MessageBox.Show("Oooopss you have reached to the limit No. of Tasks as Work in progress first complete other Task and then add more task in Progress"); } else { var tak = TestStorage.ReadXml <ObservableCollection <Task> >("Tasks.xml"); var task = new ObservableCollection <Task>(); var ps = tak.First(f => f.TaskId == updatetaskid.Text); ps.TaskTitle = dtaskTitle.Text; ps.TaskDescription = dtaskDescription.Text; ps.TaskPriority = taskprioritys.SelectionBoxItem.ToString(); ps.TaskNotes = dtaskNote.Text; ps.TaskStatus = taskstatus.SelectionBoxItem.ToString(); if (string.IsNullOrEmpty(dtaskTitle.Text) || string.IsNullOrEmpty(dtaskDescription.Text) || string.IsNullOrEmpty(dtaskNote.Text)) { MessageBox.Show("Please enter all the values"); } else { TestStorage.WriteXml <ObservableCollection <Task> >(tak, "Tasks.xml"); var gotokanbanboard = new Kanbanboard(id); gotokanbanboard.Show(); this.Close(); } } }