Example #1
0
        /// <summary>
        /// 创建生成
        /// </summary>
        /// <param name="conModel"></param>
        /// <param name="tableName"></param>
        void lp_newcontentForm(Dos.Tools.Model.Connection conModel, string tableName, string databaseName, bool isView)
        {
            ContentForm s = new ContentForm();

            s.Text            = "(" + databaseName + ")" + tableName;
            s.TableName       = tableName;
            s.DatabaseName    = databaseName;
            s.IsView          = isView;
            s.ConnectionModel = conModel;
            s.Show(dpleft);
        }
Example #2
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cbbServer.Text))
            {
                MessageBox.Show("服务器不能为空!");
                return;
            }

            if (cbbShenFenRZ.SelectedIndex == 1 && string.IsNullOrEmpty(txtUserName.Text))
            {
                MessageBox.Show("登陆名不能为空!");
                return;
            }

            string tempconnectionstring = createConnectionString(cbbDatabase.SelectedIndex == 0 ? "master" : cbbDatabase.Text);

            try
            {
                using (SqlConnection conn = new SqlConnection(tempconnectionstring))
                {
                    conn.Open();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("连接失败!\n\r" + ex.Message);
                return;
            }



            Model.Connection connectionModel = new Dos.Tools.Model.Connection();
            connectionModel.Database = cbbDatabase.SelectedIndex == 0 ? "all" : cbbDatabase.Text;
            connectionModel.ID       = Guid.NewGuid();
            connectionModel.Name     = cbbServer.Text + "(" + cbbServerType.Text + ")[" + connectionModel.Database + "]";
            if (cbbServerType.SelectedIndex == 0)
            {
                connectionModel.DbType = Dos.ORM.DatabaseType.SqlServer.ToString();
            }
            else
            {
                connectionModel.DbType = Dos.ORM.DatabaseType.SqlServer9.ToString();
            }
            connectionModel.ConnectionString = tempconnectionstring;

            Utils.AddConnection(connectionModel);

            this.DialogResult = DialogResult.OK;

            this.Close();
        }
Example #3
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cbbServer.Text))
            {
                MessageBox.Show("服务器不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(txtUserName.Text))
            {
                MessageBox.Show("登陆名不能为空!");
                return;
            }
            IDbObject dbObejct             = new Dos.DbObjects.MySQL.DbObject(false, cbbServer.Text, txtUserName.Text, txtPassword.Text, txtport.Text);
            string    tempconnectionstring = dbObejct.DbConnectStr;

            try
            {
                using (MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection(tempconnectionstring))
                {
                    connection.Open();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("连接失败!\n\r" + ex.Message);
                return;
            }



            Model.Connection connectionModel = new Dos.Tools.Model.Connection();
            connectionModel.Database         = cbbDatabase.SelectedIndex == 0 ? "all" : cbbDatabase.Text;
            connectionModel.ID               = Guid.NewGuid();
            connectionModel.Name             = cbbServer.Text + "(MySql)[" + connectionModel.Database + "]";
            connectionModel.ConnectionString = tempconnectionstring;
            connectionModel.DbType           = Dos.ORM.DatabaseType.MySql.ToString();



            Utils.AddConnection(connectionModel);

            this.DialogResult = DialogResult.OK;

            this.Close();
        }
Example #4
0
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            button1_Click(null, null);

            if (!isConnection)
            {
                return;
            }


            Model.Connection connectionModel = new Dos.Tools.Model.Connection();
            connectionModel.Database         = cbbServer.Text;
            connectionModel.ID               = Guid.NewGuid();
            connectionModel.Name             = cbbServer.Text + "(Oracle)";
            connectionModel.ConnectionString = dbObject.DbConnectStr;
            connectionModel.DbType           = Dos.ORM.DatabaseType.Oracle.ToString();
            Utils.AddConnection(connectionModel);

            this.DialogResult = DialogResult.OK;

            this.Close();
        }
Example #5
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (rbconnstring.Checked)
            {
                if (string.IsNullOrEmpty(txtConnectionString.Text))
                {
                    MessageBox.Show("请填写连接字符串!");
                    return;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(txtfilepath.Text))
                {
                    MessageBox.Show("请选择Sqlite数据库文件!");
                    return;
                }
            }

            Model.Connection connModel = new Dos.Tools.Model.Connection();

            if (rbdatabaseselect.Checked)
            {
                StringBuilder cstring = new StringBuilder("Data Source=");
                cstring.Append(txtfilepath.Text);
                cstring.Append(";");
                if (!string.IsNullOrEmpty(txtPassword.Text))
                {
                    cstring.Append("Password="******";");
                }

                connModel.ConnectionString = cstring.ToString();
                connModel.Name             = txtfilepath.Text;
                connModel.Database         = connModel.Name.Substring(connModel.Name.LastIndexOf('\\') + 1);
            }
            else
            {
                connModel.ConnectionString = txtConnectionString.Text;


                string constring       = txtConnectionString.Text;
                string templeftstring  = string.Empty;
                string temprightstring = string.Empty;
                if (constring.IndexOf('/') > 0)
                {
                    templeftstring  = constring.Substring(0, constring.LastIndexOf('/'));
                    temprightstring = constring.Substring(constring.LastIndexOf('/') + 1);
                }
                else if (constring.IndexOf('\\') > 0)
                {
                    templeftstring  = constring.Substring(0, constring.LastIndexOf('\\'));
                    temprightstring = constring.Substring(constring.LastIndexOf('\\') + 1);
                }
                else
                {
                    MessageBox.Show("连接字符串格式不正确!");
                    return;
                }

                if (temprightstring.IndexOf(';') > 0)
                {
                    temprightstring = temprightstring.Substring(0, temprightstring.IndexOf(';'));
                }

                templeftstring = templeftstring.Substring(templeftstring.IndexOf('=') + 1);


                connModel.Name     = templeftstring + temprightstring;
                connModel.Database = temprightstring;
            }

            try
            {
                using (SQLiteConnection oledbConn = new SQLiteConnection(connModel.ConnectionString))
                {
                    oledbConn.Open();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("连接失败!\n\r" + ex.Message);
                return;
            }

            connModel.DbType = Dos.ORM.DatabaseType.Sqlite3.ToString();
            connModel.ID     = Guid.NewGuid();

            Utils.AddConnection(connModel);

            this.DialogResult = DialogResult.OK;

            this.Close();
        }
Example #6
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (rbconnstring.Checked)
            {
                if (string.IsNullOrEmpty(txtConnectionString.Text))
                {
                    MessageBox.Show("请填写连接字符串!");
                    return;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(txtfilepath.Text))
                {
                    MessageBox.Show("请选择Access文件!");
                    return;
                }
            }

            Model.Connection connModel = new Dos.Tools.Model.Connection();

            if (rbdatabaseselect.Checked)
            {
                StringBuilder cstring = new StringBuilder();

                string exstension = txtfilepath.Text.Substring(txtfilepath.Text.LastIndexOf('.') + 1);
                if (exstension.ToLower().Equals("mdb"))
                {
                    cstring.Append("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=");
                }
                else if (exstension.ToLower().Equals("accdb"))
                {
                    cstring.Append("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=");
                }

                cstring.Append(txtfilepath.Text);
                cstring.Append(";");
                if (!string.IsNullOrEmpty(txtPassword.Text))
                {
                    cstring.Append("User Id=");
                    cstring.Append(txtUserName.Text);
                    cstring.Append(";Password="******";");
                }

                connModel.ConnectionString = cstring.ToString();
                connModel.Name             = txtfilepath.Text;
                connModel.Database         = connModel.Name.Substring(connModel.Name.LastIndexOf('\\') + 1);
            }
            else
            {
                connModel.ConnectionString = txtConnectionString.Text;


                string constring       = txtConnectionString.Text;
                string templeftstring  = string.Empty;
                string temprightstring = string.Empty;
                if (constring.IndexOf('/') > 0)
                {
                    templeftstring  = constring.Substring(0, constring.LastIndexOf('/'));
                    temprightstring = constring.Substring(constring.LastIndexOf('/') + 1);
                }
                else if (constring.IndexOf('\\') > 0)
                {
                    templeftstring  = constring.Substring(0, constring.LastIndexOf('\\'));
                    temprightstring = constring.Substring(constring.LastIndexOf('\\') + 1);
                }
                else
                {
                    MessageBox.Show("连接字符串格式不正确!");
                    return;
                }

                if (temprightstring.IndexOf(';') > 0)
                {
                    temprightstring = temprightstring.Substring(0, temprightstring.IndexOf(';'));
                }

                templeftstring = templeftstring.Substring(templeftstring.IndexOf('=') + 1);


                connModel.Name     = templeftstring + temprightstring;
                connModel.Database = temprightstring;
            }

            try
            {
                using (OleDbConnection oledbConn = new OleDbConnection(connModel.ConnectionString))
                {
                    oledbConn.Open();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("连接失败!\n\r" + ex.Message);
                return;
            }

            connModel.DbType = Dos.ORM.DatabaseType.MsAccess.ToString();
            connModel.ID     = Guid.NewGuid();

            Utils.AddConnection(connModel);

            this.DialogResult = DialogResult.OK;

            this.Close();
        }