예제 #1
0
        public TaskMaster()
        {
            InitializeComponent();
            dbContext = new tmDbContext();
            var statuses = dbContext.Statuses.ToList();

            foreach (var s in statuses)
            {
                cbStatuses.Items.Add(s);
            }

            RefreshData();
        }
예제 #2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTask.Text))
            {
                MessageBox.Show("Please enter task before clicking Create button!");
                return;
            }
            if (cbStatuses.SelectedItem == null)
            {
                MessageBox.Show("Please select a status for the task!");
                return;
            }
            var dbContext = new tmDbContext();
            var status    = (cbStatuses.SelectedItem as Status);
            var newTask   = new Models.Task {
                Name = txtTask.Text, DueDate = dtDueDate.Value, StatusId = status.Id
            };

            dbContext.Tasks.Add(newTask);
            dbContext.SaveChanges();
            RefreshData();
            txtTask.Text = "";
        }