public void LidmaatschapRemoveClicked(Foundation.NSObject sender)
        {
            Debug.WriteLine("Start: PersoonController.LidmaatschapRemoveClicked");

            var selectedRowIndex = (int)LidmaatschappenTable.SelectedRow;

            if (selectedRowIndex >= 0)
            {
                SelectedLidmaatschap = dsLidmaatschappen.Lidmaatschappen[selectedRowIndex] as ClublidmaatschapModel;

                // Configure alert
                var alert = new NSAlert()
                {
                    AlertStyle      = NSAlertStyle.Informational,
                    InformativeText = $"Weet je zeker dat je het lidmaatschap op {SelectedLidmaatschap.ClubNaam} wilt verwijderen?\n\nDit kan niet meer ongedaan gemaakt worden.",
                    MessageText     = $"Delete {SelectedLidmaatschap.ClubNaam}?",
                };
                alert.AddButton("Cancel");
                alert.AddButton("Delete");
                alert.BeginSheetForResponse(this.View.Window, (result) =>
                {
                    // Should we delete the requested row?
                    if (result == 1001)
                    {
                        // Remove the given row from the dataset
                        SelectedLidmaatschap.Delete(AppDelegate.Conn);
                        dsLidmaatschappen.Lidmaatschappen.Remove(SelectedLidmaatschap);

                        LidmaatschappenTable.ReloadData();
                    }
                });
            }

            Debug.WriteLine("Einde: PersoonController.LidmaatschapRemoveClicked");
        }
        public void LidmaatschapDoubleClicked(NSObject sender)
        {
            Debug.WriteLine("Start: PersoonController.LidmaatschapDoubleClicked");

            var selectedRowIndex = (int)LidmaatschappenTable.SelectedRow;

            if (selectedRowIndex >= 0)
            {
                SelectedLidmaatschap = dsLidmaatschappen.Lidmaatschappen[selectedRowIndex] as ClublidmaatschapModel;

                PerformSegue("LidmaatschapSegue", this);
            }
            Debug.WriteLine("Einde: PersoonController.LidmaatschapDoubleClicked");
        }
예제 #3
0
        void LoadLidmaatschappen(SqliteConnection conn, string PersoonID)
        {
            bool shouldClose = false;

            // Is the database already open?
            if (conn.State != ConnectionState.Open)
            {
                shouldClose = true;
                conn.Open();
            }

            // Execute query
            using (var command = conn.CreateCommand())
            {
                try
                {
                    // Create new command
                    command.CommandText = "SELECT DISTINCT ID FROM [Clublidmaatschap] WHERE PersoonID = '" + PersoonID + "'";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var lidmaatschap = new ClublidmaatschapModel();
                            var id           = (string)reader["ID"];

                            lidmaatschap.Load(conn, id);

                            Lidmaatschappen.Add(lidmaatschap);
                        }
                    }
                }
                catch (Exception Exception)
                {
                    Debug.WriteLine(Exception.Message);
                }
            }

            if (shouldClose)
            {
                conn.Close();
            }
        }
        public override void AwakeFromNib()
        {
            Debug.WriteLine("Start: LidmaatschapController.AwakeFromNib");

            _parentController = this.PresentingViewController as PersoonController;
            if (_parentController != null)
            {
                Lidmaatschap = _parentController.SelectedLidmaatschap;

                if (Lidmaatschap == null)
                {
                    Lidmaatschap = new ClublidmaatschapModel();
                    IsNieuw      = true;
                }

                if (LidmaatschapCombobox != null)
                {
                    LidmaatschapCombobox.UsesDataSource = true;
                    LidmaatschapCombobox.Completes      = true;
                    LidmaatschapCombobox.DataSource     = new ClubsComboDS();

                    if (!Lidmaatschap.ClubNaam.Equals(string.Empty))
                    {
                        var index = LidmaatschapCombobox.DataSource.IndexOfItem(LidmaatschapCombobox, Lidmaatschap.ClubNaam);
                        LidmaatschapCombobox.SelectItem(index);
                    }
                }

                if (IngeschrevenOpButton != null)
                {
                    IngeschrevenOpButton.State = NSCellStateValue.Off;
                    IngeschrevenOpDate.Enabled = false;
                }

                if (UitgeschrevenOpButton != null)
                {
                    UitgeschrevenOpButton.State = NSCellStateValue.Off;
                    UitgeschrevenOpDate.Enabled = false;
                }
            }
            Debug.WriteLine("Start: LidmaatschapController.AwakeFromNib");
        }