public static void CreateNewTask(string parentBusiness, WorkTask task, string xml = BasicPath) { XDocument doc = XDocument.Load(xml); XElement business = doc.Root.Elements("Business") .SingleOrDefault(b => b.Element("BusinessTitle").Value == parentBusiness); if (business == null) { return; } int tasksCount = business.Descendants("Task") == null ? 0 : business.Descendants("Task").Count(); if (business.Element("Tasks") == null) { business.Add(new XElement("Tasks")); } var taskNode = new XElement("Task", new XAttribute("Index", tasksCount), new XElement("Title", task.Title), new XElement("Describe", task.Content), new XElement("Priority", task.Priority), new XElement("Accomplished", task.Accomplished)); business.Element("Tasks").Add(taskNode); doc.Save(xml); }
private void TaskListView_MouseDoubleCick(object sender, MouseButtonEventArgs e) { WorkTask selected = (sender as ListView).SelectedItem as WorkTask; if (selected == null) { return; } else if (SelectedTask != null && SelectedTask.Equals(selected)) { TitleTextbox.Text = ""; DescribeTextbox.Text = ""; TaskPriorityTextbox.Text = ""; AccomplishCheckBox.IsChecked = false; AddFileBtn.IsEnabled = false; FileListbox.ItemsSource = null; SelectedTask = null; return; } TitleTextbox.Text = selected.Title; DescribeTextbox.Text = selected.Content; TaskPriorityTextbox.Text = selected.Priority.ToString(); AccomplishCheckBox.IsChecked = selected.Accomplished; FileListbox.ItemsSource = IOBusiness.GetTaskFileNames(BusinessName, selected.Title); AddFileBtn.IsEnabled = true; SelectedTask = selected; }
private void CreateNewTaskBtn_Click(object sender, RoutedEventArgs e) { if (TitleTextbox.Text != "" && DescribeTextbox.Text != "" && TaskPriorityTextbox.Text != "") { Result = new WorkTask(0, TitleTextbox.Text, DescribeTextbox.Text, TaskPriorityTextbox.Text); XmlBusinessManager.CreateNewTask(business, Result); BusinessMessageBox.Show($"새 업무, {Result.Title}를 생성 완료했습니다.", "업무 생성"); this.Close(); } else { BusinessMessageBox.Show("빈 칸을 채워주세요.", "정보 입력"); } }
private void DeleteTaskBtn_Click(object sender, RoutedEventArgs e) { if (SelectedTask == null) { BusinessMessageBox.Show("선택된 업무가 없습니다.", "삭제 실패"); return; } else if (BusinessMessageBox.Show($"정말 {SelectedTask.Title}를 삭제하시겠습니까?", "삭제", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { XmlBusinessManager.DeleteTask(BusinessName, SelectedTask.Index); BusinessMessageBox.Show($"{SelectedTask.Title}에 대한 삭제가 완료되었습니다.", "삭제 완료"); SelectedTask = null; RefreshTaskListView(); } }