Exemplo n.º 1
0
        private void Btn_DeleteCemetery_Click(object sender, RoutedEventArgs e)
        {
            string selected;

            selected = Convert.ToString(ListBox_CemeteryDetails.SelectedValue);

            // Verify the user selected a record to delete
            if (!string.IsNullOrEmpty(selected))
            {
                MessageBoxResult result;
                result = MessageBox.Show(Tools.deleteMessage, Tools.deleteTitle, MessageBoxButton.YesNo);

                if (result == MessageBoxResult.Yes)
                {
                    foreach (CemeteryDBInfo cemetery in cemList)
                    {
                        if (cemetery.Details == selected)
                        {
                            // Remove from the database
                            cemetery.DeleteFromDatabase();
                        }
                    }

                    cemList = CemeteryDBInfo.LoadObjectList();

                    ListBox_CemeteryDetails.DataContext = cemList;
                }
            }
            else
            {
                MessageBox.Show(Tools.RecordDeleteMessage, Tools.RecordSelectTitle);
            }
        }
Exemplo n.º 2
0
        public Veterans(MainWindow parent)
        {
            InitializeComponent();

            parentWin = parent;

            DataContext = this;

            CemList = CemeteryDBInfo.LoadStringList();
        }
Exemplo n.º 3
0
        public Cemeteries()
        {
            InitializeComponent();

            cemList = CemeteryDBInfo.LoadObjectList();

            ListBox_CemeteryDetails.DataContext = cemList;

            DataContext = this;
        }
Exemplo n.º 4
0
        private void Save()
        {
            CurrentCemetery.WriteDataToDatabase();

            cemList = CemeteryDBInfo.LoadObjectList();

            ListBox_CemeteryDetails.DataContext = cemList;

            HideControls();

            CurrentCemetery = null;
        }
Exemplo n.º 5
0
        public VeteranRecord(MainWindow main)
        {
            InitializeComponent();

            mainWin = main;

            DataContext = this;

            Tools.hasDataChanged = false;

            CemList = CemeteryDBInfo.LoadStringList();
        }
Exemplo n.º 6
0
        // Loads the cemeteries into a list of objects
        public static List <CemeteryDBInfo> LoadObjectList()
        {
            List <CemeteryDBInfo> records = new List <CemeteryDBInfo>();
            CemeteryDBInfo        current;

            try
            {
                using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString))
                {
                    conn.OpenAsync();

                    using (MySqlCommand command = conn.CreateCommand())
                    {
                        command.CommandText = "SELECT CName,CCity FROM Cemeteries;";

                        using (MySqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                string name = "";
                                string city = "";

                                if (!reader.IsDBNull(0))
                                {
                                    name = reader.GetString(0);
                                }

                                if (!reader.IsDBNull(1))
                                {
                                    city = reader.GetString(1);
                                }

                                current = new CemeteryDBInfo(name, city);
                                records.Add(current);
                            }
                        }
                    }
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(Tools.DBErrorMessage, Tools.DBErrorTitle);
            }
            catch (MySqlException e)
            {
                Tools.HandleSQLExceptions(e);
            }

            return(records);
        }
Exemplo n.º 7
0
        // Copy Constructor
        public CemeteryDBInfo(CemeteryDBInfo other)
        {
            name      = other.name;
            oldName   = other.oldName;
            city      = other.city;
            oldCity   = other.oldCity;
            address   = other.address;
            gps       = other.gps;
            airPicLoc = other.airPicLoc;
            dirPicLoc = other.dirPicLoc;

            hasDataChanged = other.hasDataChanged;
            isNewRecord    = other.isNewRecord;
        }
Exemplo n.º 8
0
        public Queries(MainWindow parent)
        {
            InitializeComponent();

            parentWin = parent;

            DataContext = this;

            // Load lists from the database
            BranchList   = BranchDBInfo.LoadStringList();
            CemList      = CemeteryDBInfo.LoadStringList();
            ConflictList = ConflictDBInfo.LoadStringList();

            SetupQueryLists();
        }
Exemplo n.º 9
0
        private void Btn_EditCemetery_Click(object sender, RoutedEventArgs e)
        {
            string selected;

            selected = Convert.ToString(ListBox_CemeteryDetails.SelectedValue);

            // Verify the user selected a record to edit
            if (!string.IsNullOrEmpty(selected))
            {
                CurrentCemetery = new CemeteryDBInfo(selected);

                ShowControls();
            }
            else
            {
                MessageBox.Show(Tools.RecordSelectMessage, Tools.RecordSelectTitle);
            }
        }
Exemplo n.º 10
0
        private void ListBox_CemeteryDetails_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            HideControls();

            CurrentCemetery = null;
        }
Exemplo n.º 11
0
        private void Btn_CemCancel_Click(object sender, RoutedEventArgs e)
        {
            HideControls();

            CurrentCemetery = null;
        }
Exemplo n.º 12
0
        private void Btn_AddCemetery_Click(object sender, RoutedEventArgs e)
        {
            CurrentCemetery = new CemeteryDBInfo();

            ShowControls();
        }