Exemple #1
0
        void CommMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try
            {
                switch (e.ClickedItem.Text)
                {
                case "刷新":
                    ReLoadDBObj(tv_DBServers.SelectedNode);
                    break;

                case "复制对象名":
                    if (this.tv_DBServers.SelectedNode != null)
                    {
                        string s = tv_DBServers.SelectedNode.Text;
                        if (s.IndexOf('(') > -1)
                        {
                            Clipboard.SetText(s.Substring(0, s.IndexOf('(')));
                        }
                        else
                        {
                            Clipboard.SetText(s);
                        }
                    }
                    break;

                case "添加实体映射表":
                    if (OnAddEntityTB != null)
                    {
                        var node = tv_DBServers.SelectedNode;
                        if (node == null)
                        {
                            return;
                        }
                        OnAddEntityTB(GetDBSource(node), node.Text);
                    }
                    break;

                case "删除对象":
                    if (MessageBox.Show("确认要删除数据库" + tv_DBServers.SelectedNode.Text + "吗?", "询问",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        var node = tv_DBServers.SelectedNode;
                        Biz.Common.Data.MySQLHelper.DeleteDataBase(GetDBSource(node), node.Text);
                        ReLoadDBObj(node.Parent);
                    }
                    break;

                case "新增对象":
                    var selnode = tv_DBServers.SelectedNode;
                    var dlg     = new SubForm.InputStringDlg("请输入库名:");
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        Biz.Common.Data.MySQLHelper.CreateDataBase(GetDBSource(selnode), selnode.FirstNode.Text, dlg.InputString);
                        ReLoadDBObj(selnode);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "发生错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Exemple #2
0
        void OnMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try
            {
                switch (e.ClickedItem.Text)
                {
                case "生成实体类":
                    CreateEntityClass();
                    break;

                case "显示前100条数据":
                    ShowTop100Data();
                    break;

                case "复制对象名":
                    if (this.tv_DBServers.SelectedNode != null)
                    {
                        Clipboard.SetText(tv_DBServers.SelectedNode.Text);
                    }
                    break;

                case "删除表":
                    if (MessageBox.Show("确认要删除表" + tv_DBServers.SelectedNode.Text + "吗?", "询问",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        var node = tv_DBServers.SelectedNode;
                        Biz.Common.Data.MySQLHelper.DeleteTable(GetDBSource(node), node.Parent.Text, node.Text);
                        ReLoadDBObj(node.Parent);
                    }
                    break;

                case "刷新":
                    ReLoadDBObj(tv_DBServers.SelectedNode);
                    break;

                case "修改表名":
                    var _node   = tv_DBServers.SelectedNode;
                    var oldname = _node.Text;
                    var dlg     = new SubForm.InputStringDlg("修改表名:", _node.Text);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if (string.Equals(dlg.InputString, oldname, StringComparison.OrdinalIgnoreCase))
                        {
                            return;
                        }
                        Biz.Common.Data.MySQLHelper.ReNameTableName(GetDBSource(_node), _node.Parent.Text,
                                                                    oldname, dlg.InputString);
                        ReLoadDBObj(_node.Parent);
                    }
                    break;

                case "InsertOrUpdate":
                    _node = tv_DBServers.SelectedNode;
                    if (this.OnCreatePorcSQL != null)
                    {
                        this.OnCreatePorcSQL(GetDBSource(_node), _node.Parent.Text, _node.Name, _node.Text, CreateProceEnum.InsertOrUpdate);
                    }
                    break;

                case "Delete":
                    _node = tv_DBServers.SelectedNode;
                    if (this.OnCreatePorcSQL != null)
                    {
                        this.OnCreatePorcSQL(GetDBSource(_node), _node.Parent.Text, _node.Name, _node.Text, CreateProceEnum.Delete);
                    }
                    break;

                case "Select":

                    break;

                case "创建语句":
                    MessageBox.Show("Create");
                    break;

                default:
                    _node = tv_DBServers.SelectedNode;
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "发生错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }