コード例 #1
0
        /// <summary>
        /// Connect to DB
        /// </summary>
        public UI()
        {
            //DisplaySplashScreen();
            //connectionString = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = 'C:\Users\Jack\source\repos\OAHeLP-Database-Project\OAHeLP Database Project\Database1.mdf'; Integrated Security = True";
            //connectionString = @"Server=(localdb)\MSSQLLocalDb;Database=OAHELP;Integrated Security=SSPI;";
            connectionString = ConfigurationManager.ConnectionStrings["OAHeLP_Database_Project.Properties.Settings.Database1ConnectionString"].ConnectionString;

            repo        = new SqlSubjectRepository(connectionString);
            subjectList = new BindingList <Subject>();
            InitializeComponent();
            PopulateTable();
            uxNamesListBox.DataSource = subjectList;
            detailedView = new DetailedView(subjectList[uxNamesListBox.SelectedIndex]);
            OpenChildForm(detailedView);
        }
コード例 #2
0
        }//SearchButtonClick

        /// <summary>
        /// Load Detailed View with information from query
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uxNamesListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (detailedView == null)
                {
                    detailedView = new DetailedView(subjectList[uxNamesListBox.SelectedIndex]);
                }

                detailedView.UpdateSubject(subjectList[uxNamesListBox.SelectedIndex]);
                detailedView.UpdateView();
            }
            catch (System.ArgumentOutOfRangeException ex)
            {
                //this exception is thrown between when list is cleared and repopulated
            }
        }