private void button_Click(object sender, RoutedEventArgs e) { DateTime current = DateTime.Now.Date; DateTime taskTime = (DateTime)Dpick.SelectedDate; int result = DateTime.Compare(current, taskTime); if (result > 0) { MessageBox.Show("Ви не можете створити завдання на попереднє число."); } else { string richText = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd).Text; Tasks task = new Tasks(); task.taskDate = Dpick.SelectedDate.ToString(); task.taskName = richText; task.taskPriority = comboBox.SelectedValue.ToString(); task.taskStatus = defaultStatus; CRUD crud = new CRUD(); task.UserID=crud.getId(); crud.Add(task); //MessageBox.Show(task.taskName); this.Close(); } }
public void Add(Tasks t) { using (TaskManEntities tme = new TaskManEntities()) { tme.Tasks.Add(t); tme.SaveChanges(); } }