三层代码生成器

1.0版本:

目前知道的缺陷有:

1、产生文件存储的路径需要自己填写,如果没有这个地址会报错;

2、对视图也会生成model对象,这个是没有意义的;

3、对视图产生的DAL类的getObject方法有错误,因为视图没有主键列;

4、DAL中的方法还不够多,没有多列组合等;

5、没有使用存储过程;

6、只是生成代码文件,不能自动生成编译后的文件,需要用户自动生成。

注:由于时间、金钱、···等等x种因素,这些缺陷都没有得到改善!日后有机会一定整好!

优点:简单易用,层层清晰。

2.0版本上线:

1、添加了对存储过程生成代码,并且在DAL中有存储过程调用方法。

2、添加了IDAL层。

3、使用了反射、配置文件,是程序更加趋向与运行时动态。

4、界面做了一些美化。

2.2更新:2013年7月7日

1、添加了方法的参数备注项,在调用方法时会出现智能感知提示。

 2.2版本 点击下载

3.0更新:2013年10月14日

三层代码生成器_第1张图片

1、采用WPF界面实现。

2、优化了界面布局。

3、自动生成WEB_UI层的页面:

    • 一张表的列表 (具体应用到项目中需要稍加修改,修改工作量指数 ★★★)
    • 表中某条记录的详细情况 (具体应用到项目中需要稍加修改,修改工作量指数 ★)
    • 添加一条记录的添加页(具体应用到项目中需要稍加修改,修改工作量指数 ★★★)

4、对Model类字段的可空处理和模糊查询

  BLL层中每个类都添加了如下方法:

public DataTable GetFuzzData(Model.Products Products)
{
return dal.GetFuzzData(Products);
}

该方法对于到SQLDAL中会根据Model对象的属性是否为空动态生成对应的查询字符串和查询参数,以实现模糊查询:

 1 public DataTable GetFuzzData(Model.Products Products)  2  {  3             
 4             string sqlSelect = "select * from [Products] where ";  5             List<SqlParameter> SPList = new List<SqlParameter>();  6             if (Products.ProductID != null)  7  {  8                 sqlSelect += "[ProductID] like @ProductID";  9                 SqlParameter SP=new SqlParameter("@ProductID",SqlDbType.NVarChar); 10                 SP.Value="%"+Products.ProductID.ToString()+"%"; 11  SPList.Add(SP); 12  } 13             if (!string.IsNullOrEmpty(Products.ProductName)) 14  { 15                 sqlSelect += "and [ProductName] like @ProductName"; 16                 SqlParameter SP=new SqlParameter("@ProductName",SqlDbType.NVarChar); 17                 SP.Value="%"+Products.ProductName.ToString()+"%"; 18  SPList.Add(SP); 19  } 20             if (Products.Discontinued != null) 21  { 22                 sqlSelect += "and [Discontinued] like @Discontinued"; 23                 SqlParameter SP=new SqlParameter("@Discontinued",SqlDbType.NVarChar); 24                 SP.Value="%"+Products.Discontinued.ToString()+"%"; 25  SPList.Add(SP); 26  } 27             if (Products.SupplierID != null) 28  { 29                 sqlSelect += "and [SupplierID] like @SupplierID"; 30                 SqlParameter SP=new SqlParameter("@SupplierID",SqlDbType.NVarChar); 31                 SP.Value="%"+Products.SupplierID.ToString()+"%"; 32  SPList.Add(SP); 33  } 34             if (Products.CategoryID != null) 35  { 36                 sqlSelect += "and [CategoryID] like @CategoryID"; 37                 SqlParameter SP=new SqlParameter("@CategoryID",SqlDbType.NVarChar); 38                 SP.Value="%"+Products.CategoryID.ToString()+"%"; 39  SPList.Add(SP); 40  } 41             if (!string.IsNullOrEmpty(Products.QuantityPerUnit)) 42  { 43                 sqlSelect += "and [QuantityPerUnit] like @QuantityPerUnit"; 44                 SqlParameter SP=new SqlParameter("@QuantityPerUnit",SqlDbType.NVarChar); 45                 SP.Value="%"+Products.QuantityPerUnit.ToString()+"%"; 46  SPList.Add(SP); 47  } 48             if (Products.UnitPrice != null) 49  { 50                 sqlSelect += "and [UnitPrice] like @UnitPrice"; 51                 SqlParameter SP=new SqlParameter("@UnitPrice",SqlDbType.NVarChar); 52                 SP.Value="%"+Products.UnitPrice.ToString()+"%"; 53  SPList.Add(SP); 54  } 55             if (Products.UnitsInStock != null) 56  { 57                 sqlSelect += "and [UnitsInStock] like @UnitsInStock"; 58                 SqlParameter SP=new SqlParameter("@UnitsInStock",SqlDbType.NVarChar); 59                 SP.Value="%"+Products.UnitsInStock.ToString()+"%"; 60  SPList.Add(SP); 61  } 62             if (Products.UnitsOnOrder != null) 63  { 64                 sqlSelect += "and [UnitsOnOrder] like @UnitsOnOrder"; 65                 SqlParameter SP=new SqlParameter("@UnitsOnOrder",SqlDbType.NVarChar); 66                 SP.Value="%"+Products.UnitsOnOrder.ToString()+"%"; 67  SPList.Add(SP); 68  } 69             if (Products.ReorderLevel != null) 70  { 71                 sqlSelect += "and [ReorderLevel] like @ReorderLevel"; 72                 SqlParameter SP=new SqlParameter("@ReorderLevel",SqlDbType.NVarChar); 73                 SP.Value="%"+Products.ReorderLevel.ToString()+"%"; 74  SPList.Add(SP); 75  } 76             return SQLHelper.getDataTableFormDataBase(SQLHelper.ConnectionStrings, CommandType.Text, sqlSelect, SPList.ToArray()); 77 
78         }

 

5、对Model添加了 INotifyPropertyChanged接口实现,用于双向绑定。

 

3.0 下载地址

BUG:

1、sqlserverdal中生成modle对象的方法getObject,当库里面为bit类型和varbinary的时候会出现类型转换错误。

2\数据库字段开头字母为大写时,生成的model字段会和属性冲突。

3\数据库字段为float类型、Datetime类型时SQLserverdal中sql参数类型出错。

4、SQLserverdal中Uniqueidentifier应该为UniqueIdentifier

6、SQLserverdal中update_por接口未实现

7、WebTemplate中添加页面,添加方法中对model对象的属性访问应该为首字母大写.

8\SQLServerDAL中的Update方法和UpdatePro方法未实现(实现为upDateTime和upDateTimePro方法,并且有错误!)


删除线的bug已经修复

你可能感兴趣的:(三层代码生成器)