//转换列表 public void TransSave() { TargetObject.Clear(); foreach (GeneralObject item in (IList)SourceObject) { //模板对象 if (TargetObject.templetObject == null) { throw new Exception("模板对象不能为空!"); } if (TargetObject.TempObj == null) { throw new Exception("临时对象不能为空!"); } //将临时对象值赋值为要转换对象 TargetObject.TempObj.CopyFrom(item); //产生新对象 GeneralObject go = new GeneralObject(); go.WebClientInfo = TargetObject.templetObject.WebClientInfo; go.CopyDataFrom(TargetObject.templetObject); TargetObject.Add(go); } //保存 TargetObject.Save(); }
//打印 public void PrintD() { PageIndex = -1; Count = (List.Count % PageRow == 0) ? (List.Count / PageRow) : (List.Count / PageRow) + 1; if (Count == 0) { return; } int c = list.Count; PrintDocument pd = new PrintDocument(); pd.PrintPage += (o, e) => { PrintDocument pd1 = (PrintDocument)o; if (pd1.PrintedPageCount - 1 != PageIndex) { return; } if (List is PagedObjectList) { PageIndex++; PagedObjectList pol = (PagedObjectList)List; pol.DataLoaded += (o1, e1) => { //加载展示数据 go.CopyDataFrom(List[0]); e.PageVisual = DataArea; DataArea.UpdateLayout(); //打印完成,重置索引 if (PageIndex == Count - 1) { e.HasMorePages = false; } else { e.HasMorePages = true; } }; pol.PageIndex = PageIndex; } }; pd.Print(""); }