コード例 #1
0
        partial void SaveButton_TouchUpInside(UIButton sender)
        {
            var item = new SavedItem();
            item.Date = DateTime.Now;
            item.Description = ItemTextBox.Text;
            decimal price = 0;
            decimal.TryParse(PreisTextBox.Text, out price);
            item.Price = price;

            _savedItems.Add(item);
            _repository.Create(item);

            UpdateTotalLabel();
        }
コード例 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            EditText descriptionText = FindViewById<EditText>(Resource.Id.descriptionText);
            EditText priceText = FindViewById<EditText>(Resource.Id.priceText);
            TextView totalText = FindViewById<TextView>(Resource.Id.totalSavedText);

            Button saveButton = FindViewById<Button>(Resource.Id.saveButton);

            var path = System.IO.Path.Combine(System.Environment.GetFolderPath(
                System.Environment.SpecialFolder.Personal), "savedItems.sqlite");
            var connection = new SQLiteConnection(new SQLitePlatformAndroid(), path);
            _repository = new SavedItemRepository(connection);
            _savedItems = _repository.GetAll();
            UpdateTotalLabel(totalText);

            saveButton.Click += (sender, e) =>
            {
                decimal price = 0;
                if (decimal.TryParse(priceText.Text, out price))
                {
                    var savedItem = new SavedItem();
                    savedItem.Date = DateTime.Now;
                    savedItem.Description = descriptionText.Text;
                    savedItem.Price = price;
                    _savedItems.Add(savedItem);
                    _repository.Create(savedItem);
                    UpdateTotalLabel(totalText);
                    descriptionText.Text = string.Empty;
                    priceText.Text = string.Empty;
                    HideKeyBoard();
                }
            };

            Button detailsButton = FindViewById<Button>(Resource.Id.detailsButton);
            detailsButton.Click += DetailsButton_Click;
        }
コード例 #3
0
 public void Update(SavedItem item)
 {
     _connection.Update(item);
     _connection.Commit();
 }
コード例 #4
0
 public void Delete(SavedItem item)
 {
     _connection.Delete(item);
     _connection.Commit();
 }
コード例 #5
0
 public void Create(SavedItem item)
 {
     _connection.Insert(item);
     _connection.Commit();
 }