2006年5月10日
Setup Project的Project Property 里 Prerequisites...
1. 顶上 Create setup program to install prerequisite components打上勾
2. 中间列表 .Net Framework 2.0打上勾 (Windows Install 3.1也是)
3. 下面 Download prerequisites from the same location as my application也打上勾
经过近一段时间对Enterprise Library的研究,在具体的实践过程中,发现其更新数据库的能力虽然比较强大,但是需要自己编写很多的代码,尤其是那些UpdataCommand以及InserCommand等,都要自己手工的编写,虽然在数据库的无关性方面有了很大的便捷性和灵活性,但是,在实际的操作过程中,感觉使用起来不是很方便,缺乏一定的智能性。
相反,vs2005提供的强数据类型集,提供了TableAdapter,能自动生成数据集和对应与物理数据库的数据逻辑表,通过提供的向导,可以很方便的建立自己的RUID操作,如果把这些做为一个DataModule的话,通过适当的包装,可以非常方便的形成自己的DataLayer,但缺点是数据库的无关性比较差,同时,如果更改了数据库中表的内容的话,这些强数据类型需要重新生成。
因此,如果是开发小型的应用,并且数据库相对稳定的话,感觉使用VS2005的Typed-DataSet比较适合一点,如果写一些比较大型或者比较通用的程序时候,可以选择Enterprise Library。这是一个折中的选择办法,也不一定合理,自己的感觉应该是这样。尤其是那些开发人员较少(只有两三个人)的情况下,使用vs2005本身提供的方法可以更好更快捷的完成程序的设计,因为目前差不多的软件开发者是项目开发者,而不是产品开发者,有明确的最终目标用户,同时也可以相对稳定的使用一种认定的数据库。
以上看法只是自己的理解,有不对的地方,多批评指正,欢迎交流和探讨。
好记性不如烂笔头,写下来,以后可以查看。
private void mnuLoad_Click(object sender, System.EventArgs e)

{
// TODO: Load Customers

Database db = null;
db = DatabaseFactory.CreateDatabase();

DataSet ds = db.ExecuteDataSet(
CommandType.Text,
"SELECT CustomerID,CompanyName,ContactName,ContactTitle From Customers");

gridControl1.DataSource = ds.Tables[0];

//设置成一次选择一行,并且不能被编辑
this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
this.gridView1.OptionsBehavior.Editable = false;
this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
//设置列的标题
gridView1.Columns[0].Caption = "客户编号";
gridView1.Columns[1].Caption = "公司名称";
gridView1.Columns[2].Caption = "联系人";
gridView1.Columns[3].Caption = "联系内容";
//设置列的名称,便于进行分组和Foot的统计等信息显示
gridView1.Columns[0].Name = "CustomerID";
//增加一个Group列进行分组

this.gridView1.GroupSummary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[]
{
new DevExpress.XtraGrid.GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Count, "CustomerID", null, "(Count={0})")});

}
另外又做了一个全面的测试,代码如下:
private void mnuLoad_Click(object sender, System.EventArgs e)

{
// TODO: Load Customers

Database db = null;
db = DatabaseFactory.CreateDatabase();

DataSet ds = db.ExecuteDataSet(
CommandType.Text,
"SELECT ID,Name,Age From UserInfo");

gridControl1.DataSource = ds.Tables[0];

//设置成一次选择一行,并且不能被编辑
this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
this.gridView1.OptionsBehavior.Editable = false;
this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
//设置列的标题
gridView1.Columns[0].Caption = "编号";
gridView1.Columns[1].Caption = "名称";
gridView1.Columns[2].Caption = "年龄";
//设置列的名称,便于进行分组和Foot的统计等信息显示
gridView1.Columns[0].Name = "ID";
gridView1.Columns[1].Name = "Name";
gridView1.Columns[2].Name = "Age";
//增加一个Group列进行分组

this.gridView1.GroupSummary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[]
{
new DevExpress.XtraGrid.GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Count, "ID", null, "(Count={0})")});

//增加一个Group列进行分组

this.gridView1.GroupSummary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[]
{
new DevExpress.XtraGrid.GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Max , "Age", null, "(Max={0})")});

//设置并制作Foot下面的统计信息
this.gridView1.GroupFooterShowMode = DevExpress.XtraGrid.Views.Grid.GroupFooterShowMode.VisibleAlways;
this.gridView1.OptionsView.ShowFooter = true;


gridView1.Columns[2].SummaryItem.DisplayFormat = "(Age={0})";
gridView1.Columns[2].SummaryItem.FieldName = "Age";
gridView1.Columns[2].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
}
//设置成cardview格式
private void menuItem2_Click(object sender, EventArgs e)

{
gridControl1.MainView = this.cardView1;
}
//设置成GridView格式
private void menuItem4_Click(object sender, EventArgs e)

{
gridControl1.MainView = this.gridView1 ;
}