コード例 #1
0
 public bool AddRegistro(Remedio tuber)
 {
     try
     {
         sqldb_query = "INSERT INTO remedio (data) VALUES ('" + tuber.data + "');";
         sqldb.ExecSQL(sqldb_query);
         sqldb_mensagem = "Registro salvo com sucesso!";
         return(true);
     }
     catch (SQLiteException ex)
     {
         sqldb_mensagem = ex.Message;
     }
     return(false);
 }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Remedio);

            Button btnSalvar = FindViewById <Button>(Resource.Id.remedio_btn_salvar);

            btnSalvar.Click += delegate
            {
                Java.Util.Calendar calendar = Java.Util.Calendar.GetInstance(Java.Util.Locale.Default);
                string             data     = calendar.Time.Day + "/" + calendar.Time.Month + "/" + calendar.Time.Year + " " + calendar.Time.Hours + ":" + calendar.Time.Minutes;
                Remedio            remedio  = new Remedio(0, data);

                DataBase db = new DataBase();
                db.CriarDatabase("remedio");
                AlertDialog.Builder alert = new AlertDialog.Builder(this);

                if (db.AddRegistro(remedio))
                {
                    alert.SetTitle("Sucessful Registered!1");
                    alert.SetPositiveButton("Yes", (senderAlert, args) =>
                    {
                        StartActivity(typeof(RemediosTomadosActivity));
                        Finish();
                    });
                    RunOnUiThread(() =>
                    {
                        alert.Show();
                    });
                }
                else
                {
                    alert.SetTitle("Problem!!1");
                    alert.SetPositiveButton("Yes", (senderAlert, args) =>
                    {
                    });
                    RunOnUiThread(() =>
                    {
                        alert.Show();
                    });
                }
            };
        }
コード例 #3
0
        public List <Remedio> GetListRemedio()
        {
            try
            {
                sqldb_query = "SELECT data FROM remedio";
                Android.Database.ICursor sqldb_cursor = null;
                sqldb_cursor = sqldb.RawQuery(sqldb_query, null);

                List <Remedio> lRemedio = new List <Remedio>();
                while (sqldb_cursor.MoveToNext())
                {
                    Remedio remedio = new Remedio();
                    remedio.data = sqldb_cursor.GetString(0);
                    lRemedio.Add(remedio);
                }
                return(lRemedio);
            }
            catch (SQLiteException ex)
            {
                return(null);
            }
        }