public override bool OnOptionsItemSelected(IMenuItem item)
        {
            //when click it will add data to data base
            int id = item.ItemId;

            if (id == Resource.Id.action_add)
            {
                if (location.Text != "" && start.Text != "" && end.Text != "" && title.Text != "" && description.Text != "")
                {
                    PlannerData data = new PlannerData()
                    {
                        Location    = location.Text,
                        Starts      = start.Text + "-" + start_time.Text,
                        Ends        = end.Text + "-" + end_time.Text,
                        Title       = title.Text,
                        Description = description.Text
                    };
                    //if the data already inside the data base then
                    db.insertIntoTable(data);    // if not
                    //move to another activity
                    Intent i = new Intent(this, typeof(PlannerList));
                    StartActivity(i);
                }
                else
                {
                    Toast.MakeText(this, "Any text box including date and time cannot be empty", ToastLength.Long).Show();//creating a toast
                }
            }

            return(base.OnOptionsItemSelected(item));
        }
Ejemplo n.º 2
0
 public bool updateIntoTable(PlannerData plannerData)
 {
     try
     {
         using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "events.db")))
         {
             connection.Query <PlannerData>("UPDATE PlannerData set Title=?,Loc=?,Desc=?,Start=?,End=?", plannerData.Title, plannerData.Location, plannerData.Description, plannerData.Starts, plannerData.Ends);
             return(true);
         }
     }
     catch (SQLite.SQLiteException ex)
     {
         Log.Info("SQL", ex.Message);
         return(false);
     }
 }
Ejemplo n.º 3
0
 public bool deleteQueryData(PlannerData plannerData)
 {
     try
     {
         using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "events.db")))
         {
             connection.Query <PlannerData>("DELETE FROM PlannerData WHERE Id=?", plannerData.ID);
             return(true);
         }
     }
     catch (SQLite.SQLiteException ex)
     {
         Log.Info("SQL", ex.Message);
         return(false);
     }
 }
Ejemplo n.º 4
0
 public bool deleteTableData(PlannerData plannerData)
 {
     try
     {
         using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "events.db")))
         {
             connection.Delete(plannerData);
             return(true);
         }
     }
     catch (SQLite.SQLiteException ex)
     {
         Log.Info("SQL", ex.Message);
         return(false);
     }
 }
Ejemplo n.º 5
0
        // this is for the parent
        public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
        {
            View       row = convertView;
            ViewHolder holder;

            if (listGroup.Count > 0)
            {
                // if not created yet
                if (row == null)
                {
                    //creating a view
                    row    = LayoutInflater.From(Context).Inflate(Resource.Layout.ListAdapter, parent, false);
                    holder = new ViewHolder()
                    {
                        //initialising
                        Location    = row.FindViewById <TextView>(Resource.Id.textview5),
                        Title       = row.FindViewById <TextView>(Resource.Id.textview3),
                        Description = row.FindViewById <TextView>(Resource.Id.textview4),
                        Starts      = row.FindViewById <TextView>(Resource.Id.textview1),
                        Ends        = row.FindViewById <TextView>(Resource.Id.textview2)
                    };
                    row.Tag = holder;
                }
                else
                {
                    holder = (ViewHolder)row.Tag;

                    //finding the item on the template
                    PlannerData item = listGroup[groupPosition];

                    holder.Title.Text       = item.Title;
                    holder.Description.Text = item.Location;
                    holder.Location.Text    = item.Description;
                    holder.Starts.Text      = item.Starts;
                    holder.Ends.Text        = item.Ends;
                    Log.Info("i", groupPosition.ToString() + " " + listGroup.Count());
                }
                return(row);
            }
            else
            {
                return(null);
            }
        }