Пример #1
0
 private void btnGen_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtNameSpace.Text.Trim().Length < 1)
         {
             MessageBox.Show("命名空间需要输入");
         }
         if (txtClassName.Text.Trim().Length < 1)
         {
             MessageBox.Show("实体类名需要输入");
         }
         if (rtbContent.Text.Trim().Length < 1)
         {
             MessageBox.Show("类属性文本需要输入");
         }
         EntityInfo entity = GetEntity();
         txtResult.AppendText(DateTime.Now.ToLongTimeString() + "  开始生成代码..." + Environment.NewLine);
         EntityEngine.GenEntityCode(_baseFolder, entity);
         txtResult.AppendText(DateTime.Now.ToLongTimeString() + "  完成实体代码生成。" + Environment.NewLine);
     }
     catch (Exception ex)
     {
         MessageBox.Show("生成出错:" + ex.ToString());
     }
 }
Пример #2
0
        private void btnGenCode_Click(object sender, EventArgs e)
        {
            try
            {
                string baseFolder = txtFolderRoot.Text.Trim();
                string entityPath = txtEntityPath.Text.Trim();
                if (baseFolder.IndexOf(@"\") < 1)
                {
                    MessageBox.Show("请选择模板文件根目录");
                    return;
                }
                if (entityPath.IndexOf(@"\") < 1)
                {
                    MessageBox.Show("请选择实体类文件路径");
                    return;
                }
                if (ddlGenType.SelectedIndex < 0)
                {
                    MessageBox.Show("请选择生成代码类别");
                    return;
                }

                EntityInfo entity = GetEntity(entityPath);
                if (ddlGenType.SelectedIndex == 0)
                {
                    //MessageBox.Show("AppServiceModule");
                    rtbInfo.AppendText(DateTime.Now.ToLongTimeString() + "  开始生成应用服务层模块代码..." + Environment.NewLine);
                    EntityEngine.GenApplicationCode(baseFolder, entity);
                    rtbInfo.AppendText(DateTime.Now.ToLongTimeString() + "  完成生成应用服务层模块代码。" + Environment.NewLine);
                }
                if (ddlGenType.SelectedIndex == 1)
                {
                    rtbInfo.AppendText(DateTime.Now.ToLongTimeString() + "  开始生成弹窗风格的增删改查界面代码..." + Environment.NewLine);
                    EntityEngine.GenAreasCode(baseFolder, entity);
                    rtbInfo.AppendText(DateTime.Now.ToLongTimeString() + "  完成生成弹窗风格的增删改查界面代码。" + Environment.NewLine);
                }
                if (ddlGenType.SelectedIndex == 2)
                {
                    rtbInfo.AppendText(DateTime.Now.ToLongTimeString() + "  开始生成新开页面的增删改查界面代码..." + Environment.NewLine);
                    EntityEngine.GenAreasCode(baseFolder, entity, 1);
                    rtbInfo.AppendText(DateTime.Now.ToLongTimeString() + "  完成生成新开页面的增删改查界面代码。" + Environment.NewLine);
                }
                if (ddlGenType.SelectedIndex == 3)
                {
                    rtbInfo.AppendText(DateTime.Now.ToLongTimeString() + "  开始生成混合风格的增删改查界面代码..." + Environment.NewLine);
                    EntityEngine.GenAreasCode(baseFolder, entity, 2);
                    rtbInfo.AppendText(DateTime.Now.ToLongTimeString() + "  完成生成混合风格的增删改查界面代码。" + Environment.NewLine);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("生成出错。具体信息:" + ex.Message);
            }
        }