protected void btnNewComment_Click(object sender, EventArgs e) { lblError.Text = ""; if (currentProject != null && txtNewComment.Text != "") { Comments newComment = new Comments(); newComment.text = txtNewComment.Text; newComment.addToTask(ddlTask.SelectedItem.Value); newComment.save(); txtNewComment.Text = ""; //liste neu laden updateTasks(); } else lblError.Text = "Kommentar kann nicht gespeichert werden!"; }
// Laden aller Comments als Liste von Objekten für einen Task - Funktion wird von Tasks aufgerufen! internal static List<Comments> LoadCommentsForTasks(Tasks theTask) { SqlCommand cmd = new SqlCommand("select id, text, taskID, date from Comments where taskID = @taskID", Main.GetConnection()); cmd.Parameters.Add(new SqlParameter("taskID", theTask.id)); SqlDataReader reader = cmd.ExecuteReader(); List<Comments> allComments = new List<Comments>(); //initialisiere leere Liste von Tasks while (reader.Read()) { Comments oneComment = new Comments(); oneComment.id = reader.GetString(0); oneComment.text = reader.GetString(1); oneComment.taskID = reader.GetString(2); oneComment.dateString = reader.GetDateTime(3).ToString("dd.MM.yyyy - HH:mm")+" Uhr"; allComments.Add(oneComment); } return allComments; }