Example #1
0
 public static string ReplaceData(SleepSession data, string path)
 {
     try
     {
         var db = new SQLiteAsyncConnection(path);
         db.InsertOrReplaceAsync(data);
         return("Single data file inserted or updated");
     }
     catch (SQLiteException ex)
     {
         return(ex.Message);
     }
 }
Example #2
0
 public static string DeleteSession(string path, SleepSession sleepSession)
 {
     try
     {
         var connection = new SQLiteAsyncConnection(path);
         int res        = connection.DeleteAsync(sleepSession).Result;
         return("Single data deleted");
     }
     catch (SQLiteException ex)
     {
         return(ex.Message);
     }
 }
Example #3
0
 public static string InsertUpdateData(SleepSession data, string path)
 {
     try
     {
         var db = new SQLiteAsyncConnection(path);
         if (db.InsertAsync(data).Result != 0)
         {
             db.UpdateAsync(data);
         }
         return("Single data file inserted or updated");
     }
     catch (SQLiteException ex)
     {
         return(ex.Message);
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ChangeSession);

            sleepSession = SQLiteSleepSessionCommands.FindSessionById(
                dbPath, this.Intent.GetIntExtra("id", 0));

            FindViewById <TextView>(Resource.Id.startSleepTextView).Text =
                $"Начало сна:\n{this.sleepSession.StartSleepTime.ToString("G")}";

            FindViewById <TextView>(Resource.Id.endSleepTextView).Text =
                $"Конец сна:\n{this.sleepSession.EndSleepTime.ToString("G")}";

            FindViewById <EditText>(Resource.Id.descriptionEditText).Text =
                this.sleepSession.Caption;

            FindViewById <Switch>(Resource.Id.isTaskDone).Checked =
                this.sleepSession.IsTaskDone;

            var cancelSessionButton = FindViewById <Button>(Resource.Id.cancelSessionButton);

            cancelSessionButton.Click += delegate
            {
                this.SetResult(Result.Canceled);
                this.Finish();
            };

            var addSessionButton = FindViewById <Button>(Resource.Id.saveSessionButton);

            addSessionButton.Click += delegate
            {
                sleepSession.Caption = FindViewById <EditText>(
                    Resource.Id.descriptionEditText).Text;
                sleepSession.IsTaskDone = FindViewById <Switch>(
                    Resource.Id.isTaskDone).Checked;
                SQLiteSleepSessionCommands.ReplaceData(sleepSession, dbPath);
                this.Finish();
            };
        }