Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (txtIP.Text.ToString().Length == 0 &&
                txtPort.Text.ToString().Length == 0 &&
                txtUsername.Text.ToString().Length == 0 &&
                txtPassword.Text.ToString().Length == 0 &&
                cbxDatabaseList.Text.ToString().Length == 0 &&
                adHocFilename.Length == 0)
            {
                MessageBox.Show("Fill the empty field(s).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            saveFileDialog1.InitialDirectory = AppDefaultDir;
            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                String SaveFile = saveFileDialog1.FileName;

                DBSP2ClassGen.dbhandler d = new DBSP2ClassGen.dbhandler();
                d.BuildAllStoredProcedureInfo(txtIP.Text.ToString(), txtPort.Text.ToString(), txtUsername.Text.ToString(), txtPassword.Text.ToString(), cbxDatabaseList.Text.ToString());
                d.LoadAllTemplate();
                if (adHocFilename != null)
                {
                    d.LoadAdHocQueryInfo(adHocFilename.ToString());
                }
                d.Build(saveFileDialog1.FileName.ToString());
                MessageBox.Show("File generated.", "info", MessageBoxButtons.OK);
                d.SaveConfig();
            }
            else
            {
                MessageBox.Show("You canceled.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
        private void cbxDatabaseList_DropDown(object sender, EventArgs e)
        {
            if (txtIP.Text.ToString().Length != 0 &&
                txtPort.Text.ToString().Length != 0 &&
                txtUsername.Text.ToString().Length != 0 &&
                txtPassword.Text.ToString().Length != 0)  // implement visual studio's db selection feature.
            {
                List <string>           dblist;
                DBSP2ClassGen.dbhandler d = new DBSP2ClassGen.dbhandler();

                dblist = d.GetDatabaseList(txtIP.Text.ToString(), txtPort.Text.ToString(), txtUsername.Text.ToString(), txtPassword.Text.ToString());

                cbxDatabaseList.Items.Clear();

                foreach (string dbname in dblist)
                {
                    cbxDatabaseList.Items.Add(dbname);
                }
            }
        }
Esempio n. 3
0
        public MainForm()
        {
            InitializeComponent();

            if (File.Exists("./config.json"))  // load config file if exists.
            {
                DBSP2ClassGen.dbhandler d = new DBSP2ClassGen.dbhandler();
                ConfigInfo ci             = new ConfigInfo();
                d.GetConfigInfo(ref ci);


                txtIP.Text           = ci.IP.ToString();
                txtPort.Text         = ci.port.ToString();
                txtUsername.Text     = ci.Username.ToString();
                txtPassword.Text     = ci.password.ToString();
                cbxDatabaseList.Text = ci.dbname.ToString();
                if (ci.adHocFilename != null)
                {
                    lblAdHoc.Text = ci.adHocFilename.ToString();
                }
            }
            AppDefaultDir = System.Environment.CurrentDirectory;
        }