private void UpdateTaskCreateButton_Click(object sender, RoutedEventArgs e) { try { // get id of the task DB1 = new DBManager(); task t = DB1.GetTasks("SELECT a.* FROM tasks a , projects b WHERE a.project_id = b.project_id AND a.task_name = '" + this.UpdateTaskTaskNameTextBox.Text + "' AND b.project_name = '" + this.UpdateTaskProjectNameTextBox.Text + "'").First(); // fill the records t.start_date = (DateTime) this.UpdateTaskStartDatePicker.SelectedDate; t.end_date = (DateTime) this.UpdateTaskDeadlineDatePicker.SelectedDate; t.employee_id = DB1.GetEmployees("SELECT * from employees where employee_name = '" + this.UpdateTaskForemanTextBox.Text + "'").First().employee_id; t.budget = Convert.ToInt32(this.UpdateTaskBudgetTextBox.Text); if (DB1.UpdateTask(t)) { MessageBox.Show("Task has been updated"); EmptyAllfields(this.UpdateTasksGrid); Initialization(); } } catch { } }
private void UpdateTaskTaskNameTextBox_TextChanged(object sender, RoutedEventArgs e) { try { // get a list of all project with same name DB1 = new DBManager(); Debug.WriteLine("SELECT a.* FROM tasks a , projects b WHERE a.project_id = b.project_id AND a.task_name = '" + this.UpdateTaskTaskNameTextBox.Text +" AND b.project_name = '" + this.UpdateTaskProjectNameTextBox.Text + "'"); task t = DB1.GetTasks("SELECT a.* FROM tasks a , projects b WHERE a.project_id = b.project_id AND a.task_name = '" + this.UpdateTaskTaskNameTextBox.Text + "' AND b.project_name = '" + this.UpdateTaskProjectNameTextBox.Text + "'").First(); // fill the records this.UpdateTaskStartDatePicker.SelectedDate = t.start_date; this.UpdateTaskDeadlineDatePicker.SelectedDate = t.end_date; this.UpdateTaskForemanTextBox.Text = DB1.GetEmployees("select a.* from employees a , tasks b where a.employee_id = b.employee_id AND b.task_id = " + t.task_id).First().employee_name.ToString(); this.UpdateTaskBudgetTextBox.Text = t.budget.ToString(); } catch { } }
private void TasksSummary() { try { DB1 = new DBManager(); this.RunningTasksListView.ItemsSource = DB1.GetTasks("SELECT * FROM tasks WHERE start_date < '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "' AND end_date > '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "'"); Debug.WriteLine("SELECT * FROM tasks WHERE start_date < '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "' AND end_date > '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "'"); this.AllTasksDatagrid.ItemsSource = DB1.GetRawData("SELECT a.task_name AS 'ALL TASKS' , b.project_name FROM tasks a , projects b WHERE a.project_id = b.project_id").DefaultView; } catch { } }