Пример #1
0
        private void FillModList()
        {
            // New mod collection.
            List<Mod> modList = new List<Mod>();

            // Clear out current list.
            cb_ModSelector.Items.Clear();
            GlobalVars.mList.Clear();

            // Setting up DB stuff.
            string s_ConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data " +
                "Source=|DataDirectory|\\ModDB.accdb";

            string s_Query = "SELECT ModID, ModNumber, ModTitle, ContractID, IsACOSigned FROM Modifications " +
                "WHERE ContractID = " + GlobalVars.SelectedContract + " ORDER BY ModNumber;";

            using (OleDbConnection AccessConn = new OleDbConnection(s_ConnString))
            {
                using (OleDbCommand AccessCmd = AccessConn.CreateCommand())
                {
                    AccessCmd.CommandText = s_Query;
                    try
                    {
                        AccessConn.Open();

                        OleDbDataReader rdr = AccessCmd.ExecuteReader();

                        while (rdr.Read())
                        {
                            Mod m = new Mod();
                            m.i_ModID = rdr.GetInt32(0);
                            m.ModNumber = rdr.GetString(1);
                            m.ModTitle = rdr.GetString(2);
                            m.i_ContractID = rdr.GetInt32(3);
                            m.IsACOSigned = rdr.GetBoolean(4);

                            modList.Add(m);
                        }

                        rdr.Close();
                        AccessConn.Close();

                    }
                    catch (Exception e)
                    {

                        MessageBox.Show("Database error:\n" + e.Message +
                          "\nPlease take a screenshot and\nreport this to Ashton.",
                         "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }

                    foreach (Mod m in modList)
                    {
                        cb_ModSelector.Items.Add(m.ModNumber + " - " + m.ModTitle);
                        GlobalVars.mList.Add(m);
                    }
                }
            }

            // If we're working on a certain mod, better keep focus on that mod.
            if (GlobalVars.CurrentMod == 0)
            {
                cb_ModSelector.SelectedIndex = 0;
            }
            else
            {
                for (int i = 0; i < modList.Count(); i++)
                {
                    if (GlobalVars.CurrentMod == modList[i].i_ModID)
                    {
                        cb_ModSelector.SelectedIndex = i;
                    }
                }
            }
        }
Пример #2
0
        private void FillMList()
        {
            // Clear out global mods list, in case it's been updated.
            GlobalVars.mList.Clear();

            // Setting up DB stuff.
            string s_ConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data " +
                "Source=|DataDirectory|\\ModDB.accdb";

            string s_Query = "SELECT ModID, ModNumber, ModTitle, ContractID, IsACOSigned " +
            "FROM Modifications ORDER BY ModID ASC;";

            using (OleDbConnection AccessConn = new OleDbConnection(s_ConnString))
            {
                using (OleDbCommand AccessCmd = AccessConn.CreateCommand())
                {
                    AccessCmd.CommandText = s_Query;
                    try
                    {
                        AccessConn.Open();

                        OleDbDataReader rdr = AccessCmd.ExecuteReader();

                        while (rdr.Read())
                        {
                            Mod m = new Mod();
                            m.i_ModID = rdr.GetInt32(0);
                            m.ModNumber = rdr.GetString(1);
                            m.ModTitle = rdr.GetString(2);
                            m.i_ContractID = rdr.GetInt32(3);
                            m.IsACOSigned = rdr.GetBoolean(4);

                            GlobalVars.mList.Add(m);
                        }

                        rdr.Close();
                        AccessConn.Close();

                    }
                    catch (Exception e)
                    {

                        MessageBox.Show("Database error:\n" + e.Message +
                        "\nPlease take a screenshot and\nreport this to Ashton.",
                         "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }