예제 #1
0
        private void btnShowDatabases_Click(object sender, EventArgs e)
        {
            DatabaseProvider provider = cbProvider.Text.ToEnum<DatabaseProvider>();

            if (provider == DatabaseProvider.SQLite)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.CheckFileExists = false;
                if (ofd.ShowDialog() == DialogResult.OK)
                    txtDBName.Text = ofd.FileName;
            }
            else
            {
                Database.Database db = new Database.Database();
                db.SetConnectionString(provider, txtHost.Text, null, txtUserName.Text, txtPassword.Text);
                db.CreateDbProvider(false);

                ListBoxDialog lbd = new ListBoxDialog();
                lbd.ListBox.DataSource = db.GetDatabases();
                lbd.ListBox.SelectionMode = SelectionMode.One;
                lbd.Message = "Select a database";
                if (lbd.ShowDialog() == DialogResult.OK)
                    txtDBName.Text = lbd.GetSelectedItems<string>()[0];
            }
        }
예제 #2
0
파일: Controller.cs 프로젝트: fizikci/Cinar
        private void cmdShowGeneratedCode(string arg)
        {
            Item item = tree.SelectedNode.Tag as Item;

            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "Select base folder to compare generated code:";

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                ListBoxDialog lbd = new ListBoxDialog();
                lbd.Message = "Select tables (or views) to generate code for:";
                lbd.ListBox.DataSource = Provider.Database.Tables;

                if (lbd.ShowDialog() == DialogResult.OK)
                {
                    List<GeneratedCode> codes = item.GenerateCode(fbd.SelectedPath, lbd.GetSelectedItems<Table>());
                    foreach (GeneratedCode gc in codes)
                    {
                        if (gc.IsFolder) continue;

                        mainForm.addFileEditor(gc.Path, gc.Code);
                        //mainForm.CurrEditor.Content = gc.Code;
                    }
                }
            }
        }
예제 #3
0
파일: Controller.cs 프로젝트: fizikci/Cinar
        private void cmdGenerateCode(string arg)
        {
            if (Provider.Database == null)
            {
                MessageBox.Show("Select a database first", "Cinar Database Tools");
                return;
            }

            Item item = tree.SelectedNode.Tag as Item;

            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "Select base folder to generate the code into:";

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                ListBoxDialog lbd = new ListBoxDialog();
                lbd.Message = "Select tables (or views) to generate code for:";
                lbd.ListBox.DataSource = Provider.Database.Tables;

                if (lbd.ShowDialog() == DialogResult.OK)
                {
                    item.CreateCode(fbd.SelectedPath, lbd.GetSelectedItems<Table>());
                    Process.Start(fbd.SelectedPath);
                }
            }
        }