Ejemplo n.º 1
0
        protected void btnModify_Click(object sender, EventArgs e)
        {
            int listId = Convert.ToInt32(txtListId.Text);
            Models.TaskList task = context.TaskLists.Where(t => t.ListId == listId).SingleOrDefault();

            task.Name = txtName.Text;
            task.Priority = Convert.ToInt32(listPriority.SelectedValue);
            task.IsComplete = Convert.ToBoolean(checkIsCompleted.Checked);

            context.SaveChanges();

            DisplayData();
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int listId = Convert.ToInt32(txtListId.Text);

            Models.TaskList task = (from t in context.TaskLists
                                    where t.ListId == listId
                                    select t).SingleOrDefault();

            if (task != null)
            {
                context.TaskLists.Remove(task);
                context.SaveChanges();
            }
            else
            {
                lblerror.Text = "There is no data to be deleted";
            }

            DisplayData();
        }
Ejemplo n.º 3
0
        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            // data input by using ef4

            // create context object
            Models.TaskDBEntities context = new Models.TaskDBEntities();

            // create input object
            Models.TaskList task = new Models.TaskList();
            task.Name        = txtName.Text;
            task.IsComplete  = false;
            task.Priority    = ListPriority.SelectedIndex + 1;
            task.DateCreated = DateTime.Now;

            // data assign into context object
            context.TaskLists.Add(task);

            // execute
            context.SaveChanges();
        }
        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            // data input by using ef4

            // create context object
            Models.TaskDBEntities context = new Models.TaskDBEntities();

            // create input object
            Models.TaskList task = new Models.TaskList();
            task.Name = txtName.Text;
            task.IsComplete = false;
            task.Priority = ListPriority.SelectedIndex + 1;
            task.DateCreated = DateTime.Now;

            // data assign into context object
            context.TaskLists.Add(task);

            // execute
            context.SaveChanges();
        }