예제 #1
0
 public static void AddItem(string title, string details)
 {
     try
     {
         var addThis = new tblToDo()
         {
             Title = title, Details = details, Date = DateTime.Now.Date
         };
         conn.Insert(addThis);
     }
     catch (Exception e)
     {
         Console.WriteLine("Add Error:" + e.Message);
     }
 }
예제 #2
0
 public static void EditItem(string title, string details, int listid)
 {
     try
     {
         // http://stackoverflow.com/questions/14007891/how-are-sqlite-records-updated
         var EditThis = new tblToDo()
         {
             Title = title, Details = details, ListID = listid
         };
         conn.Update(EditThis);
         //or this
         //db.Execute("UPDATE tblToDoList Set Title = ?, Details =, WHERE ID = ?", title, details, listid);
     }
     catch (Exception e)
     {
         Console.WriteLine("Update Error:" + e.Message);
     }
 }
예제 #3
0
        public static List <tblToDo> ViewAll()
        {
            try
            {
                //  return conn.Query<tblToDo>("select * from tblToDo");
                return(conn.Table <tblToDo>().ToList());
            }
            catch (Exception e)
            {
                Console.WriteLine("Error:" + e.Message);
                //making some fake items to stop the system from crashing when the DB doesn't connect
                List <tblToDo> fakeitem = new List <tblToDo>();
                //make a single item
                tblToDo item = new tblToDo {
                    ListID = 100, Date = DateTime.Now.Date, Details = "There are no items", Title = "No Items"
                };

                fakeitem.AddRange(new[] { item }); //add it to the fake item list
                return(fakeitem);
            }
        }