Exemple #1
0
        private void AspnetCodeGenerationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AspnetCodeGenerationDialog dialog = null;

            try
            {
                //check for a single entity
                if (listView.CheckedItems.Count != 1)
                {
                    MessageBox.Show("Please choose a single entity to generate ASP.NET code", "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (CheckForPrimaryKeys() == false)
                {
                    return;
                }

                dialog = new AspnetCodeGenerationDialog();

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    List <string> listTables   = new List <string>();
                    List <string> listEntities = new List <string>();

                    GetSelectedEntities(ref listTables, ref listEntities);

                    presenter.GenerateSilverChaliceObjects(dialog.NamespaceName, string.Empty, dialog.GenerateContentPlaceholder, Language.CSharp, listTables, listEntities);

                    MessageBox.Show("Files were successfully generated.", "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occurred while generating the files " + "\n" + ex.Message, "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (dialog != null)
                {
                    dialog.Dispose();
                }
            }
        }
Exemple #2
0
        private void AspnetCodeGenerationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AspnetCodeGenerationDialog dialog = null;


            try
            {
                //generate mappings
                menuItemGenerateMappingFiles_Click(null, null);


                //is something selected
                if (listView.CheckedItems.Count != 1)
                {
                    MessageBox.Show("Please choose a single entity to generate ASP.NET code", "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (CheckForPrimaryKeys() == false)
                {
                    return;
                }

                dialog = new AspnetCodeGenerationDialog();

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string entityName = string.Empty;
                    string tableName  = string.Empty;

                    ArrayList       alColumns        = new ArrayList();
                    ArrayList       alTableRelations = new ArrayList();
                    TableRelation[] relations        = new TableRelation[0];


                    int current = -1;


                    //get the entity names
                    for (int i = 0; i < listView.Items.Count; i++)
                    {
                        ++current;

                        if (listView.Items[i].Checked)
                        {
                            entityName = Utilies.RemoveEmptySpaces(Context.databaseTables[i].EntityName);
                            tableName  = Context.databaseTables[i].TableName;
                            relations  = Context.databaseTables[i].Relations;

                            break;
                        }
                    }

                    string currentFilePath = string.Empty;

                    AspnetCodeGenerator c = new AspnetCodeGenerator();
                    c.Generate(Context.databaseTables[current].Columns, dialog.NamespaceName, entityName, dialog.GenerateContentPlaceholder, Application.StartupPath + @"\Output", relations);

                    MessageBox.Show("Files were successfully generated.", "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occurred while generating the files " + "\n" + ex.Message, "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (dialog != null)
                {
                    dialog.Dispose();
                }
            }
        }