Todo Item business object
Inheritance: RealmObject
Exemplo n.º 1
0
 public TodoItemDialog (TodoItem item)
 {
     Name = item.Name;
     Notes = item.Notes;
     // TODO: ensure the completed property is displayed on the screen
     Done = item.Done;
 }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            int taskID = Intent.GetIntExtra("TaskID", 0);
            if (taskID > 0)
            {
                task = TodoItemManager.GetTask(taskID);
            }

            SetContentView(Resource.Layout.TaskDetails);
            nameTextEdit = FindViewById<EditText>(Resource.Id.NameText);
            notesTextEdit = FindViewById<EditText>(Resource.Id.NotesText);
            saveButton = FindViewById<Button>(Resource.Id.SaveButton);

            doneCheckbox = FindViewById<CheckBox>(Resource.Id.chkDone);
            doneCheckbox.Checked = task.Done;

            cancelDeleteButton = FindViewById<Button>(Resource.Id.CancelDeleteButton);

            cancelDeleteButton.Text = (task.ID == 0 ? "Cancel" : "Delete");

            nameTextEdit.Text = task.Name;
            notesTextEdit.Text = task.Notes;

            cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
            saveButton.Click += (sender, e) => { Save(); };
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            int taskID = Intent.GetIntExtra("TaskID", 0);
            if(taskID > 0) {
                task = TodoItemManager.GetTask(taskID);
            }

            // set our layout to be the home screen
            SetContentView(Resource.Layout.TaskDetails);
            nameTextEdit = FindViewById<EditText>(Resource.Id.NameText);
            notesTextEdit = FindViewById<EditText>(Resource.Id.NotesText);
            saveButton = FindViewById<Button>(Resource.Id.SaveButton);

            doneCheckbox = FindViewById<CheckBox>(Resource.Id.chkDone);
            doneCheckbox.Checked = task.Done;

            // find all our controls
            cancelDeleteButton = FindViewById<Button>(Resource.Id.CancelDeleteButton);

            // set the cancel delete based on whether or not it's an existing task
            cancelDeleteButton.Text = (task.ID == 0 ? "Cancel" : "Delete");

            nameTextEdit.Text = task.Name;
            notesTextEdit.Text = task.Notes;

            // button clicks
            cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
            saveButton.Click += (sender, e) => { Save(); };
        }
Exemplo n.º 4
0
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);
            
            transaction = TodoItemManager.BeginTransaction();

            var taskID = Intent.GetStringExtra("TaskID");
            if (taskID == null)
                task = TodoItemManager.CreateTodoItem();
            else
                task = TodoItemManager.GetTask(taskID);
            
            // set our layout to be the home screen
            SetContentView(Resource.Layout.TaskDetails);
            nameTextEdit = FindViewById<EditText>(Resource.Id.NameText);
            notesTextEdit = FindViewById<EditText>(Resource.Id.NotesText);
            saveButton = FindViewById<Button>(Resource.Id.SaveButton);

            // TODO: find the Checkbox control and set the value
            doneCheckbox = FindViewById<CheckBox>(Resource.Id.chkDone);
            doneCheckbox.Checked = task.Done;

            // find all our controls
            cancelDeleteButton = FindViewById<Button>(Resource.Id.CancelDeleteButton);
            
            // set the cancel delete based on whether or not it's an existing task
            cancelDeleteButton.Text = "Delete";
            
            nameTextEdit.Text = task.Name; 
            notesTextEdit.Text = task.Notes;

            // button clicks 
            cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
            saveButton.Click += (sender, e) => { Save(); };
        }
Exemplo n.º 5
0
		protected void ShowTaskDetails(TodoItem item)
		{
			currentItem = item;
			taskDialog = new TodoItemDialog (currentItem);
			context = new BindingContext (this, taskDialog, "Task Details");
			detailsScreen = new DialogViewController (context.Root, true);
			ActivateController(detailsScreen);
		}
Exemplo n.º 6
0
		/// <summary>Convert from DataReader to Task object</summary>
		TodoItem FromReader (SqliteDataReader r) {
			var t = new TodoItem ();
			t.ID = Convert.ToInt32 (r ["_id"]);
			t.Name = r ["Name"].ToString ();
			t.Notes = r ["Notes"].ToString ();
			t.Done = Convert.ToInt32 (r ["Done"]) == 1 ? true : false;
			return t;
		}
Exemplo n.º 7
0
 /// <summary>Convert from DataReader to Task object</summary>
 private TodoItem FromReader (SqliteDataReader r) {
     var t = new TodoItem {
         ID = Convert.ToInt32 (r["_id"]),
         Name = r["Name"].ToString (),
         Notes = r["Notes"].ToString (),
         Done = (Convert.ToInt32 (r["Done"]) == 1)
     };
     return t;
 }
Exemplo n.º 8
0
        protected void ShowTaskDetails(TodoItem item)
        {
            transaction = TodoItemManager.BeginTransaction();
            item = item ?? TodoItemManager.CreateTodoItem();

            currentItem = item;
            taskDialog = new TodoItemDialog (currentItem);
            context = new BindingContext (this, taskDialog, "Task Details");
            detailsScreen = new DialogViewController (context.Root, true);
            ActivateController(detailsScreen);
        }
Exemplo n.º 9
0
 public TodoItem GetItem (int id) {
     var t = new TodoItem ();
     lock (locker) {
         connection = new SqliteConnection ("Data Source=" + path);
         connection.Open ();
         using (var command = connection.CreateCommand ()) {
             command.CommandText = "SELECT [_id], [Name], [Notes], [Done] from [Items] WHERE [_id] = ?";
             command.Parameters.Add (new SqliteParameter (DbType.Int32) {Value = id});
             var r = command.ExecuteReader ();
             while (r.Read ()) {
                 t = FromReader (r);
                 break;
             }
         }
         connection.Close ();
     }
     return t;
 }
Exemplo n.º 10
0
 public TodoItemDialog(TodoItem item)
 {
     Name = item.Name;
     Notes = item.Notes;
     Done = item.Done;
 }
 public static int SaveTask(TodoItem item)
 {
     return(me.db.SaveItem(item));
 }
Exemplo n.º 12
0
 public static string SaveTask (TodoItem item)
 {
     me.db.SaveItem(item);
     return item.ID;
 }
Exemplo n.º 13
0
 public static int SaveTask(TodoItem item)
 {
     return(TodoItemRepositoryADO.SaveTask(item));
 }
Exemplo n.º 14
0
 public static int SaveTask (TodoItem item) {
     return TodoItemRepositoryADO.SaveTask (item);
 }
Exemplo n.º 15
0
 public void SaveItem (TodoItem item) 
 {
     // Nothing to see here...
 }
Exemplo n.º 16
0
        //save item to DataBase
        public int SaveItem(TodoItem item)
        {
            int r;
            lock (locker) {
                if (item.ID != 0) {
                    connection = new SqliteConnection ("Data Source=" + path);
                    connection.Open ();
                    using (var command = connection.CreateCommand ()) {
                        command.CommandText = "UPDATE [Items] SET [Name] = ?, [Notes] = ?, [Done] = ? WHERE [_id] = ?;";
                        command.Parameters.Add (new SqliteParameter (DbType.String) { Value = item.Name });
                        command.Parameters.Add (new SqliteParameter (DbType.String) { Value = item.Notes });
                        command.Parameters.Add (new SqliteParameter (DbType.Int32) { Value = item.Done });
                        command.Parameters.Add (new SqliteParameter (DbType.Int32) { Value = item.ID });
                        r = command.ExecuteNonQuery ();
                    }
                    connection.Close ();
                    return r;
                } else {
                    connection = new SqliteConnection ("Data Source=" + path);
                    connection.Open ();
                    using (var command = connection.CreateCommand ()) {
                        command.CommandText = "INSERT INTO [Items] ([Name], [Notes], [Done]) VALUES (? ,?, ?)";
                        command.Parameters.Add (new SqliteParameter (DbType.String) { Value = item.Name });
                        command.Parameters.Add (new SqliteParameter (DbType.String) { Value = item.Notes });
                        command.Parameters.Add (new SqliteParameter (DbType.Int32) { Value = item.Done });
                        r = command.ExecuteNonQuery ();
                    }
                    connection.Close ();
                    return r;
                }

            }
        }
		public static int SaveTask (TodoItem item)
		{
			return me.db.SaveItem(item);
		}
Exemplo n.º 18
0
        public int SaveItem(TodoItem item)
        {
            int r;

            lock (locker) {
                if (item.ID != 0)
                {
                    connection = new SqliteConnection("Data Source=" + path);
                    connection.Open();
                    using (var command = connection.CreateCommand()) {
                        command.CommandText = "UPDATE [Items] SET [Name] = ?, [Dates] = ?, [Priority] = ?, [Reminder] = ?, [Details] = ?, [Done] = ? WHERE [_id] = ?;";
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Name
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Date
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Priority
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Reminder
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Details
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.Int32)
                        {
                            Value = item.Done
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.Int32)
                        {
                            Value = item.ID
                        });
                        r = command.ExecuteNonQuery();
                    }
                    connection.Close();
                    return(r);
                }
                else
                {
                    connection = new SqliteConnection("Data Source=" + path);
                    connection.Open();
                    using (var command = connection.CreateCommand()) {
                        command.CommandText = "INSERT INTO [Items] ([Name], [Dates], [Priority], [Reminder], [Details], [Done]) VALUES (? ,?, ?, ?, ?, ?)";
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Name
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Date
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Priority
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Reminder
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.String)
                        {
                            Value = item.Details
                        });
                        command.Parameters.Add(new SqliteParameter(DbType.Int32)
                        {
                            Value = item.Done
                        });
                        r = command.ExecuteNonQuery();
                    }
                    connection.Close();
                    return(r);
                }
            }
        }