public Object getLastRecordSettings(string tableName) //: where T = TBL_Tasks { TBL_Tasks result = null; //var result = DB.Get<TBL_Tasks>(id); // primary key id of 5 //List < ColumnInfo >= DB.GetTableInfo(tableName); TableQuery<TBL_Tasks> table = DB.Table<TBL_Tasks>(); result = table.Last(); //foreach (TBL_Tasks record in table) //{ //} //TableMapping tableMap = DB.GetMapping<TBL_Tasks>(); //string sqlScript = "SELECT * FROM " + TableName + " WHERE ID=?"; //List<object> objects = DB.Query(tableMap, sqlScript, new object[1] { id }); //DB.Close(); return result; }
private bool SaveRecord(Task task) { bool result = true; long recorsWasEffected = 0; TBL_Tasks record = null; IsSaveNeededBeforeExit = false; if (!IsDataWasChanged()) { return(result); } SetObjectByControls(); // only insert the data if it doesn't already exist if (isNewMode) { record = new TBL_Tasks(); } else { record = (TBL_Tasks)MainActivity.DBTaskReminder.GetRecordByID(task.getTaskID(), MainActivity.DB_TABLE_NAME); } try { record.Title = task.getTitle(); record.Description = task.getDescriptionWithHtml(); record.DateDue = task.getDate_due() + " " + task.getTime_due(); record.CardBackColor = task.getBackgroundColor(); record.LastUpdateDate = task.getDate_last_update(); if (isNewMode) { recorsWasEffected = MainActivity.DBTaskReminder.RecordInser(record, MainActivity.DB_TABLE_NAME); //MainActivity.DBTaskReminder.DB.Insert(record); } else { recorsWasEffected = MainActivity.DBTaskReminder.RecordUpdate(record); record = (TBL_Tasks)MainActivity.DBTaskReminder.GetRecordByID(task.getTaskID(), MainActivity.DB_TABLE_NAME); task.TableRecord = record; } if (recorsWasEffected > 0) { if (isNewMode) { Object recordUpdated = MainActivity.DBTaskReminder.getLastRecord(MainActivity.DB_TABLE_NAME); CurrentTask.setTaskID(((TBL_Tasks)recordUpdated).ID); } MainActivity.CurrentTask = CurrentTask; MainActivity.isShowTimerReminder = true; MainActivity.MainMessageText = "נשמר"; inputIntent.PutExtra("Result", "true"); ////SetResult(Result.Ok, inputIntent); // Second option to - Raise the event to the Caller if (OnExitResult != null) { OnExitResult(MainActivity.SCREEN_TASK_DETAILS_SAVED, Result.Ok, inputIntent); } } else { Toast.MakeText(this, "השמירה נכשלה", ToastLength.Long).Show(); SetResult(Result.Canceled, inputIntent); } Finish(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(result); }