Esempio n. 1
0
 public Form2(ToDoListItem item)
 {
     InitializeComponent();
     TaskTypes2.DropDownStyle = ComboBoxStyle.DropDownList;
     this.item = item;
     Edit();
 }
Esempio n. 2
0
        private void UpdateColors(ToDoListItem toDoListItem, ListViewItem item)
        {
            DateTime dt;
            if (DateTime.TryParse(toDoListItem.date, out dt))
            {
                TimeSpan difference = dt - DateTime.Now;
                item.SubItems.Add(difference.Days.ToString());

                if (item.Checked)
                {
                    item.BackColor = Color.White;
                    item.ForeColor = Color.Gray;
                }
                else
                {
                    item.ForeColor = Color.Black;
                    if (difference.TotalDays > 1)
                    {
                        item.BackColor = Color.Green;
                    }
                    else if (difference.TotalDays >= 0)
                    {
                        item.BackColor = Color.Yellow;
                    }
                    else
                    {
                        item.BackColor = Color.Red;
                    }
                }
            }
        }
Esempio n. 3
0
 private void loadTaskFromDatabase()
 {
     using (SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Roba\Documents\Visual Studio 2013\Projects\Todo+duomb\WindowsFormsApplication6\Database.mdf;Integrated Security=True"))
     {
         con.Open();
         using (SqlCommand command = new SqlCommand("SELECT * FROM list", con))
         {
             SqlDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 int id  = reader.GetInt32(0);
                 bool check = reader.GetBoolean(1);
                 string type = reader.GetString(2);
                 string task = reader.GetString(3);
                 string date = reader.GetString(4);
                 ToDoListItem todo = new ToDoListItem(check, id, type, task, date);
                 list.AddLast(todo);
             }
         }
     }
     refreshTaskView();
 }
Esempio n. 4
0
 private void AddTask_Click(object sender, EventArgs e)
 {
     ToDoListItem todo = new ToDoListItem(false, 0, "", "", "");
     Form2 secondForm = new Form2(todo);
     if (secondForm.ShowDialog(this) == DialogResult.OK)
     {
         var item = new ListViewItem();
         item.Tag = todo;
         item.Checked = todo.check;
         item.SubItems.Add(todo.type);
         item.SubItems.Add(todo.todo);
         if (!String.IsNullOrEmpty(todo.date))
         {
             DateTime temp;
             if (DateTime.TryParse(todo.date, out temp))
             {
                 DateTime dt = DateTime.Parse(todo.date);
                 TimeSpan difference = dt - DateTime.Now;
                 item.SubItems.Add(todo.date);
                 item.SubItems.Add(difference.Days.ToString());
             }
         }
         list.AddLast(todo);
         listView1.Items.Add(item);
         refreshTaskView();
         writeTasksToDatabase();
     }
 }
Esempio n. 5
0
        private void loadTaskFile()
        {
            ToDoListItem todo = new ToDoListItem(false, 0, "", "", "");
            XmlDocument doc = new XmlDocument();

            if (new FileInfo("todo.xml").Length < 10)
            {
                return;
            }

            doc.Load("todo.xml");
            XmlNodeList elemList = doc.GetElementsByTagName("ToDo");
            list.Clear();

            foreach(XmlNode element in elemList)
            {
                string check = element["Check"].InnerText;
                string taskNumber = element["TaskNumber"].InnerText;
                string taskType = element["TaskType"].InnerText;
                string task = element["Task"].InnerText;
                string date = element["Date"].InnerText;
                int num = Convert.ToInt32(taskNumber);
                bool ch = Convert.ToBoolean(check);
                ToDoListItem ToDoItem = new ToDoListItem( ch, num, taskType, task, date);
                list.AddLast(ToDoItem);
            }

            refreshTasksView();
            doc.Save("todo.xml");
        }