示例#1
0
        public void Remove(string s)
        {
            if (IsEmpty)
            {
                throw new NullReferenceException("List is Empty!");
            }

            MyToDo m = null;
            int    c = -1;

            foreach (var item in myList)
            {
                if (item.Value == s)
                {
                    m = item;
                    c = 1;
                    break;
                }
            }
            ;
            if (c == 1)
            {
                myList.Remove(m);
            }
            else
            {
                throw new Exception("string wasn't found!");
            }
        }
        public void RemoveTaskFromTable(MyToDo task)
        {
            string query = $"Use ToDoList" +
                           $" Delete From Task where [Id] ='{task.Id}'";

            using (_conection = new SqlConnection(connectionString))
            {
                _conection.Open();
                _comand = new SqlCommand(query, _conection);
                _comand.ExecuteNonQuery();
            }
        }
示例#3
0
 public void Add(MyToDo mtd)
 {
     if (IsEmpty)
     {
         myList = new List <MyToDo>();
         myList.Add(mtd);
     }
     else
     {
         myList.Add(mtd);
     }
 }
        public void AddTaskInTable(MyToDo task)
        {
            string query = $"Use ToDoList" +
                           $" Insert into Task (Id,Title) Values ('{task.Id}','{task.Value}')";

            using (_conection = new SqlConnection(connectionString))
            {
                _conection.Open();
                _comand = new SqlCommand(query, _conection);
                _comand.ExecuteNonQuery();
            }
        }