Exemplo n.º 1
0
        /// <summary>
        /// Returns new data adapter to this type of the database.
        /// </summary>
        /// <param name="query">A SQL query.</param>
        /// <param name="connection">A connection to database.</param>
        /// <param name="commandType">A type of the query.</param>
        /// <returns>Created adapter.</returns>
        public virtual DbDataAdapter CreateAdapter(string query, DbConnection connection, CommandType commandType = CommandType.Text)
        {
            var adapter = AssemblyHelper.CreateAdapter(TypeDataAdapter, query, connection);

            adapter.SelectCommand.CommandType = commandType;
            return(adapter);
        }
Exemplo n.º 2
0
        private void LoadAdapterConfig(Type adapterType)
        {
            IAdapterConfig adapter = AssemblyHelper.CreateAdapter <IAdapterConfig>(adapterType);

            if (adapter == null)
            {
                MessageBox.Show("Cannot create instance of type " + adapterType.ToString() + "\r\n\r\n" + AssemblyHelper.LastErrorInfor);
                return;
            }

            IConfigUI[] uilist = adapter.GetConfigUI();
            if (uilist != null && uilist.Length > 0)
            {
                _config = uilist[0];
            }

            if (_config == null)
            {
                MessageBox.Show("Cannot get config implementation from adapter " + adapterType.ToString());
                return;
            }

            Control ctrl = _config.GetControl();

            if (ctrl == null)
            {
                MessageBox.Show("Cannot get config GUI from adapter " + adapterType.ToString());
                return;
            }

            AssemblyHelper.PrepareControl(ctrl, tabPage2);
            tabPage2.Controls.Add(ctrl);

            //this.Text = _config.FileName;
            _config.LoadConfig();
        }