private void deleteButton_Click(object sender, RoutedEventArgs e) { TaskTable selectedTask = (TaskTable)todogrid.SelectedItem; if (selectedTask != null) { using (var context = new ScheduleUpDBEntities()) { context.Entry(selectedTask).State = EntityState.Deleted; context.SaveChanges(); } todoTaskTable.Remove(selectedTask); todogrid.ItemsSource = null; todogrid.ItemsSource = todoTaskTable; } else { var message = "You didn't pick any task"; if ((TaskTable)donegrid.SelectedItem != null) { message = "Can not delete task in \"DONE\" status. Please change task status as \"ToDo\" or \"InProgress\" and try deleting again."; } MessageBox.Show(message, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void done_button_Click(object sender, RoutedEventArgs e) { TaskTable selectedTask = (TaskTable)todogrid.SelectedItem; todoTaskTable.Remove(selectedTask); if (selectedTask != null) { using (var context = new ScheduleUpDBEntities()) { var updateTask = context.TaskTable.Where(x => x.TaskID == selectedTask.TaskID).FirstOrDefault(); updateTask.TaskStatu = "Done"; context.SaveChanges(); doneTaskTable.Add(updateTask); } todogrid.ItemsSource = null; todogrid.ItemsSource = todoTaskTable; donegrid.ItemsSource = null; donegrid.ItemsSource = doneTaskTable; } else { var message = "Nothing Selected From Active Tasks Table"; MessageBox.Show(message, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
public MainWindow(UserTable parameter) : this() { InitializeComponent(); this.parameter = parameter; signedAsLabel.Content = "Signed As : " + parameter.userName; ScheduleUpDBEntities context = new ScheduleUpDBEntities(); TaskTable tb = new TaskTable() //test data ekleme { TaskID = Guid.NewGuid(), TaskContent = "intest", TaskAssignedTo = "26C741D5-1758-4CA7-B802-85BFAF64B587", TaskCreator = "26C741D5-1758-4CA7-B802-85BFAF64B587", TaskEndDate = new DateTime(1995, 10, 20), TaskStartDate = new DateTime(1995, 10, 21), TaskTitle = "test", TaskStatu = "Todo" }; context.TaskTable.Add(tb); context.SaveChanges(); var TotalTaskList = context.TaskTable.Where(x => x.TaskAssignedTo == parameter.userID.ToString()).ToList(); #region Task Tablolarını Doldurur var todoTaskList = TotalTaskList.Where(x => x.TaskStatu.ToUpper() == "TODO" || x.TaskStatu.ToUpper() == "INPROGRESS").ToList(); foreach (var todoTask in todoTaskList) { todoTaskTable.Add(todoTask); } todogrid.ItemsSource = todoTaskTable; var doneTaskList = TotalTaskList.Where(x => x.TaskStatu.ToUpper() == "DONE").ToList(); foreach (var doneTask in doneTaskList) { doneTaskTable.Add(doneTask); } donegrid.ItemsSource = doneTaskTable; #endregion }
private void todo_button_Click(object sender, RoutedEventArgs e) { TaskTable selectedTask = (TaskTable)todogrid.SelectedItem; if (selectedTask == null) { selectedTask = (TaskTable)donegrid.SelectedItem; doneTaskTable.Remove(selectedTask); donegrid.ItemsSource = null; donegrid.ItemsSource = doneTaskTable; } else { todoTaskTable.Remove(selectedTask); } if (selectedTask != null) { if (selectedTask.TaskStatu.ToUpper() == "TODO") { var message = "Selected Task Statu Already \"ToDo\""; MessageBox.Show(message, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } else { using (var context = new ScheduleUpDBEntities()) { var updateTask = context.TaskTable.Where(x => x.TaskID == selectedTask.TaskID).FirstOrDefault(); updateTask.TaskStatu = "ToDo"; context.SaveChanges(); todoTaskTable.Add(updateTask); todogrid.ItemsSource = null; todogrid.ItemsSource = todoTaskTable; } } } else { var message = "You didn't pick any task"; MessageBox.Show(message, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void createAccountButton_Click(object sender, RoutedEventArgs e) { UserTable new_user = new UserTable { userID = Guid.NewGuid(), userName = r_usernameBox.Text, name = r_nameBox.Text, surname = r_surnameBox.Text, email = r_emailBox.Text, password = r_passwordBox.Password, }; using (var context = new ScheduleUpDBEntities()) { if (new_user.name == string.Empty || new_user.surname == string.Empty || new_user.password == string.Empty || new_user.userName == string.Empty) { MessageBox.Show("Username, name, surname, password can not be null", "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } else { var accountExist = context.UserTable.Where(x => x.userName == new_user.userName).ToList(); if (accountExist.Count != 0) { MessageBox.Show("the username has already been taken", "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } else { context.UserTable.Add(new_user); context.SaveChanges(); MessageBox.Show("Account Successfully Created", "Alert", MessageBoxButton.OK, MessageBoxImage.Information); LoginScreen loginWindow = new LoginScreen(); loginWindow.Show(); this.Close(); } } } }
private void button_Click(object sender, RoutedEventArgs e) { using (var context = new ScheduleUpDBEntities()) { UserTable user = AssignedTo.SelectedItem as UserTable; var new_task = new TaskTable() { TaskID = Guid.NewGuid(), TaskTitle = titleBox.Text, TaskContent = contentBox.Text, TaskCreator = parameter.userID.ToString(), TaskAssignedTo = user.userID.ToString(), TaskStartDate = startDate.SelectedDate.Value.Date, TaskEndDate = endDate.SelectedDate.Value.Date, TaskStatu = "TODO" }; context.TaskTable.Add(new_task); context.SaveChanges(); MessageBox.Show("Task Successfully Created", "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }