private void btnGenerateColumnDefine_Click(object sender, EventArgs e) { string fullname = this.txtClassFullName.Text.Trim(); object obj = ReflectHelper.CreateInstance(fullname); if (obj == null) { MessageBoxHelper.Show("不存在该类型!"); return; } Type type = obj.GetType(); if (type == null) { } else { DataTable dt = FT.DAL.Orm.SimpleOrmCache.GetConditionDT(type); if (dt != null) { string cn = this.txtClassCnName.Text.Trim(); FT.DAL.DataAccessFactory.GetDataAccess().ExecuteSql("delete from table_entity_column_define where c_class_full_name='" + FT.DAL.DALSecurityTool.TransferInsertField(fullname) + "'"); EntityColumnDefine column = new EntityColumnDefine(); int i = 1; foreach (DataRow dr in dt.Rows) { column.ClassCnName = cn; column.ExportWidth = 10; column.HeaderName = dr["text"].ToString(); column.HeaderWidth = 80; column.IsExportExcel = true; column.IsPrinted = true; column.OrderNum = i; column.ColumnName = dr["value"].ToString(); column.PrintedWidth = 80; column.PropertyName = column.HeaderName; column.ShowInDetail = true; column.DetailWidth = 80; column.ClassFullName = fullname; FT.DAL.Orm.SimpleOrmOperator.Create(column); //column.s i++; } MessageBoxHelper.Show("创建成功,共" + i + "个列!"); } } }
private void btnGenerateColumnDefine_Click(object sender, EventArgs e) { string fullname = this.txtClassFullName.Text.Trim(); object obj=ReflectHelper.CreateInstance(fullname); if (obj == null) { MessageBoxHelper.Show("�����ڸ����ͣ�"); return; } Type type = obj.GetType(); if (type == null) { } else { DataTable dt = FT.DAL.Orm.SimpleOrmCache.GetConditionDT(type); if (dt != null) { string cn = this.txtClassCnName.Text.Trim(); FT.DAL.DataAccessFactory.GetDataAccess().ExecuteSql("delete from table_entity_column_define where c_class_full_name='" + FT.DAL.DALSecurityTool.TransferInsertField(fullname)+"'"); EntityColumnDefine column = new EntityColumnDefine(); int i = 1; foreach (DataRow dr in dt.Rows) { column.ClassCnName = cn; column.ExportWidth = 10; column.HeaderName = dr["text"].ToString(); column.HeaderWidth = 80; column.IsExportExcel = true; column.IsPrinted = true; column.OrderNum=i; column.ColumnName = dr["value"].ToString(); column.PrintedWidth = 80; column.PropertyName = column.HeaderName; column.ShowInDetail = true; column.DetailWidth = 80; column.ClassFullName = fullname; FT.DAL.Orm.SimpleOrmOperator.Create(column); //column.s i++; } MessageBoxHelper.Show("�����ɹ�,��" + i + "���У�"); } } }
/// <summary> /// 设置Grid的样式 /// </summary> protected virtual void SettingGridStyle() { this.dataGridView1.AutoGenerateColumns = false; string key = this.entityType.FullName + "-detail-columndefine"; ArrayList lists; if (StaticCacheManager.Get(key) != null) { lists = StaticCacheManager.Get(key) as ArrayList; } else { lists = FT.DAL.Orm.SimpleOrmOperator.QueryConditionList <FT.Windows.Forms.EntityColumnDefine> (" where bool_showindetail='True' and c_class_full_name='" + this.entityType.FullName + "' order by i_order_num"); StaticCacheManager.Add(key, lists); } EntityColumnDefine column = null; for (int i = 0; i < lists.Count - 1; i++) { column = lists[i] as EntityColumnDefine; if (column.ShowInDetail) { this.CreateColumn(column.PropertyName, column.HeaderName, column.HeaderWidth); } } column = lists[lists.Count - 1] as EntityColumnDefine; if (column.ShowInDetail) { if (this.dataGridView1.DisplayedColumnCount(false) < lists.Count - 1) { this.CreateColumn(column.PropertyName, column.HeaderName, column.HeaderWidth); } else { this.CreateColumn(column.PropertyName, column.HeaderName); } } }