Ejemplo n.º 1
0
        public bool addSubTask(SubTask inTask)
        {
            MySqlConnection conn    = null;
            MySqlCommand    command = null;

            try{
                conn = new MySqlConnection(connectionString);
                conn.Open();

                command = new MySqlCommand(
                    "INSERT INTO 'SubTask' (SubTaskID, DueDate, isComplete, FilePath, Title, Description, RepeatFrom) VALUES (@subTaskID, @dueDate, @isComplete, @filePath, @title, @description, @repeatFrom", conn
                    );

                command.Parameters.AddWithValue("@subTaskId", inTask.getId());
                command.Parameters.AddWithValue("@dueDate", inTask.getDueDate());
                command.Parameters.AddWithValue("@isComplete", inTask.isComplete());
                command.Parameters.AddWithValue("@title", inTask.getTitle());
                command.Parameters.AddWithValue("@description", inTask.getNotes());
                command.Parameters.AddWithValue("@repeatfrom", null);

                command.ExecuteNonQuery();
            }catch (Exception ex) {
                Console.WriteLine("this is not supposed to happen" + ex);
                return(false);
            }
            finally{
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(true);
        }