コード例 #1
0
        public static IList <ObjectInfo> SearchAndSelectObjectFromDb(ConnectionParams cp, string caption, bool autoLoad)
        {
            if (cp == null)
            {
                throw new NullParameterException("Connection not specified!");
            }

            frmDbObjectSearch frm = new frmDbObjectSearch();

            frm.InitializeForm(caption, cp);

            if (autoLoad)
            {
                try
                {
                    frm.PerformSearch();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Can not load data!\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    frm.Close();
                    frm.Dispose();
                    frm = null;
                    return(null);
                }
            }

            frm.IsDialog         = true;
            frm.RowSelectAllowed = true;

            frm.ShowDialog();
            return(frm.GetSelectedObjects());
        }