/// <summary> /// 修改某个映射集,按照ID进行修改,如果不存在则增加 /// </summary> /// <param name="map">要修改的映射集</param> public void Update(MapElementCollection map) { if (map == null) { return; } if (Maps == null) { Maps = new List <MapElementCollection>(); } var ms = Maps; if (IsExistName(map.ID, map.Name)) { Error(string.Format("名称已经存在,名称不能重复:" + map.Name)); return; } if (map.ID == -1) { map.ID = GeneratorNewID(); ms.Add(map); } else { int index = ms.FindIndex(m => { return(m.ID == map.ID); }); if (index >= 0) { ms[index] = map; Maps = ms; } } }
private void button1_Click(object sender, EventArgs e) { var th = new System.Threading.Thread(new System.Threading.ThreadStart(() => { int tables = (int)numTables.Value; int cols = (int)numCols.Value; AddInfo("开始构造"); var mapGroup = new MappingGroup(); mapGroup.Name = "名称"; mapGroup.ErrorHappened += new Action<string>(mapGroup_ErrorHappened); for (int i = 0; i < tables; i++) { MapElementCollection mec = new MapElementCollection(); mec.Name = "table" + i % (tables + 1); MappingElement ele1 = new MappingElement( new ColumnElement("dept_name"), new ColumnElement("单位名称")); mec.Add(ele1); MappingElement ele = new MappingElement( new ColumnElement("dept_id"), new ColumnElement("单位ID")); mec.Add(ele); mapGroup.Add(mec); } AddInfo("构造完成"); yltl.Common.ConfigHelper<MappingGroup>.Reflesh(mapGroup); AddInfo("保存完成"); })); th.Start(); }
/// <summary> /// 按名称移除一个映射集合 /// </summary> /// <param name="map"></param> public int Remove(MapElementCollection map) { if (map == null) { return(0); } return(Remove(map.ID)); }
public void Export(MapElementCollection mapping, System.Data.DataTable dt) { if (mapping == null) return; var colMapping = mapping.GetColumnMapping(); if (colMapping == null || colMapping.Count == 0) return; yltl.ExcelHelper.WinFormExcelExporter.DataTableToExcel(dt, colMapping); }
public void Export(MapElementCollection mapping, System.Data.DataTable dt) { if (mapping == null) { return; } var colMapping = mapping.GetColumnMapping(); if (colMapping == null || colMapping.Count == 0) { return; } yltl.ExcelHelper.WinFormExcelExporter.DataTableToExcel(dt, colMapping); }
private void button1_Click(object sender, EventArgs e) { var th = new System.Threading.Thread(new System.Threading.ThreadStart(() => { int tables = (int)numTables.Value; int cols = (int)numCols.Value; AddInfo("开始构造"); var mapGroup = new MappingGroup(); mapGroup.Name = "名称"; mapGroup.ErrorHappened += new Action <string>(mapGroup_ErrorHappened); for (int i = 0; i < tables; i++) { MapElementCollection mec = new MapElementCollection(); mec.Name = "table" + i % (tables + 1); MappingElement ele1 = new MappingElement( new ColumnElement("dept_name"), new ColumnElement("单位名称")); mec.Add(ele1); MappingElement ele = new MappingElement( new ColumnElement("dept_id"), new ColumnElement("单位ID")); mec.Add(ele); mapGroup.Add(mec); } AddInfo("构造完成"); yltl.Common.ConfigHelper <MappingGroup> .Reflesh(mapGroup); AddInfo("保存完成"); })); th.Start(); }
/// <summary> /// 修改某个映射集,按照ID进行修改,如果不存在则增加 /// </summary> /// <param name="map">要修改的映射集</param> public void Update(MapElementCollection map) { if (map == null) return; if (Maps == null) Maps = new List<MapElementCollection>(); var ms = Maps; if (IsExistName(map.ID, map.Name)) { Error(string.Format("名称已经存在,名称不能重复:" + map.Name)); return; } if (map.ID == -1) { map.ID = GeneratorNewID(); ms.Add(map); } else { int index = ms.FindIndex(m => { return m.ID == map.ID; }); if (index >= 0) { ms[index] = map; Maps = ms; } } }
/// <summary> /// 按名称移除一个映射集合 /// </summary> /// <param name="map"></param> public int Remove(MapElementCollection map) { if (map == null) return 0; return Remove(map.ID); }
/// <summary> /// 增加某个映射集,按照ID进行判断,如果存在,则更像 /// </summary> /// <param name="map"></param> public void Add(MapElementCollection map) { Update(map); }