public Column EntityToColumn(ColumnEntity toConvert) { Point position = new Point(toConvert.CoordX, toConvert.CoordY); Column conversion = new Column(position); return(conversion); }
public ActionResult ExportDataStandards(string queryJson) { try { Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); Pagination pagination = new Pagination(); pagination.page = 1; pagination.rows = 1000000000; pagination.p_kid = "storeid"; pagination.p_fields = "FileName,FileCode,IssueDept,to_char(releasedate,'yyyy-MM-dd') as releasedate,to_char(revisedate,'yyyy-MM-dd') as revisedate,to_char(carrydate,'yyyy-MM-dd') as carrydate,lawtypename"; pagination.p_tablename = " bis_storelaw c left join (select id as lid,CreateDate,FileName,IssueDept,FileCode,ValidVersions,CarryDate,FilesId,releasedate,revisedate,lawtypename,LawTypeCode,createuserorgcode from bis_safestandards a ) t on c.lawid=t.lid"; pagination.conditionJson = string.Format("userid='{0}' and ctype='3'", user.UserId); DataTable exportTable = storelawbll.GetPageJsonStandards(pagination, queryJson); //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = "安全操作规程信息"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 16; excelconfig.FileName = "安全操作规程导出.xls"; excelconfig.IsAllSizeColumn = true; List <ColumnEntity> listColumnEntity = new List <ColumnEntity>(); excelconfig.ColumnEntity = listColumnEntity; ColumnEntity columnentity = new ColumnEntity(); //需跟数据源列顺序保持一致 excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "filename", ExcelColumn = "文件名称", Width = 40 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "filecode", ExcelColumn = "文件编号", Width = 25 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "issuedept", ExcelColumn = "发布单位(部门)", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "releasedate", ExcelColumn = "发布时间", Width = 10 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "revisedate", ExcelColumn = "修订时间", Width = 10 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "carrydate", ExcelColumn = "实施时间", Width = 10 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "lawtypename", ExcelColumn = "类型", Width = 20 }); //调用导出方法 ExcelHelper.ExcelDownload(exportTable, excelconfig); } catch (Exception ex) { } return(Success("导出成功。")); }
public static string GetEasyUIColumn(ColumnEntity col) { StringBuilder sb = new StringBuilder(); int width = col.Width <= 0 ? 100 : col.Width; sb.Append("{"); sb.Append("field:\"" + col.Field + "\",title:\"" + col.Display + "\","); sb.Append("align:\"" + col.Align.ToString().ToLower() + "\",width:" + width + ""); if (!col.Sortable) { sb.Append(",sortable:false"); } if (!string.IsNullOrEmpty(col.FormatString)) { sb.Append(",formatter:song.column.render.format(\"" + col.FormatString + "\")"); } DataType dataType = DataTypeManager.Parse(col.DataType); if (dataType == DataType.Boolean) { sb.Append(",formatter:song.column.render.yesno"); } sb.Append("}"); return(sb.ToString()); }
public PropertySchema(string propertyName, PropertyInfo propInfo, string columnName, ColumnEntity columnSchema) { PropertyName = propertyName; PropInfo = propInfo; ColumnName = columnName; ColumnSchema = columnSchema; }
public void ConstructorSyscatColumn() { var model = new ColumnEntity(new SyscatColumn() { ColName = "Test", ColNo = 1, Default = "Test", Identity = 'N', Length = 1, Nulls = 'Y', TabName = "Test", TypeName = "Test" }); var result = model.Validate(); Assert.False(result.Any()); Assert.Null(model.Description); Assert.Equal(decimal.Zero, model.Id); Assert.Equal("Test.Test", model.SyncId); Assert.Equal("TEST", model.TableName); Assert.Equal("TEST", model.Name); Assert.Equal(1, model.Number); Assert.Equal("Test", model.Default); Assert.Equal('N', model.IsIdentity); Assert.Equal(1, model.Length); Assert.Equal('Y', model.IsNull); Assert.Equal("Test", model.Type); }
public string GetUpdateSql(ColumnEntity entity) { StringBuilder sb = new StringBuilder(); sb.AppendLine("update [Column] set "); sb.AppendLine("[TableID]=" + entity.TableID + ","); sb.AppendLine("[Field]='" + entity.Field + "',"); sb.AppendLine("[Display]='" + entity.Display + "',"); sb.AppendLine("DataType='" + entity.DataType.ToString() + "',"); sb.AppendLine("Length=" + entity.Length + ","); sb.AppendLine("Precision=" + entity.Precision + ","); sb.AppendLine("IsDataKey=" + GetBoolValue(entity.IsDataKey) + ","); sb.AppendLine("EditorType='" + entity.EditorType.ToString() + "',"); sb.AppendLine("Sortable=" + GetBoolValue(entity.Sortable) + ","); sb.AppendLine("Queryable=" + GetBoolValue(entity.Queryable) + ","); sb.AppendLine("Hidden=" + GetBoolValue(entity.Hidden) + ","); sb.AppendLine("Required=" + GetBoolValue(entity.Required) + ","); sb.AppendLine("[Width]=" + entity.Width + ","); sb.AppendLine("FormatString='" + entity.FormatString + "',"); sb.AppendLine("DefaultValue=@DefaultValue,"); sb.AppendLine("Align='" + entity.Align + "',"); sb.AppendLine("SortID=" + entity.SortID + ","); sb.AppendLine("[Enabled]=" + GetBoolValue(entity.Enabled) + ""); sb.AppendLine(" where ID=" + entity.ID); string sql = sb.ToString(); return(sql); }
public BaseObject UpdateColumn(ColumnEntity param) { using (ColumnLogic logic = new ColumnLogic(_db)) { return(logic.UpdateColumn(param)); } }
protected override BaseJsonHandler Handle() { ColumnEntity[] columns; switch (State.MandatoryColumns) { case MandatoryColumns.All: columns = State.Columns.ToArray(); break; case MandatoryColumns.Required: columns = State.Columns.Where(q => q.IsRequired).ToArray(); break; default: columns = new ColumnEntity[0]; break; } var propertyNames = State.OriginalRequest.Properties().Select(s => s.Name).ToArray(); foreach (var column in columns) { if (!propertyNames.Contains(column.ColumnName)) { State.AddError(column.ColumnName, ErrorMessages.MissingProperty); State.Continue = false; } else if (string.IsNullOrWhiteSpace(State.OriginalRequest[column.ColumnName].Value <string>())) { State.AddError(column.ColumnName, ErrorMessages.Required); } } return(this); }
public BaseObject InsertColumn(ColumnEntity param) { using (ColumnLogic logic = new ColumnLogic(_db)) { return(logic.InsertColumn(param)); } }
public void FromEntity() { var entity = new ColumnEntity() { Default = "Test", Description = "Test", Id = 1, IsIdentity = 'N', IsNull = 'Y', Length = 1, Name = "Test", Number = 1, TableName = "Test", Type = "Test" }; var model = new ColumnViewModel(entity); var result = model.Validate(); Assert.False(result.Any()); Assert.Equal(entity.Default, model.Default); Assert.Equal(entity.Description, model.Description); Assert.Equal(entity.Id, model.Id); Assert.Equal(entity.IsIdentity, model.IsIdentity.First()); Assert.Equal(entity.IsNull, model.IsNull.First()); Assert.Equal(entity.Length, model.Length); Assert.Equal(entity.Name, model.Name); Assert.Equal(entity.Number, model.Number); Assert.Equal(entity.TableName, model.TableName); Assert.Equal(entity.Type, model.Type); }
public string GetTypeName(ColumnEntity column) { var typeEntity = GetType(column); var type = typeEntity?.Type == null ? typeof(string) : typeEntity.Type; return(type.ToKeywordName(column.Dimension)); }
/// <summary> /// 生成表单 /// </summary> /// <param name="columns">列集合</param> /// <param name="column">每行生成多少个字段</param> /// <returns></returns> public static string GetFormItems(IList <ColumnEntity> columns, int column, int tabCount) { bool isQuery = false; StringBuilder sb = new StringBuilder(); IList <ColumnEntity> list = FilterColumns(columns, isQuery); int lines = CodeUtils.GetLineCount(list.Count, column); int columnIndex = 0; string lineTab = CodeUtils.GetTab(tabCount), itemTab = CodeUtils.GetNextTab(lineTab), controlTab = CodeUtils.GetNextTab(itemTab); //循环生成表单 for (int i = 0; i < lines; i++) { sb.AppendLine(lineTab + "<div class=\"line\">"); //循环生成每一行的表单元素 for (int j = 0; j < column; j++) { if (columnIndex < list.Count) { ColumnEntity col = list[columnIndex]; sb.AppendLine(itemTab + "<div class=\"short\">"); sb.AppendLine(controlTab + "<label>" + (col.Required ? "<em>*</em>" : "") + "" + col.Display + ":</label>"); sb.AppendLine(controlTab + GetFormControl(col)); sb.AppendLine(itemTab + "</div>"); columnIndex++; } } sb.AppendLine(lineTab + "</div>"); } return(sb.ToString()); }
public void ConstructorColumnViewModel() { var model = new ColumnEntity(new ColumnViewModel() { Default = "Test", Description = "Test", Id = 1, IsIdentity = "N", IsNull = "Y", Length = 1, Name = "Test", Number = 1, TableName = "Test", Type = "Test" }); var result = model.Validate(); Assert.False(result.Any()); Assert.Equal("Test", model.Description); Assert.Equal(1, model.Id); Assert.Null(model.SyncId); Assert.Equal("TEST", model.TableName); Assert.Equal("TEST", model.Name); Assert.Equal(1, model.Number); Assert.Equal("Test", model.Default); Assert.Equal('N', model.IsIdentity); Assert.Equal(1, model.Length); Assert.Equal('Y', model.IsNull); Assert.Equal("Test", model.Type); }
public ActionResult Export(string queryJson) { Pagination pagination = new Pagination(); queryJson = queryJson ?? ""; pagination.page = 1; pagination.rows = 100000000; pagination.p_kid = "id"; pagination.p_fields = "REALNAME,GENDER,identifyid,DEPTNAME,jointime,reason"; pagination.p_tablename = "bis_blacklist a left join v_userinfo u on a.userid=u.userid"; pagination.conditionJson = "isblack=1"; string where = new AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value, "DEPARTMENTCODE", "OrganizeCode"); pagination.conditionJson = string.IsNullOrEmpty(where) ? pagination.conditionJson : pagination.conditionJson + " and " + where; var watch = CommonHelper.TimerStart(); var data = new UserBLL().GetPageList(pagination, queryJson); //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = "人员黑名单"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 25; excelconfig.FileName = "人员黑名单.xls"; excelconfig.IsAllSizeColumn = true; //每一列的设置,没有设置的列信息,系统将按datatable中的列名导出 List <ColumnEntity> listColumnEntity = new List <ColumnEntity>(); ColumnEntity columnentity = new ColumnEntity(); listColumnEntity.Add(new ColumnEntity() { Column = "REALNAME".ToLower(), ExcelColumn = "姓名", Alignment = "Center" }); listColumnEntity.Add(new ColumnEntity() { Column = "GENDER".ToLower(), ExcelColumn = "性别", Alignment = "Center" }); listColumnEntity.Add(new ColumnEntity() { Column = "identifyid".ToLower(), ExcelColumn = "身份证号", Alignment = "Center" }); listColumnEntity.Add(new ColumnEntity() { Column = "DEPTNAME".ToLower(), ExcelColumn = "单位/部门", Alignment = "Center" }); listColumnEntity.Add(new ColumnEntity() { Column = "jointime".ToLower(), ExcelColumn = "加入黑名单时间", Alignment = "Center" }); listColumnEntity.Add(new ColumnEntity() { Column = "reason".ToLower(), ExcelColumn = "加入黑名单原因", Alignment = "Center" }); excelconfig.ColumnEntity = listColumnEntity; //调用导出方法 ExcelHelper.ExcelDownload(data, excelconfig); return(Success("导出成功。")); }
public ActionResult ExportDataLaw(string queryJson) { try { Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); Pagination pagination = new Pagination(); pagination.page = 1; pagination.rows = 1000000000; pagination.p_kid = "storeid"; pagination.p_fields = @"FileName,FileCode,to_char(b.CreateDate,'yyyy-MM-dd') as CreateDate,to_char(CarryDate,'yyyy-MM-dd') as CarryDate,IssueDept,case when Effetstate='1' then '现行有效' when Effetstate ='2' then '即将实施' when Effetstate='3' then '已修订' when Effetstate='4' then '废止' end Effetstate"; pagination.p_tablename = " bis_storelaw a left join bis_safetylaw b on a.lawid=b.id"; pagination.conditionJson = "userid='" + user.UserId + "' and ctype='1'"; DataTable exportTable = storelawbll.GetPageDataTable(pagination, queryJson); //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = "安全生产法律法规信息"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 16; excelconfig.FileName = "安全生产法律法规信息导出.xls"; excelconfig.IsAllSizeColumn = true; List <ColumnEntity> listColumnEntity = new List <ColumnEntity>(); excelconfig.ColumnEntity = listColumnEntity; ColumnEntity columnentity = new ColumnEntity(); //需跟数据源列顺序保持一致 excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "filename", ExcelColumn = "标题名称", Width = 40 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "filecode", ExcelColumn = "文号/标准号", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "createdate", ExcelColumn = "发布时间", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "carrydate", ExcelColumn = "实施日期", Width = 15 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "issuedept", ExcelColumn = "发布机关", Width = 30 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "effetstate", ExcelColumn = "时效性", Width = 15 }); //调用导出方法 ExcelHelper.ExcelDownload(exportTable, excelconfig); } catch (Exception ex) { } return(Success("导出成功。")); }
public ActionResult ExportData(string queryJson) { try { var queryParam = queryJson.ToJObject(); Pagination pagination = new Pagination(); pagination.page = 1; pagination.rows = 1000000000; pagination.p_kid = "ID"; pagination.p_fields = "dataname,checkcode,to_char(uploadtime,'yyyy-MM-dd') as uploadtime,uploadpersonname"; pagination.p_tablename = " bis_owncheck "; pagination.conditionJson = "1=1"; Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); if (!user.IsSystem) { pagination.conditionJson += " and createuserorgcode='" + user.OrganizeCode + "'"; } var data = owncheckbll.GetPageList(pagination, queryJson); //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = "自行检测"; excelconfig.FileName = "自行检测信息导出.xls"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 16; excelconfig.IsAllSizeColumn = true; List <ColumnEntity> listColumnEntity = new List <ColumnEntity>(); excelconfig.ColumnEntity = listColumnEntity; ColumnEntity columnentity = new ColumnEntity(); //需跟数据源列顺序保持一致 excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "dataname", ExcelColumn = "资料名称", Width = 300 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "checkcode", ExcelColumn = "编号", Width = 300 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "uploadtime", ExcelColumn = "上传时间", Width = 300 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "uploadpersonname", ExcelColumn = "上传人员", Width = 300 }); //调用导出方法 //ExcelHelper.ExcelDownload(exportTable, excelconfig); ExcelHelper.ExportByAspose(data, excelconfig.FileName, excelconfig.ColumnEntity); } catch (Exception ex) { } return(Success("导出成功。")); }
public ActionResult AddColumnJson(ColumnEntity param) { param.UpdateUser = User.Identity.Name.Uint(); var result = new SystemHelper().InsertColumn(param); return(Json(result)); }
public ColumnDescViewModel(ColumnEntity entity) { if (entity != null) { Id = entity.Id; Description = entity.Description; } }
public static string GetAspNetColumn(ColumnEntity col) { StringBuilder sb = new StringBuilder(); string width = col.Width > 0 ? "HeaderStyle-Width=\"" + col.Width + "\"" : ""; sb.AppendFormat("<asp:BoundField DataField=\"{0}\" HeaderText=\"{1}\" {2}/>", col.Field, col.Display, width); return(sb.ToString()); }
public static void SetDefault(ColumnEntity entity) { entity.Enabled = true; entity.Sortable = true; entity.Queryable = false; entity.Hidden = false; entity.Width = 0; }
public static void SetAlign(ColumnEntity col, DataType dataType) { col.Align = DispatchServers.AlignType.Left; if (IsNumber(dataType)) { col.Align = DispatchServers.AlignType.Right; } }
public ActionResult Export(string queryJson) { Pagination pagination = new Pagination(); var watch = CommonHelper.TimerStart(); pagination.p_kid = "id"; pagination.p_fields = "ItemName,ItemType,Score,case WHEN isauto=0 then '否' else '是' end as isautostr"; pagination.p_tablename = "(select * from BIS_SCORESET order by CreateDate desc) t"; pagination.conditionJson = "1=1"; pagination.page = 1; pagination.rows = 100000000; Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); if (user.IsSystem) { pagination.conditionJson = "deptcode='00'"; } else { pagination.conditionJson = string.Format(" (deptcode='00' or deptcode='{0}')", user.OrganizeCode); } var data = scoresetbll.GetPageJsonList(pagination, queryJson); //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = "积分标准设置"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 25; excelconfig.FileName = "积分标准设置.xls"; excelconfig.IsAllSizeColumn = true; //每一列的设置,没有设置的列信息,系统将按datatable中的列名导出 List <ColumnEntity> listColumnEntity = new List <ColumnEntity>(); ColumnEntity columnentity = new ColumnEntity(); listColumnEntity.Add(new ColumnEntity() { Column = "ItemName".ToLower(), ExcelColumn = "积分项目", Alignment = "Center", Width = 20 }); listColumnEntity.Add(new ColumnEntity() { Column = "ItemType".ToLower(), ExcelColumn = "积分类型", Alignment = "Center", Width = 20 }); listColumnEntity.Add(new ColumnEntity() { Column = "score".ToLower(), ExcelColumn = "积分标准值(分/次)", Alignment = "Center", Width = 20 }); listColumnEntity.Add(new ColumnEntity() { Column = "isautostr".ToLower(), ExcelColumn = "是否允许系统自动积分", Alignment = "Center", Width = 20 }); excelconfig.ColumnEntity = listColumnEntity; //调用导出方法 ExcelHelper.ExcelDownload(data, excelconfig); return(Success("导出成功。")); }
public ActionResult Export(string queryJson) { Pagination pagination = new Pagination(); pagination.page = 1; pagination.rows = 100000000; pagination.p_kid = "ID"; pagination.p_fields = "PatrolType,PatrolDept,PatrolPerson,District,to_char(PatrolDate,'yyyy-MM-dd hh24:mi') as PatrolDate,PROBLEMNUM,createuserid"; pagination.p_tablename = "HRS_EVERYDAYPATROL"; pagination.conditionJson = "1=1"; var watch = CommonHelper.TimerStart(); var data = everydaypatrolbll.GetPageList(pagination, queryJson); //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = "消防日常巡查"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 25; excelconfig.FileName = "消防日常巡查.xls"; excelconfig.IsAllSizeColumn = true; //每一列的设置,没有设置的列信息,系统将按datatable中的列名导出 List <ColumnEntity> listColumnEntity = new List <ColumnEntity>(); ColumnEntity columnentity = new ColumnEntity(); listColumnEntity.Add(new ColumnEntity() { Column = "patroltype", ExcelColumn = "巡查类型", Alignment = "center" }); listColumnEntity.Add(new ColumnEntity() { Column = "patroldept", ExcelColumn = "巡查部门", Alignment = "center" }); listColumnEntity.Add(new ColumnEntity() { Column = "patrolperson", ExcelColumn = "巡查人", Alignment = "center" }); listColumnEntity.Add(new ColumnEntity() { Column = "district", ExcelColumn = "巡查区域", Alignment = "center" }); listColumnEntity.Add(new ColumnEntity() { Column = "patroldate", ExcelColumn = "巡查时间", Alignment = "center" }); listColumnEntity.Add(new ColumnEntity() { Column = "problemnum", ExcelColumn = "存在问题数量", Alignment = "center" }); excelconfig.ColumnEntity = listColumnEntity; //调用导出方法 //ExcelHelper.ExcelDownload(data, excelconfig); //调用导出方法 ExcelHelper.ExportByAspose(data, excelconfig.FileName, listColumnEntity); return(Success("导出成功。")); }
public static void SetLength(ColumnEntity col, DataType dataType, int len, int p) { //只有string类型才读取长度 if (dataType == DataType.String) { col.Length = len; } col.Precision = p > 0 ? p : len; }
public async Task <bool> Update(ColumnEntity entity) { var query = updateQuery.Replace("@Params", "cdescription=@Description", StringComparison.InvariantCulture); query = query.Replace("@Where", ColumnEntity.keyQuery, StringComparison.InvariantCulture); using var cnn = GetConnection(); return(await cnn.ExecuteAsync(query, entity, commandTimeout : cnn.ConnectionTimeout).ConfigureAwait(false) == 1); }
public static Column ToTable(this ColumnEntity column) { return(new Column { ColumnId = column.ColumnId, Header = column.Header, Brush = column.Brush, BoardId = column.BoardId }); }
public ActionResult ExportInoroutrecordList(string condition, string queryJson) { Pagination pagination = new Pagination(); var SUPPLIESID = Request["SUPPLIESID"] ?? ""; queryJson = queryJson ?? ""; pagination.page = 1; pagination.rows = 100000000; pagination.p_kid = "ID"; pagination.p_fields = "CREATEUSERID, STATUNAME,NUM,SUPPLIESUNTILNAME,USERNAME,INOROUTTIME"; pagination.p_tablename = "MAE_INOROUTRECORD t"; pagination.conditionJson = "1=1"; pagination.sidx = "STATUNAME"; //string where = new AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value, "departmentcode", "organizecode"); //pagination.conditionJson = string.IsNullOrEmpty(where) ? "1=1" : where; pagination.conditionJson += string.Format(" and SUPPLIESID='{0}'", SUPPLIESID); var data = inoroutrecordbll.GetPageList(pagination, queryJson); //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = "出入库记录"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 25; excelconfig.FileName = "出入库记录.xls"; excelconfig.IsAllSizeColumn = true; //每一列的设置,没有设置的列信息,系统将按datatable中的列名导出 List <ColumnEntity> listColumnEntity = new List <ColumnEntity>(); ColumnEntity columnentity = new ColumnEntity(); listColumnEntity.Add(new ColumnEntity() { Column = "STATUNAME".ToLower(), ExcelColumn = "方式" }); listColumnEntity.Add(new ColumnEntity() { Column = "NUM".ToLower(), ExcelColumn = "数量" }); listColumnEntity.Add(new ColumnEntity() { Column = "SUPPLIESUNTILNAME".ToLower(), ExcelColumn = "单位" }); listColumnEntity.Add(new ColumnEntity() { Column = "USERNAME".ToLower(), ExcelColumn = "执行人" }); listColumnEntity.Add(new ColumnEntity() { Column = "INOROUTTIME".ToLower(), ExcelColumn = "时间" }); excelconfig.ColumnEntity = listColumnEntity; //调用导出方法 ExcelHelper.ExcelDownload(data, excelconfig); return(Success("导出成功。")); }
public override IList <ColumnEntity> GetColumns(TableEntity table) { IList <ColumnEntity> list = null; DataTable columns = new DataTable(); columns.Locale = CultureInfo.CurrentCulture; using (SqlConnection connection = new SqlConnection(table.DbConnectionStringBuilder.ConnectionString)) { connection.Open(); SqlCommand command = connection.CreateCommand(); command.CommandText = string.Format(CultureInfo.CurrentCulture, "SELECT TOP 1 * FROM {0}", table.Name); using (IDataReader reader = command.ExecuteReader(CommandBehavior.KeyInfo)) { columns = reader.GetSchemaTable(); reader.Close(); } #region //DataTable columns = connection.GetSchema(SqlClientMetaDataCollectionNames.Columns, new string[] { null, null, table.Name, null }); //if (columns != null && columns.Rows.Count > 0) //{ // list = new List<ColumnEntity>(); // DataView dv = columns.DefaultView; // dv.Sort = "ORDINAL_POSITION asc"; // foreach (DataRowView view in dv) // { // string name = string.Format("{0}", view["COLUMN_NAME"]); // string description = string.Format("{0}({1})", view["COLUMN_NAME"], view["DATA_TYPE"]); // ColumnEntity column = new ColumnEntity(table.DbConnectionStringBuilder,name); // column.Description = description; // column.DataType = DbType.SqlParse(view["DATA_TYPE"].ToString()); // column.Table = table; // list.Add(column); // } //} #endregion } if (columns != null) { list = new List <ColumnEntity>(); foreach (DataRow row in columns.Rows) { ColumnEntity column = new ColumnEntity(table.DbConnectionStringBuilder, row["ColumnName"].ToString()); column.Description = string.Format("{0}({1})", row["ColumnName"].ToString(), row["DataTypeName"].ToString()); column.AllowDBNull = bool.Parse(row["AllowDBNull"].ToString()); column.DataType = (Type)row["DataType"]; column.IsIdentity = (bool)row["IsIdentity"]; column.IsPrimaryKey = (bool)row["IsKey"]; column.IsReadOnly = (bool)row["IsReadOnly"]; column.IsUnique = (bool)row["IsUnique"]; column.Table = table; list.Add(column); } CheckForeignKeys(table, list); } return(list); }
public static ColumnEntity CreateColumnEntity(string columnName, ColumnDataTypeDefinition columnDatatype, bool isIdentity, int ordinalPosition, bool isForeignKey, string constraintDefinition, ForeignKeyEntity foreignKeyEntity, string generatorName) { ColumnEntity c = new ColumnEntity(columnName, columnDatatype, isIdentity, ordinalPosition, isForeignKey, constraintDefinition, foreignKeyEntity); var gens = Generators.GeneratorFactory.GetGeneratorsForColumn(c); c.PossibleGenerators = gens; c.Generator = gens.Where(g => g.GeneratorName == generatorName).First(); return(c); }
protected override object InternalGenerateValue(long n) { ColumnEntity col = GeneratorParameters.ValueFromOtherColumn.Value; if (col != null) { return(col.ColumnIdentity); } throw new ArgumentNullException("Value From Column"); }