Exemplo n.º 1
0
        private void DeleteData()
        {
            var t = tmContext.Tasks.Find((int)dataGridView1.SelectedCells[0].Value);

            tmContext.Tasks.Remove(t);
            tmContext.SaveChanges();

            RefreshData();
        }
Exemplo n.º 2
0
        private void cmdCreateTask_Click(object sender, EventArgs e)
        {
            if (cboStatus.SelectedItem != null && txtTask.Text != String.Empty)
            {
                var newTask = new Model.Task
                {
                    Name     = txtTask.Text,
                    StatusId = (cboStatus.SelectedItem as Model.Status).Id,
                    DueDate  = dateTimePicker1.Value
                };

                tmContext.Tasks.Add(newTask);
                tmContext.SaveChanges();
                refreshData();
            }
            else
            {
                MessageBox.Show("Please make sure all data has been entered");
            }
        }
Exemplo n.º 3
0
        private void cmdCreateTask_Click(object sender, EventArgs e)
        {
            if (cboStatus.SelectedItem != null && txtTask.Text != String.Empty)
            {
                var newTask = new Model.Task
                {
                    Name     = txtTask.Text,
                    StatusId = (cboStatus.SelectedItem as Model.Status).Id,
                    DueDate  = dateTimePicker1.Value
                };
                tmContext.Tasks.Add(newTask); //tmContext keeps a list of things that need to get done,
                //that haven't been activated in the Database

                tmContext.SaveChanges();   //adds to Database
                refreshData();
            }
            else
            {
                MessageBox.Show("Please make sure all data has been entered");
            }
        }
Exemplo n.º 4
0
        private void cmdCreateTask_Click(object sender, EventArgs e)
        {
            if (cboStatus.SelectedItem != null && txtTask.Text != String.Empty)
            {
                var newTask = new Model.Task
                {
                    Name     = txtTask.Text,
                    StatusId = (cboStatus.SelectedItem as Model.Status).Id,
                    DueDate  = dateTimePicker1.Value
                };

                tmContext.Tasks.Add(newTask);

                tmContext.SaveChanges();
                refreshGrid();
            }
            else
            {
                MessageBox.Show("You must select a Task Status and enter a Task description.");
            }
        }
Exemplo n.º 5
0
        private void cmdCreateTask_Click(object sender, EventArgs e)
        {
            if (cboStatus.SelectedItem != null & txtTask.Text != String.Empty)
            {
                var newTask = new Models.Task
                {
                    Name     = txtTask.Text,
                    StatusId = (cboStatus.SelectedItem as Models.Status).Id, // fk na tabela task
                    DueDate  = dateTimePicker1.Value
                };

                tmContext.Tasks.Add(newTask); // adicionar à coleção Tasks
                tmContext.SaveChanges();      // registrar no banco

                refreshData();
            }
            else
            {
                MessageBox.Show("Preencha o formulário corretamente.");
            }
        }