private void BtnSelectDir_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择输出目录"; dialog.SelectedPath = txtDir.Text; if (dialog.ShowDialog() == DialogResult.OK) { string foldPath = dialog.SelectedPath; txtDir.Text = foldPath; ParamSetting.SaveConfig(Global.config_file, "OutputPath", foldPath); } }
private void MenuSetting_Click(object sender, EventArgs e) { FrmSetting frmSetting = new FrmSetting(); frmSetting.StartPosition = FormStartPosition.CenterParent; if (frmSetting.ShowDialog() == DialogResult.OK) { string connstr = ParamSetting.GetConfigValue(Global.config_file, "ConnectionString"); string[] config = connstr.Split(';'); if (config.Length > 1) { GetTableList(); this.txtServer.Text = config[0].Substring(config[0].IndexOf("=") + 1); this.cbxDatabase.Text = config[1].Substring(config[1].IndexOf("=") + 1); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); InitEvent(); string connstr = ParamSetting.GetConfigValue(Global.config_file, "ConnectionString"); string[] config = connstr.Split(';'); string outputPath = ParamSetting.GetConfigValue(Global.config_file, "OutputPath"); txtDir.Text = outputPath; this.txtServer.Text = config[0].Substring(config[0].IndexOf("=") + 1); this.cbxDatabase.Text = config[1].Substring(config[1].IndexOf("=") + 1); GetTableList(); }
private void BtnOK_Click(object sender, EventArgs e) { string _connStr = ""; if (this.cbxDatabase.SelectedIndex == 0) { MessageBox.Show("请选择数据库"); return; } _connStr = "server=" + this.txtServer.Text + ";database=" + this.cbxDatabase.Text + ";uid=" + this.txtUserName.Text + ";pwd=" + this.txtPassword.Text; //将数据库连接参数保存到配置文件里 if (ParamSetting.SaveConfig(Global.config_file, "ConnectionString", _connStr)) { MessageBox.Show("保存数据库配置成功"); this.DialogResult = DialogResult.OK; this.Close(); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string connstr = ParamSetting.GetConfigValue(Global.config_file, "ConnectionString"); string[] config = connstr.Split(';'); InitDatabaseList(connstr); this.txtServer.Text = config[0].Substring(config[0].IndexOf("=") + 1); this.cbxDatabase.SelectedValue = config[1].Substring(config[1].IndexOf("=") + 1); this.txtUserName.Text = config[2].Substring(config[2].IndexOf("=") + 1); this.txtPassword.Text = config[3].Substring(config[3].IndexOf("=") + 1); btnCancel.Click += BtnCancel_Click; btnOK.Click += BtnOK_Click; //txtPassword.TextChanged += TxtPassword_TextChanged; txtPassword.KeyDown += TxtPassword_KeyDown; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); InitEvent(); try { string outputPath = ParamSetting.GetConfigValue(Global.config_file, "OutputPath"); txtDir.Text = outputPath; string connstr = ParamSetting.GetConfigValue(Global.config_file, "ConnectionString"); string[] config = connstr.Split(';'); if (config.Length > 1) { GetTableList(); this.txtServer.Text = config[0].Substring(config[0].IndexOf("=") + 1); this.cbxDatabase.Text = config[1].Substring(config[1].IndexOf("=") + 1); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { string connstr = ParamSetting.GetConfigValue(Global.config_file, "ConnectionString"); string[] config = connstr.Split(';'); if (config.Length > 1) { InitDatabaseList(connstr); this.txtServer.Text = config[0].Substring(config[0].IndexOf("=") + 1); this.cbxDatabase.SelectedValue = config[1].Substring(config[1].IndexOf("=") + 1); this.txtUserName.Text = config[2].Substring(config[2].IndexOf("=") + 1); this.txtPassword.Text = config[3].Substring(config[3].IndexOf("=") + 1); } } catch { } btnCancel.Click += BtnCancel_Click; btnOK.Click += BtnOK_Click; txtPassword.LostFocus += (s, evn) => { TxtPassword_TextChanged(null, null); }; txtPassword.KeyDown += TxtPassword_KeyDown; }