예제 #1
0
        public void TaskLabel_Click(object sender, EventArgs e)
        {
            Label    taskLabel = sender as Label;
            int      id        = Convert.ToInt32(taskLabel.Name.Split("_")[1]);
            NoteTask t         = NoteTask.GetTaskById(id);

            if (t == null)
            {
                return;
            }
            worker.SwitchTaskStatus(t);
            onTaskLabelClicked?.Invoke(taskLabel, t.IsComplete);
        }
예제 #2
0
        public List <Note> LoadNotesFromSQLite()
        {
            List <Note>      noteList = new List <Note>();
            SQLiteCommand    cmd      = new SQLiteCommand("SELECT id, name, text, type, img, color, date, updateDate, isDelete, alarmDate FROM Notes", sqlConn);
            SQLiteDataReader er       = cmd.ExecuteReader();

            while (er.Read())
            {
                int    id;
                string name    = "";
                string text    = "";
                string type    = "";
                string imgPath = "";
                Image  screenShot;
                int    color      = 0;
                string date       = null;
                string updateDate = null;
                int    isDelete   = 0;
                string alarmDate  = null;


                id = er.GetInt32(0);
                try { name = er.GetString(1); } catch { }
                try { text = er.GetString(2); } catch { }
                try { type = er.GetString(3); } catch { }
                try { imgPath = er.GetString(4); } catch { }
                try
                {
                    screenShot = Image.FromFile(imgPath);
                }
                catch
                {
                    screenShot = null;
                }
                try { color = er.GetInt32(5); } catch { }
                try { date = er.GetString(6); } catch { }
                try { updateDate = er.GetString(7); } catch { }
                try { isDelete = er.GetInt32(8); } catch { }
                try {
                    alarmDate = er.GetString(9);
                }
                catch (Exception e)
                {
                }

                Note newNote = null;
                switch (type)
                {
                case "Screenshot":
                    newNote = new Screenshot(screenShot, imgPath);
                    break;

                case "Common":
                    newNote = new Common();
                    break;

                case "Alarm":
                    newNote = new Alarm(Convert.ToDateTime(alarmDate));
                    break;

                case "ToDoList":
                    newNote = new ToDoList();
                    break;

                default:
                    newNote = new Common();
                    break;
                }
                newNote.Id   = id;
                newNote.Name = name;
                newNote.Text = text;
                //newNote.Img = img;
                newNote.ARGBColor  = color;
                newNote.RegDate    = Convert.ToDateTime(date);
                newNote.UpdateDate = Convert.ToDateTime(updateDate);
                newNote.IsDelete   = Convert.ToBoolean(isDelete);
                noteList.Add(newNote);
            }
            er.Close();

            foreach (Note n in noteList)
            {
                if (n.GetType() != typeof(ToDoList))
                {
                    continue;
                }
                ToDoList        toDo     = n as ToDoList;
                List <NoteTask> taskList = new List <NoteTask>();
                cmd = new SQLiteCommand("SELECT id,name,complete,note_id FROM tasks WHERE `note_id` = '" + n.Id + "'", sqlConn);
                er  = cmd.ExecuteReader();
                while (er.Read())
                {
                    int      id         = er.GetInt32(0);
                    string   name       = er.GetString(1);
                    bool     isComplete = Convert.ToBoolean(er.GetInt32(2));
                    NoteTask newTask    = new NoteTask(id, name, isComplete);
                    taskList.Add(newTask);
                }
                toDo.SetTaskList(taskList);
                er.Close();
            }

            return(noteList);
        }
예제 #3
0
        public void UpdateTask(NoteTask task)
        {
            SQLiteCommand cmd = new SQLiteCommand("UPDATE tasks SET `complete` = '" + Convert.ToInt32(task.IsComplete) + "' WHERE `id`=" + task.Id, sqlConn);

            cmd.ExecuteNonQuery();
        }