public void addNewList(ProjectList newProjectList) { mySqlConnection.Open(); MySqlCommand cmd = mySqlConnection.CreateCommand(); cmd.CommandText = String.Format( "INSERT INTO Lists(id,projectId,title,priority) " + "VALUES ({0},'{1}','{2}','{3}');", newProjectList.Id, newProjectList.ProjectId, newProjectList.getName(), newProjectList.getListPriority()); cmd.ExecuteNonQuery(); mySqlConnection.Close(); }
internal void removeList(ProjectList list) { mySqlConnection.Open(); MySqlCommand cmd = mySqlConnection.CreateCommand(); cmd.CommandText = String.Format( "DELETE FROM Lists " + "WHERE id = {0};", list.Id); cmd.ExecuteNonQuery(); mySqlConnection.Close(); }
private void CreateButton_Click(object sender, RoutedEventArgs e) { string listTitle = ListTitleTextBox.Text; string listPriority = (PriorityComboBox.SelectedItem as ComboBoxItem).Content as string; int id = DatabaseHandler.generateNextProjectListId(); ProjectList newProjectList = new ProjectList(id, projectId, listTitle, listPriority, new List <Task> ()); DatabaseHandler.getInstance().addNewList(newProjectList); callerWindow.GenerateProjectListUI(newProjectList); callerWindow.AddNewList(newProjectList); this.Close(); callerWindow.IsEnabled = true; }
public ProjectList getListFromId(int listId) { ProjectList projectList = null; List <Task> tasks = getTasksForListId(listId); try { mySqlConnection.Open(); } catch (Exception e) { // was already open } MySqlCommand cmd = mySqlConnection.CreateCommand(); cmd.CommandText = String.Format( "SELECT id, title, priority, projectId " + "FROM Lists " + "WHERE id = {0} ", listId); using (MySqlDataReader reader = cmd.ExecuteReader()) { List <int> userIds = new List <int> (); while (reader.Read()) { int id = reader.GetInt32(0); string listName = reader.GetString(1); string priority = reader.GetString(2); int projectId = reader.GetInt32(3); projectList = new ProjectList(id, projectId, listName, priority, tasks); } } mySqlConnection.Close(); return(projectList); }
internal void AddProjectList(ProjectList newProjectList) { projectLists.Add(newProjectList); }
internal void AddNewList(ProjectList newProjectList) { activeProject.AddProjectList(newProjectList); }
public void GenerateProjectListUI(ProjectList newProjectList) { string listName = newProjectList.getName(); string listPriority = newProjectList.getListPriority(); MainStackPanel.Children.Add(new Separator() { Width = 20, Visibility = Visibility.Hidden }); StackPanel newStackPanel = new StackPanel(); newStackPanel.Width = 120; newStackPanel.Margin = new Thickness(0, 10, 0, 10); newStackPanel.Background = new SolidColorBrush(Colors.LightGray); Button deleteListButton = new Button() { Content = "-", FontSize = 16, HorizontalAlignment = HorizontalAlignment.Right, Tag = newProjectList, Height = 12, Margin = new Thickness(0, 6, 6, 0), }; deleteListButton.Click += DeleteListButton_Click; newStackPanel.Children.Add(deleteListButton); Label listHeaderLabel = new Label(); listHeaderLabel.Content = listName; newStackPanel.Children.Add(listHeaderLabel); ComboBox priorityComboBox = new ComboBox(); ComboBoxItem lowPriority = new ComboBoxItem(); lowPriority.Content = "Low"; ComboBoxItem mediumPriority = new ComboBoxItem(); mediumPriority.Content = "Medium"; ComboBoxItem highPriority = new ComboBoxItem(); highPriority.Content = "High"; priorityComboBox.Items.Add(lowPriority); priorityComboBox.Items.Add(mediumPriority); priorityComboBox.Items.Add(highPriority); switch (listPriority) { case "Low": priorityComboBox.SelectedIndex = 0; break; case "Medium": priorityComboBox.SelectedIndex = 1; break; case "High": priorityComboBox.SelectedIndex = 2; break; } newStackPanel.Children.Add(priorityComboBox); newStackPanel.Children.Add(new Separator() { Visibility = Visibility.Hidden }); Button addTaskButton = new Button(); addTaskButton.Click += AddTaskButton_Click; addTaskButton.Content = "+"; addTaskButton.Width = 20; addTaskButton.Height = 20; addTaskButton.HorizontalAlignment = HorizontalAlignment.Left; addTaskButton.Margin = new Thickness(10, 0, 0, 0); addTaskButton.Tag = newStackPanel; newStackPanel.Tag = newProjectList.Id; newStackPanel.Children.Add(addTaskButton); MainStackPanel.Children.Add(newStackPanel); Button addNewButton = null; foreach (var child in MainStackPanel.Children) { if (child is Button) { addNewButton = child as Button; } } // Generate tasks UI List <Task> tasks = DatabaseHandler.getInstance().getTasksOnList(newProjectList); foreach (Task task in tasks) { AddNewTaskToList(task, newStackPanel); } MainStackPanel.Children.Remove(addNewButton); MainStackPanel.Children.Add(addNewButton); }