コード例 #1
0
        private void createDatabaseFromModelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewDbForm f = new NewDbForm();
            DialogResult result = f.ShowDialog();

            if (result == DialogResult.OK)
            {
                ModelForm frmModel = (ModelForm)dockPanel1.ActiveDocument;
                if (frmModel == null)
                    return;

                try
                {
                    DumpSql dsql = new DumpSql(frmModel.DataSet, frmModel.VisibleTables);
                    dsql.CreateNewDatabase(f.txtDbName.Text, frmModel.SqlSchema, dsql.SqlCode);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }

                MessageBox.Show("Database created!");
            }
        }
コード例 #2
0
        private void exportToSQLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ModelForm frmModel = (ModelForm)dockPanel1.ActiveDocument;
            if (frmModel == null)
                return;

            DumpSql dsql = new DumpSql(frmModel.DataSet, frmModel.VisibleTables);
            string sql = dsql.SqlCode;
            string preview = Path.GetTempFileName();

            StreamWriter sw = null;
            try
            {
                sw = new StreamWriter(preview, false);
                sw.Write(sql);
            }
            catch (Exception)
            {
                MessageBox.Show("Erro ao abrir ficheiro!", "Ocorreu um erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                sw.Close();
            }

            System.Diagnostics.Process.Start("notepad.exe", preview);
        }