Beispiel #1
0
 private void cboServer_SelectedIndexChanged(object sender, EventArgs e)
 {
     DataRow[] drs = m_dt.Select("IP='" + cboServer.Text.Trim() + "'");
     if (drs.Length > 0)
     {
         cboUser.Text     = drs[0]["User"].ToString();
         txtPassword.Text = DESEncryptHelper.Decrypt(drs[0]["Pwd"].ToString(), "test332211");
     }
 }
Beispiel #2
0
        /// <summary>连接
        /// 连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!CheckInput())
            {
                return;
            }
#if !DEBUG
            if (txtDB.Text.Trim() == string.Empty)
            {
                m_ServerDB = DataBaseManager.GetDataBase(dbType, BuildConn(this.dbType));
                if (m_ServerDB.Rows.Count > 5)
                {
                    dialog = MessageBox.Show(@"一共需要加载【" + m_ServerDB.Rows.Count + "】个数据库,需要时间较长,建议按需加载", "提示", MessageBoxButtons.YesNo);
                    if (dialog == DialogResult.Yes)
                    {
                        btnSelectDB_Click(null, null);
                        return;
                    }
                }
            }
#endif
#if  DEBUG
            LoadDatabase = new DataTable();
            LoadDatabase.Columns.Add("name", typeof(string));
            DataRow dr = LoadDatabase.NewRow();
            dr["name"] = GlobalHelp.DefauleDatabase;
            LoadDatabase.Rows.Add(dr);
#endif

            bool flag = TestConn(this.dbType);
            if (flag)
            {
                if (chkRem.Checked)
                {
                    DataSet ds = m_dalConn.GetList("IP='" + cboServer.Text.Trim() + "'");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        m_dalConn.DeleteByCond("IP='" + cboServer.Text.Trim() + "'");
                    }
                    DbConnect model = new DbConnect
                    {
                        IP         = cboServer.Text.Trim(),
                        Pwd        = DESEncryptHelper.Encrypt(txtPassword.Text.Trim(), "test332211"),
                        User       = cboUser.Text.Trim(),
                        Remark     = this.dbType.ToString(),
                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    };
                    m_dalConn.Add(model);
                }
                DBConn = BuildConn(this.dbType);
                Server = cboServer.Text.Trim();
                UID    = cboUser.Text.Trim();
                PWD    = txtPassword.Text.Trim();
                if (this.dbType == SqlType.MySql)
                {
                    Port = cboLogin.Text.Trim();
                }
                List <string> lstLoadType = new List <string>();
                foreach (CCBoxItem item in chkAllowType.CheckedItems)
                {
                    lstLoadType.Add(item.Name);
                }
                LoadType = lstLoadType;

                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(@"连接失败");
            }
        }