• 大小: 196KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: C#
  • 标签: 生成代码  

资源简介

配置数据库连接字符串后 一键生成三层架构代码,包含通用的增删改查

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CreateCode
{
    public partial class Create : System.Web.UI.Page
    {
        string dbSort = string.IsNullOrWhiteSpace(System.Configuration.ConfigurationManager.ConnectionStrings[“connString“].ProviderName) ? ““ : System.Configuration.ConfigurationManager.ConnectionStrings[“connString“].ProviderName;
        List tables = null;
        protected void Page_Load(object sender EventArgs e)
        {
           
            if (!IsPostBack)
            {
                switch (dbSort)
                {
                    case “mysql“:
                        tables = Service.MySqlService.GetAllTable();
                        ddlTablename.DataSource = tables;
                        ddlTablename.DataBind();
                        break;

                    case “mssql“:
                        tables = Service.MsSqlService.GetAllTable();
                        ddlTablename.DataSource = tables;
                        ddlTablename.DataBind();
                        break;

                }

               
            }
        }

        protected void Button1_Click(object sender EventArgs e)
        {
            string tableName = ddlTablename.SelectedValue;
            if (dbSort == “mysql“)
            {

                if (string.IsNullOrWhiteSpace(txtSavePath.Text))
                {
                    scriptManager.RegisterStartupscript(this.Page this.GetType() “msg0“ “alert(‘路径不能为空‘);“ true);
                    return;
                }
                Service.MySqlService.CreateModel(tableName txtSavePath.Text);
                Service.MySqlService.CreateDal(tableName txtSavePath.Text);
                Service.MySqlService.CreateBLL(tableName txtSavePath.Text);
                scriptManager.RegisterStartupscript(this.Page this.GetType() “msg0“ “alert(‘生成成功‘);“ true);
            }

            if (dbSort == “mssql“)
            {
                if (string.IsNullOrWhiteSpace(txtSavePath.Text))
                {
                    scriptManager.RegisterStartupscript(this.Page this.GetType() “msg0“ “alert(‘路径不能为空‘);“ true);
                    return;
                }
                Service.MsSqlService.CreateModel(tableName txtSavePath.Text);
                Service.MsSqlService.CreateDal(tableName txtSavePath.Text);
                Service.MsSqlService.CreateBLL(tableName txtSavePath.Text);
                scriptManager.RegisterStartupscript(this.Page this.GetType() “msg0“ “alert(‘生成成功‘);“ true);
            }
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-08-29 12:01  CreateCode\
     文件        1765  2018-08-29 12:01  CreateCode\Create.aspx
     文件        2786  2018-08-29 11:54  CreateCode\Create.aspx.cs
     文件        2178  2018-08-29 11:53  CreateCode\Create.aspx.designer.cs
     文件        5580  2018-08-29 11:54  CreateCode\CreateCode.csproj
     文件        1457  2018-08-29 11:54  CreateCode\CreateCode.csproj.user
     目录           0  2018-08-29 11:27  CreateCode\Properties\
     文件        1313  2018-08-29 11:27  CreateCode\Properties\AssemblyInfo.cs
     目录           0  2018-08-29 16:41  CreateCode\Service\
     文件        2346  2018-08-29 11:53  CreateCode\Service\Common.cs
     文件       29778  2018-08-29 11:53  CreateCode\Service\DirFileCommon.cs
     文件       26788  2018-08-29 16:40  CreateCode\Service\MsSqlService.cs
     文件       25291  2018-08-29 16:41  CreateCode\Service\MySqlService.cs
     文件        1246  2018-08-29 11:27  CreateCode\Web.Debug.config
     文件        1307  2018-08-29 11:27  CreateCode\Web.Release.config
     文件         497  2018-08-29 11:27  CreateCode\Web.config
     目录           0  2018-08-31 13:51  CreateCode\bin\
     文件       38912  2018-08-31 13:51  CreateCode\bin\CreateCode.dll
     文件         497  2018-08-29 11:27  CreateCode\bin\CreateCode.dll.config
     文件       52736  2018-08-31 13:51  CreateCode\bin\CreateCode.pdb
     文件       14848  2018-08-31 13:51  CreateCode\bin\DBUnitily.dll
     文件       32256  2018-08-31 13:51  CreateCode\bin\DBUnitily.pdb
     文件      294912  2018-07-02 09:54  CreateCode\bin\MySql.Data.dll
     目录           0  2018-08-29 11:27  CreateCode\obj\
     目录           0  2018-08-31 13:51  CreateCode\obj\Debug\
     文件           0  2018-08-31 13:51  CreateCode\obj\Debug\CreateCode.csproj.CopyComplete
     文件          42  2018-08-31 13:51  CreateCode\obj\Debug\CreateCode.csproj.CoreCompileInputs.cache
     文件         874  2018-08-31 13:51  CreateCode\obj\Debug\CreateCode.csproj.FileListAbsolute.txt
     文件       15964  2018-08-31 13:51  CreateCode\obj\Debug\CreateCode.csprojAssemblyReference.cache
     文件       38912  2018-08-31 13:51  CreateCode\obj\Debug\CreateCode.dll
     文件       52736  2018-08-31 13:51  CreateCode\obj\Debug\CreateCode.pdb
............此处省略2个文件信息

评论

共有 条评论

相关资源