Пример #1
0
        public static List<Task> DBGetTasks(string userid)
        {
            List<Task> tasks = new List<Task>();
            MySqlConnection cn = new MySqlConnection(ConfigurationManager.ConnectionStrings["sldbConnectionString"].ConnectionString);
            MySqlCommand cmd = new MySqlCommand();

            string sSql = String.Format("CALL `schultzlegenddb`.`TRACKER_TASKS_GET_BY_USERID`('{0}');", userid);

            cmd.Connection = cn;
            cmd.CommandText = sSql;
            cmd.Connection.Open();
            MySqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

            while (reader.Read())
            {
                Task task = new Task();
                task.Name = Convert.ToString(reader["name"]);
                task.UserId = Convert.ToString(reader["user"]);
                task.TaskId = (int)reader["task_id"];
                task.Parent = (int)reader["parent"];
                task.Complete = (sbyte)reader["complete"];
                task.Priority = (int)reader["priority"];
                tasks.Add(task);
            }
            reader.Close();
            cmd.Connection.Close();
            return tasks;
        }
Пример #2
0
        public static Task DBGetTaskByName(string name)
        {
            Task task = new Task();
            MySqlConnection cn = new MySqlConnection(ConfigurationManager.ConnectionStrings["sldbConnectionString"].ConnectionString);
            MySqlCommand cmd = new MySqlCommand();

            string sSql = String.Format("CALL `schultzlegenddb`.`TRACKER_TASK_GET_BY_NAME`('{0}');", name);

            cmd.Connection = cn;
            cmd.CommandText = sSql;
            cmd.Connection.Open();
            MySqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

            if (reader.Read())
            {
                task.Name = Convert.ToString(reader["name"]);
                task.UserId = Convert.ToString(reader["user"]);
                task.TaskId = (int)reader["task_id"];
                task.Parent = (int)reader["parent"];
                task.Complete = (sbyte)reader["complete"];
                task.Priority = (int)reader["priority"];
            }
            reader.Close();
            cmd.Connection.Close();
            return task;
        }