miniSql

创建
zgc123@gmail.com authored at 11/19/2023 1:40:15 AM
6136600
Tree
0 Parent(s)
Summary: 1 changed files with 72 additions and 0 deletions.
Added +72 -0
Added +72 -0
diff --git a/minisqlquery-master/src/MiniSqlQuery.Core/Controls/BatchQuerySelectControl.cs b/minisqlquery-master/src/MiniSqlQuery.Core/Controls/BatchQuerySelectControl.cs
new file mode 100644
index 0000000..2211260
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery.Core/Controls/BatchQuerySelectControl.cs
@@ -0,0 +1,72 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System;
+using System.Windows.Forms;
+
+namespace MiniSqlQuery.Core.Controls
+{
+    /// <summary>A batch query selection control is used for displaying multiple result sets and allows
+    /// the user to select one (e.g. for exports etc).</summary>
+    public partial class BatchQuerySelectControl : UserControl
+    {
+        /// <summary>The _batch.</summary>
+        private QueryBatch _batch;
+
+        /// <summary>The _selected query.</summary>
+        private Query _selectedQuery;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BatchQuerySelectControl"/> class.
+        /// </summary>
+        public BatchQuerySelectControl()
+        {
+            InitializeComponent();
+        }
+
+        /// <summary>
+        /// Gets the selected query.
+        /// </summary>
+        /// <value>The selected query.</value>
+        public Query SelectedQuery
+        {
+            get { return _selectedQuery; }
+        }
+
+        /// <summary>Fills the list with the batch result sets.</summary>
+        /// <param name="batch">The query batch.</param>
+        public void Fill(QueryBatch batch)
+        {
+            _batch = batch;
+            lstBatches.Items.Clear();
+            if (batch == null)
+            {
+                return;
+            }
+
+            for (int setIndex = 0; setIndex < batch.Queries.Count; setIndex++)
+            {
+                var query = batch.Queries[setIndex];
+                if (query.Result != null && query.Result.Tables.Count > 0)
+                {
+                    string setName = string.Format("Result Set {0} ({1} tables)", setIndex, query.Result.Tables.Count);
+                    lstBatches.Items.Add(setName);
+                }
+            }
+
+            lstBatches.SelectedIndex = 0;
+        }
+
+        /// <summary>The lst batches_ selected index changed.</summary>
+        /// <param name="sender">The sender.</param>
+        /// <param name="e">The e.</param>
+        private void lstBatches_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            _selectedQuery = _batch.Queries[lstBatches.SelectedIndex];
+        }
+    }
+}
\ No newline at end of file