Esempio n. 1
0
        // 打开连接文件
        private void cbMySqlName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //打开连接文件解密密码并对界面赋值
                DBConnector_XSD xsd = new DBConnector_XSD();
                xsd.MySql.ReadXml(ConnectionFolder + @"\MySql\" + cbMySqlName.Text + ".xml");
                if (xsd.MySql.Rows.Count > 0)
                {
                    DBConnector_XSD.MySqlRow dr = xsd.MySql.Rows[0] as DBConnector_XSD.MySqlRow;
                    dr.PwdD = Apq.Security.Cryptography.DESHelper.DecryptString(Apq.Convert.ChangeType <string>(dr["PwdC"]),
                                                                                Apq.Win.GlobalObject.XmlAsmConfig["Apq.Win.GlobalObject", "DESKey"],
                                                                                Apq.Win.GlobalObject.XmlAsmConfig["Apq.Win.GlobalObject", "DESIV"]
                                                                                );

                    txtMySqlServer.Text = dr.Server;
                    txtMySqlUserId.Text = dr.Uid;
                    txtMySqlPwd.Text    = dr.PwdD;
                    txtMySqlPort.Text   = dr.Port;
                    if (!Apq.Convert.IsNull(dr["DBName"]))
                    {
                        cbMySqlDBName.Text = dr.DBName;
                    }

                    btnMySqlSaveName.Enabled = false;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }
Esempio n. 2
0
        // 保存
        private void btnMySqlSaveName_Click(object sender, EventArgs e)
        {
            try
            {
                if (!cbMySqlName.Items.Contains(cbMySqlName.Text))
                {
                    cbMySqlName.Items.Add(cbMySqlName.Text);
                }

                //获取界面值,加密密码后生成连接文件,覆盖保存
                DBConnector_XSD xsd = new DBConnector_XSD();
                DataRow         dr  = xsd.MySql.NewRow();
                xsd.MySql.Rows.Add(dr);
                dr["Server"] = txtMySqlServer.Text;
                dr["Port"]   = txtMySqlPort.Text;
                dr["Uid"]    = txtMySqlUserId.Text;
                dr["PwdD"]   = txtMySqlPwd.Text;
                if (!string.IsNullOrWhiteSpace(cbMySqlDBName.Text))
                {
                    dr["DBName"] = cbMySqlDBName.Text;
                }
                if (cbMySqlSavePwd.Checked)
                {
                    dr["PwdC"] = Apq.Security.Cryptography.DESHelper.EncryptString(txtMySqlPwd.Text,
                                                                                   Apq.Win.GlobalObject.XmlAsmConfig["Apq.Win.GlobalObject", "DESKey"],
                                                                                   Apq.Win.GlobalObject.XmlAsmConfig["Apq.Win.GlobalObject", "DESIV"]
                                                                                   );
                }

                xsd.MySql.Columns.Remove("PwdD");
                if (!cbMySqlSavePwd.Checked)
                {
                    xsd.MySql.Columns.Remove("PwdC");
                }
                if (!Directory.Exists(ConnectionFolder + @"\MySql"))
                {
                    Directory.CreateDirectory(ConnectionFolder + @"\MySql");
                }
                xsd.MySql.WriteXml(ConnectionFolder + @"\MySql\" + cbMySqlName.Text + ".xml", XmlWriteMode.IgnoreSchema);

                btnMySqlSaveName.Enabled = false;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }
Esempio n. 3
0
		// 打开连接文件
		private void cbMySqlName_SelectedIndexChanged(object sender, EventArgs e)
		{
			try
			{
				//打开连接文件解密密码并对界面赋值
				DBConnector_XSD xsd = new DBConnector_XSD();
				xsd.MySql.ReadXml(ConnectionFolder + @"\MySql\" + cbMySqlName.Text + ".xml");
				if (xsd.MySql.Rows.Count > 0)
				{
					DBConnector_XSD.MySqlRow dr = xsd.MySql.Rows[0] as DBConnector_XSD.MySqlRow;
					dr.PwdD = Apq.Security.Cryptography.DESHelper.DecryptString(Apq.Convert.ChangeType<string>(dr["PwdC"]),
						Apq.Win.GlobalObject.XmlAsmConfig["Apq.Win.GlobalObject", "DESKey"],
						Apq.Win.GlobalObject.XmlAsmConfig["Apq.Win.GlobalObject", "DESIV"]
					);

					txtMySqlServer.Text = dr.Server;
					txtMySqlUserId.Text = dr.Uid;
					txtMySqlPwd.Text = dr.PwdD;
					txtMySqlPort.Text = dr.Port;
					if (!Apq.Convert.IsNull(dr["DBName"]))
					{
						cbMySqlDBName.Text = dr.DBName;
					}

					btnMySqlSaveName.Enabled = false;
				}
			}
			catch (System.Exception ex)
			{
				MessageBox.Show(this, ex.Message);
			}
		}
Esempio n. 4
0
		// 保存
		private void btnMySqlSaveName_Click(object sender, EventArgs e)
		{
			try
			{
				if (!cbMySqlName.Items.Contains(cbMySqlName.Text))
				{
					cbMySqlName.Items.Add(cbMySqlName.Text);
				}

				//获取界面值,加密密码后生成连接文件,覆盖保存
				DBConnector_XSD xsd = new DBConnector_XSD();
				DataRow dr = xsd.MySql.NewRow();
				xsd.MySql.Rows.Add(dr);
				dr["Server"] = txtMySqlServer.Text;
				dr["Port"] = txtMySqlPort.Text;
				dr["Uid"] = txtMySqlUserId.Text;
				dr["PwdD"] = txtMySqlPwd.Text;
				if (!string.IsNullOrWhiteSpace(cbMySqlDBName.Text))
				{
					dr["DBName"] = cbMySqlDBName.Text;
				}
				if (cbMySqlSavePwd.Checked)
				{
					dr["PwdC"] = Apq.Security.Cryptography.DESHelper.EncryptString(txtMySqlPwd.Text,
						Apq.Win.GlobalObject.XmlAsmConfig["Apq.Win.GlobalObject", "DESKey"],
						Apq.Win.GlobalObject.XmlAsmConfig["Apq.Win.GlobalObject", "DESIV"]
					);
				}

				xsd.MySql.Columns.Remove("PwdD");
				if (!cbMySqlSavePwd.Checked)
				{
					xsd.MySql.Columns.Remove("PwdC");
				}
				if (!Directory.Exists(ConnectionFolder + @"\MySql"))
				{
					Directory.CreateDirectory(ConnectionFolder + @"\MySql");
				}
				xsd.MySql.WriteXml(ConnectionFolder + @"\MySql\" + cbMySqlName.Text + ".xml", XmlWriteMode.IgnoreSchema);

				btnMySqlSaveName.Enabled = false;
			}
			catch (System.Exception ex)
			{
				MessageBox.Show(this, ex.Message);
			}
		}