コード例 #1
0
        public void SetStatusBar()
        {
            TabPage   page      = this.tcRslt.SelectedTab;
            QueryRslt queryRslt = page.Tag as QueryRslt;

            this.SetStatusBar(queryRslt);
        }
コード例 #2
0
        private void tcRslt_Selected(object sender, TabControlEventArgs e)
        {
            TabPage   page      = e.TabPage;
            QueryRslt queryRslt = page.Tag as QueryRslt;

            this.SetStatusBar(queryRslt);
        }
コード例 #3
0
 private void SetStatusBar(QueryRslt queryRslt)
 {
     if (queryRslt == null)
     {
         this.OnChangeStatusBar(new ChangeStatusBarEventArgs(true));
     }
     else
     {
         this.OnChangeStatusBar(new ChangeStatusBarEventArgs(queryRslt.RowIndex, queryRslt.Count, queryRslt.Statement, queryRslt.Cost));
     }
 }
コード例 #4
0
        private void QueryRslt_CurrentCellChange(object sender, EventArgs e)
        {
            QueryRslt queryRslt = sender as QueryRslt;

            this.SetStatusBar(queryRslt);
        }
コード例 #5
0
        private void RunSql(object args)
        {
            string str = args as string;

            try
            {
                this.Invoke(new MethodInvoker(delegate()
                {
                    try
                    {
                        this.splitMain.Panel2Collapsed = false;
                        while (this.tcRslt.TabPages.Count > 1)
                        {
                            this.tcRslt.TabPages.RemoveAt(this.tcRslt.TabPages.Count - 1);
                        }
                        this.txtMsg.Clear();
                        List <StatementObj> statements;
                        bool rslt = this.databaseInfo.Parse(str, out statements);
                        if (!rslt)
                        {
                            this.txtMsg.AppendText($"[ERROR] {this.databaseInfo.Message}\r\n\r\n");
                            return;
                        }
                        foreach (var statement in statements)
                        {
                            int count    = 0;
                            string error = "";
                            Int64 cost   = 0;
                            if (statement.SqlType == SqlType.eMsg)
                            {
                                rslt = this.databaseInfo.ExecueNonQuery(statement.SqlText, out count, out error, out cost);
                            }
                            else
                            {
                                DataTable table;
                                rslt = this.databaseInfo.ExecuteQuery(statement.SqlText, out table, out count, out error, out cost);
                                if (rslt)
                                {
                                    TabPage page                 = new TabPage();
                                    page.Text                    = $"结果-{this.tcRslt.TabPages.Count}";
                                    QueryRslt queryRslt          = new QueryRslt();
                                    queryRslt.Dock               = DockStyle.Fill;
                                    queryRslt.CurrentCellChange += QueryRslt_CurrentCellChange;
                                    queryRslt.Cost               = cost;
                                    queryRslt.Statement          = statement.SqlText;
                                    queryRslt.BindData(table);
                                    page.Tag = queryRslt;
                                    page.Controls.Add(queryRslt);
                                    this.tcRslt.TabPages.Add(page);
                                    this.tcRslt.SelectedTab = page;
                                }
                            }
                            if (rslt)
                            {
                                string success_msg = $"[SQL] {statement.SqlText}\r\n 受影响的行:{count}, 时间: {cost / 1000.0}s\r\n\r\n";
                                this.txtMsg.AppendText(success_msg);
                            }
                            else
                            {
                                this.txtMsg.AppendText($"[ERROR] {error}\r\n\r\n");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error(ex);
                    }
                    finally
                    {
                        this.EnableRun();
                    }
                }));
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }