Exemple #1
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string strError = "";
            int    nRet     = 0;

            if (this.textBox_sqlServerName.Text == "")
            {
                strError = "尚未指定 MySQL 服务器";
                goto ERROR1;
            }

            if (string.Compare(this.textBox_sqlServerName.Text.Trim(), "~sqlite") == 0)
            {
                strError = "MySQL 服务器名不能为 '~sqlite',因为这个名字保留给了 SQLite 内置数据库类型";
                goto ERROR1;
            }

            if (this.textBox_loginName.Text == "")
            {
                strError = "尚未指定 MySQL 用户名";
                goto ERROR1;
            }

            if (this.textBox_loginPassword.Text != this.textBox_confirmLoginPassword.Text)
            {
                strError = "MySQL 帐户的密码和确认密码不一致";
                goto ERROR1;
            }

#if NO
            SaLoginDialog dlg = new SaLoginDialog();
            GuiUtil.AutoSetDefaultFont(dlg);
            dlg.SqlServerName = this.textBox_sqlServerName.Text;
            dlg.StartPosition = FormStartPosition.CenterScreen;

            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }
#endif

#if NO
            // 创建dp2Kernel登录名

            // 创建一个适合于dpKernel的SQL Server login
            // return:
            //      -1  出错
            //      0   成功
            //      1   原来已经存在,且不允许删除
            nRet = CreateLogin(
                this.SqlServerName,
                dlg.SqlUserName,
                dlg.SqlPassword,
                dlg.SSPI,
                this.textBox_loginName.Text,
                this.textBox_loginPassword.Text,
                out strError);
            if (nRet == -1 || nRet == 1)
            {
                goto ERROR1;
            }
#endif
            this.button_OK.Enabled = false;
            try
            {
                nRet = VerifySqlServer(
                    this.SqlServerName,
                    this.textBox_loginName.Text,
                    this.textBox_loginPassword.Text,
                    false,
                    out strError);
                if (nRet == -1)
                {
                    DialogResult result = MessageBox.Show(this,
                                                          "在检查服务器参数的过程中发生错误: \r\n\r\n"
                                                          + strError
                                                          + "\r\n\r\n是否依然采用这些参数继续完成安装?",
                                                          "MySqlDataSourceDlg",
                                                          MessageBoxButtons.YesNo,
                                                          MessageBoxIcon.Question,
                                                          MessageBoxDefaultButton.Button2);
                    if (result == System.Windows.Forms.DialogResult.No)
                    {
                        MessageBox.Show(this, "请修改服务器参数");
                        return;
                    }
                }
            }
            finally
            {
                this.button_OK.Enabled = true;
            }


            this.DialogResult = DialogResult.OK;
            this.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
            // MessageBox.Show(this, "虽然刚才的创建登录名操作失败了,但您也可以在重新指定登录名和密码后,再次按“确定”按钮创建登录名,继续进行安装");
        }
Exemple #2
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            if (this.textBox_sqlServerName.Text == "")
            {
                strError = "尚未指定 MySQL 服务器";
                goto ERROR1;
            }

            if (string.Compare(this.textBox_sqlServerName.Text.Trim(), "~sqlite") == 0)
            {
                strError = "MySQL 服务器名不能为 '~sqlite',因为这个名字保留给了 SQLite 内置数据库类型";
                goto ERROR1;
            }

            if (this.textBox_loginName.Text == "")
            {
                strError = "尚未指定 MySQL 用户名";
                goto ERROR1;
            }

            if (this.textBox_loginPassword.Text != this.textBox_confirmLoginPassword.Text)
            {
                strError = "MySQL 帐户的密码和确认密码不一致";
                goto ERROR1;
            }

#if NO
            SaLoginDialog dlg = new SaLoginDialog();
            GuiUtil.AutoSetDefaultFont(dlg);
            dlg.SqlServerName = this.textBox_sqlServerName.Text;
            dlg.StartPosition = FormStartPosition.CenterScreen;

            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
                return;
#endif

#if NO
            // 创建dp2Kernel登录名

            // 创建一个适合于dpKernel的SQL Server login
            // return:
            //      -1  出错
            //      0   成功
            //      1   原来已经存在,且不允许删除
            nRet = CreateLogin(
                this.SqlServerName,
                dlg.SqlUserName,
                dlg.SqlPassword,
                dlg.SSPI,
                this.textBox_loginName.Text,
                this.textBox_loginPassword.Text,
                out strError);
            if (nRet == -1 || nRet == 1)
                goto ERROR1;
#endif
            this.button_OK.Enabled = false;
            try
            {
                nRet = VerifySqlServer(
                    this.SqlServerName,
                    this.textBox_loginName.Text,
                    this.textBox_loginPassword.Text,
                    false,
                    out strError);
                if (nRet == -1)
                {
                    DialogResult result = MessageBox.Show(this,
    "在检查服务器参数的过程中发生错误: \r\n\r\n"
    + strError
    + "\r\n\r\n是否依然采用这些参数继续完成安装?",
    "MySqlDataSourceDlg",
    MessageBoxButtons.YesNo,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button2);
                    if (result == System.Windows.Forms.DialogResult.No)
                    {
                        MessageBox.Show(this, "请修改服务器参数");
                        return;
                    }
                }
            }
            finally
            {
                this.button_OK.Enabled = true;
            }


            this.DialogResult = DialogResult.OK;
            this.Close();
            return;
        ERROR1:
            MessageBox.Show(this, strError);
            // MessageBox.Show(this, "虽然刚才的创建登录名操作失败了,但您也可以在重新指定登录名和密码后,再次按“确定”按钮创建登录名,继续进行安装");
        }
        private void button_OK_Click(object sender, EventArgs e)
        {
            string strError = "";
            int    nRet     = 0;

            if (this.textBox_sqlServerName.Text == "")
            {
                strError = "尚未指定 SQL 服务器";
                goto ERROR1;
            }

            if (string.Compare(this.textBox_sqlServerName.Text.Trim(), "~sqlite") == 0)
            {
                strError = "MS SQL 服务器名不能为 '~sqlite',因为这个名字保留给了 SQLite 内置数据库类型";
                goto ERROR1;
            }

            if (this.textBox_loginName.Text == "")
            {
                strError = "尚未指定 dp2Kernel 登录名";
                goto ERROR1;
            }

            if (this.textBox_loginPassword.Text != this.textBox_confirmLoginPassword.Text)
            {
                strError = "dp2Kernel 登录名的密码和确认密码不一致";
                goto ERROR1;
            }

            /*
             * if (this.SSPI == false && this.textBox_sqlUserName.Text == "")
             * {
             *  MessageBox.Show(this, "尚未指定SQL帐号。");
             *  return;
             * }
             *
             *
             * // 检测SQL帐户是否正确
             * EnableControls(false);
             * string strError = "";
             * int nRet = this.detect(this.textBox_sqlServerName.Text,
             *  this.textBox_sqlUserName.Text,
             *  this.textBox_sqlPassword.Text,
             *  radioButton_SSPI.Checked,
             *  out strError);
             * EnableControls(true);
             * if (nRet == -1)
             * {
             *  strError = strError + "\r\n" + "请重新指定服务器信息。";
             *  MessageBox.Show(this, strError);
             *  return;
             * }
             * */

            SaLoginDialog dlg = new SaLoginDialog();

            GuiUtil.AutoSetDefaultFont(dlg);
            dlg.SqlServerName = this.textBox_sqlServerName.Text;
            dlg.StartPosition = FormStartPosition.CenterScreen;

            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }

#if NO
            // 创建dp2Kernel登录名

            // 创建一个适合于dpKernel的SQL Server login
            // return:
            //      -1  出错
            //      0   成功
            //      1   原来已经存在,且不允许删除
            nRet = CreateLogin(
                this.SqlServerName,
                dlg.SqlUserName,
                dlg.SqlPassword,
                dlg.SSPI,
                this.textBox_loginName.Text,
                this.textBox_loginPassword.Text,
                out strError);
            if (nRet == -1 || nRet == 1)
            {
                goto ERROR1;
            }
#endif

            nRet = AddSystemDbCreatorRole(
                this.SqlServerName,
                dlg.SqlUserName,
                dlg.SqlPassword,
                dlg.SSPI,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            /*
             * if (nRet == 1)
             * {
             *  string strText = "登录名 '" + this.textBox_loginName.Text + "' 在SQL服务器 '" + this.SqlServerName + "' 中已经存在,但其密码不一定和当前指定的密码相同。\r\n\r\n是否继续使用这个登录名?\r\n(Yes)继续使用;(No)重新指定登录名和密码";
             *  DialogResult result = MessageBox.Show(this,
             *      strText,
             *      "setup_dp2Kernel",
             *      MessageBoxButtons.YesNo,
             *      MessageBoxIcon.Question,
             *      MessageBoxDefaultButton.Button2);
             *  if (result == DialogResult.No)
             *  {
             *      this.textBox_loginPassword.Focus();
             *      return;
             *  }
             * }
             * */

            this.DialogResult = DialogResult.OK;
            this.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
            MessageBox.Show(this, "虽然刚才的创建登录名操作失败了,但您也可以在重新指定登录名和密码后,再次按“确定”按钮创建登录名,继续进行安装");
        }