Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var ops = new SqlServerOperations();

            countriesCombox.DataSource    = ops.CountryList();
            countriesCombox.DisplayMember = "Name";
        }
        /// <summary>
        /// Load reference table countries into two ComboBox controls
        /// for allowing selections for exporting to either ms-access
        /// or ms-excel from sql-server.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            var ops = new SqlServerOperations();

            countriesComboxExcel.DataSource   = ops.CountryList();
            countriesComboxAccess1.DataSource = ops.CountryList("*");

            countriesComboxAccess2.DataSource = new List <CountryItem>((List <CountryItem>)countriesComboxAccess1.DataSource);

            clbColumnNames.DataSource = ops.GetColumnsForTable("Customers");

            if (ops.HasException)
            {
                // disable buttons as they are of no use
                Controls.OfType <Button>().ToList().ForEach(but => but.Enabled = false);
                MessageBox.Show(ops.LastExceptionMessage);
                return;
            }

            countriesComboxExcel.DisplayMember   = "Name";
            countriesComboxAccess1.DisplayMember = "Name";
            countriesComboxAccess2.DisplayMember = "Name";
        }