private void btnOk_Click(object sender, EventArgs e)
        {
            FileInfo fileInfo = cbxHost.SelectedItem as FileInfo;
            string   text     = File.ReadAllText(fileInfo.FullName, Encoding.UTF8);

            ConnectionString = Newtonsoft.Json.JsonConvert.DeserializeObject <PgConnectionString>(text);
            if (ConnectionString != null)
            {
                DialogResult = DialogResult.OK;
            }
        }
Beispiel #2
0
        private void 打开OToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var dialog = new SelectFormDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                PgConnectionString cs = dialog.ConnectionString;
                tbxHost.Text     = cs.Host;
                numPort.Value    = (decimal)cs.Port;
                tbxUser.Text     = cs.DBUser;
                tbxPassword.Text = cs.DBPassword;
                tbxDatabase.Text = cs.DBName;
            }
        }
Beispiel #3
0
        private void 保存SToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string dirPath = Application.StartupPath + "/DB";

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }
            string filePath = string.Format("{0}/{1}.{2}.config",
                                            dirPath, tbxHost.Text.Trim(), tbxDatabase.Text.Trim());
            PgConnectionString connString = new PgConnectionString(tbxHost.Text.Trim(), (int)numPort.Value, tbxUser.Text.Trim(), tbxPassword.Text.Trim(), tbxDatabase.Text.Trim());

            File.WriteAllText(filePath, JsonConvert.SerializeObject(connString), Encoding.UTF8);
            MessageBox.Show("已保存");
        }