Ejemplo n.º 1
0
        private SubTask addParentSubTask(string sql, SubTask subTask)
        {
            //插入子任务
            SQLiteExecutor.execute(sql);
            //获取刚插入的数据返回
            string           sql_select       = string.Format("select id from subtask order by id desc limit 1");
            SQLiteDataReader sQLiteDataReader = SQLiteExecutor.select(sql);

            if (!sQLiteDataReader.Read())
            {
                return(subTask);
            }
            subTask.Id = sQLiteDataReader.GetInt32(0);
            return(subTask);
        }
Ejemplo n.º 2
0
        private static List <SubTask> getSubTasks(int taskId, string parentIdName)
        {
            List <SubTask>   result           = new List <SubTask>();
            string           sql_select       = string.Format($"select id,subtask_name,subtask_state from subtask where {parentIdName} = {taskId}");
            SQLiteDataReader sQLiteDataReader = SQLiteExecutor.select(sql_select);

            while (sQLiteDataReader.Read())
            {
                SubTask subTask = new SubTask();
                subTask.Id           = sQLiteDataReader.GetInt32(0);
                subTask.SubTaskName  = sQLiteDataReader.GetString(1);
                subTask.SubTaskState = sQLiteDataReader.GetInt32(2);
                result.Add(subTask);
            }
            return(result);
        }
Ejemplo n.º 3
0
        public Task addNewTask(Task task)
        {
            string sql = string.Format($"INSERT INTO task(task_name,task_priority,task_state,task_description,task_date) VALUES ('{task.TaskName}','{task.Priority}','{task.TaskState}','{task.TaskDescription}','{task.TaskDate}')");

            //插入子任务
            SQLiteExecutor.execute(sql);
            //获取刚插入的数据返回
            string           sql_select       = string.Format("select id from task order by id desc limit 1");
            SQLiteDataReader sQLiteDataReader = SQLiteExecutor.select(sql);

            if (!sQLiteDataReader.Read())
            {
                return(task);
            }
            task.TaskId = sQLiteDataReader.GetInt32(0);
            return(task);
        }
Ejemplo n.º 4
0
        private static List <Task> select(string sql_select)
        {
            SQLiteDataReader sQLiteDataReader = SQLiteExecutor.select(sql_select);
            List <Task>      result           = new List <Task>();

            while (sQLiteDataReader.Read())
            {
                int      id         = sQLiteDataReader.GetInt32(0);
                string   taskName   = sQLiteDataReader.GetString(1);
                string   desc       = sQLiteDataReader.GetString(4);
                string   dateString = sQLiteDataReader.GetString(5);
                DateTime dateTime   = DateTime.Now;
                try {
                    dateTime = Convert.ToDateTime(dateString);
                }
                catch (Exception e) {
                }
                int  priority = sQLiteDataReader.GetInt32(2);
                Task task     = new Task(id, taskName, desc, dateTime, priority);
                result.Add(task);
            }
            return(result);
        }