Exemple #1
0
        // Sets dialog settings and loads data. Used if record already exists.
        public void BuildAndShowDialog(int recordId)
        {
            // If recordIds == null, it's a single record, the buttons are hidden
            if (recordIds != null)
            {
                if (recordIds.IndexOf(recordId) == 0)
                {
                    Btn_Previous.IsEnabled = false;
                    Btn_Next.IsEnabled     = true;
                }
                else if (recordIds.IndexOf(recordId) == (recordIds.Count - 1))
                {
                    Btn_Previous.IsEnabled = true;
                    Btn_Next.IsEnabled     = false;
                }
                else
                {
                    Btn_Previous.IsEnabled = true;
                    Btn_Next.IsEnabled     = true;
                }
            }

            currentId = recordId;
            Veteran   = new VeteranDBInfo(currentId);

            // Set the Listboxes to the Lists in Veteran
            ListBox_ServiceDetails.DataContext  = Veteran.ServiceDetails;
            ListBox_AwardDetails.DataContext    = Veteran.AwardDetails;
            ListBox_ConflictDetails.DataContext = Veteran.ConflictDetails;

            LoadMilPic();
            LoadCasualPic();
            LoadMarkerPic();
            LoadMiscPic();
        }
Exemple #2
0
        // Sets dialog settings. Used for new record.
        public void BuildAndShowDialog()
        {
            Veteran = new VeteranDBInfo();

            // Set the Listboxes to the Lists in Veteran
            ListBox_ServiceDetails.DataContext  = Veteran.ServiceDetails;
            ListBox_AwardDetails.DataContext    = Veteran.AwardDetails;
            ListBox_ConflictDetails.DataContext = Veteran.ConflictDetails;

            // No need to load pictures, it's a new record
        }
        public void LoadNew()
        {
            DataContext = null;

            // Assign down the chain and build a new record to add to
            OldestVeteran = OlderVeteran;
            OlderVeteran  = Veteran;
            Veteran       = new VeteranDBInfo();

            Veteran.CemDetails = cemeteryDetails;

            DataContext = this;

            // Set the Listboxes to the Lists in Veteran
            ListBox_ServiceDetails.DataContext  = Veteran.ServiceDetails;
            ListBox_ConflictDetails.DataContext = Veteran.ConflictDetails;
        }
Exemple #4
0
        public static List <VeteranDBInfo> ListByConflictCem(string selectedConflict, string selectedCemetery)
        {
            List <VeteranDBInfo> results = new List <VeteranDBInfo>();
            string city = "";
            string name = "";

            Tools.CemDetailsParser(selectedCemetery, ref name, ref city);

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

                    using (MySqlCommand command = conn.CreateCommand())
                    {
                        command.CommandText = @"SELECT FName,MName,LName,Suffix FROM Veterans NATURAL JOIN Conflicts " +
                                              "WHERE CName = @name AND CCity = @city AND ConflictName=@CName ORDER BY LName, FName;";
                        command.Parameters.Add("@name", MySqlDbType.VarChar).Value  = name;
                        command.Parameters.Add("@city", MySqlDbType.VarChar).Value  = city;
                        command.Parameters.Add("@CName", MySqlDbType.VarChar).Value = selectedConflict;

                        using (MySqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                VeteranDBInfo record = new VeteranDBInfo();

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

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

                                if (!reader.IsDBNull(2))
                                {
                                    record.LastName = reader.GetString(2);
                                }

                                if (!reader.IsDBNull(3))
                                {
                                    record.Suffix = reader.GetString(3);
                                }

                                results.Add(record);
                            }
                        }
                    }
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(Tools.DBErrorMessage, Tools.DBErrorTitle);
            }
            catch (MySqlException e)
            {
                Tools.HandleSQLExceptions(e);
            }

            // Queries never change data in the database
            Tools.hasDataChanged = false;

            return(results);
        }