Ejemplo n.º 1
0
        private void GetMilestonesPickerList()
        {
            // Clear out previous list and listbox.
            GlobalVars.MilestonePickerList.Clear();
            lb_TaskRelMilestone.Items.Clear();

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

            string s_Query = "SELECT MilestoneID, MilestoneName " +
                "FROM Milestones " +
                "ORDER BY MilestoneID;";

            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())
                        {
                            Milestone m = new Milestone();
                            m.MilestoneID = rdr.GetInt32(0);
                            m.MilestoneName = rdr.GetString(1);

                            GlobalVars.MilestonePickerList.Add(m);
                        }
                        rdr.Close();
                        AccessConn.Close();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        // Update Status Bar if error
                    }
                }
            }

            foreach (Milestone m in GlobalVars.MilestonePickerList)
                lb_TaskRelMilestone.Items.Add(m.MilestoneName);
        }
        private void Fill_cb_MilestonesPicker()
        {
            GlobalVars.mList.Clear();
            cb_MilestonesPicker.Items.Clear();

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

            string s_Query = "SELECT MilestoneID, MilestoneName, MilestoneDescription FROM Milestones;";

            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())
                        {
                            Milestone m = new Milestone();

                            m.MilestoneID = rdr.GetInt32(0);
                            m.MilestoneName = rdr.GetString(1);
                            m.MilestoneDescription = rdr.GetString(2);

                            GlobalVars.mList.Add(m);

                        }
                        foreach (Milestone m in GlobalVars.mList)
                        {
                            cb_MilestonesPicker.Items.Add(m.MilestoneName);
                        }

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

                    }
                    catch (Exception x)
                    {
                        MessageBox.Show("Database error:\n" + x.Message +
                         "\nPlease take a screenshot and\nreport this to Ashton.",
                          "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
        private void FillAllMilestones()
        {
            // Clear out global milestones list, in case it's been updated.
            GlobalVars.mList.Clear();

            // Clear out current listbox.
            lb_MilestonesList.Items.Clear();

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

            string s_Query = "SELECT MilestoneID, MilestoneName, MilestoneDescription " +
                "FROM Milestones " +
                "ORDER BY MilestoneID;";

            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())
                        {
                            Milestone m = new Milestone();
                            m.MilestoneID = rdr.GetInt32(0);
                            m.MilestoneName = rdr.GetString(1);
                            m.MilestoneDescription = rdr.GetString(2);
                            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);
                    }
                }
            }

            foreach (Milestone m in GlobalVars.mList)
            {
                lb_MilestonesList.Items.Add(m.MilestoneName);
            }

            // Clear any selections.
            lb_MilestonesList.SelectedIndex = 0;
        }