private void printDocument2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { List <ZupiData> printData = new List <ZupiData>(); foreach (var mix in hjmixs) { List <string> vehnos = new List <string>(); DbEntityTable <QC_Sample_Veh> vehs = new DbEntityTable <QC_Sample_Veh>(); vehs.LoadDataByWhere("main.Sample_Mix_ID=@Sample_Mix_ID", mix.Sample_Mix_ID); foreach (var item in vehs) { vehnos.Add(QC_Sample_Mix.ShortStoreCode(item.CardID)); } if (vehnos.Count > 0) { ZupiData zd = new ZupiData(); zd.Head = QC_Sample_Mix.ShortStoreCode(mix.CardID); zd.ZupiItems = vehnos; printData.Add(zd); ZupiData pbzd = new ZupiData(); pbzd.Head = QC_Sample_Mix.ShortStoreCode("PB" + mix.CardID.Remove(0, 2)); pbzd.ZupiItems = vehnos; printData.Add(pbzd); } } int totalPage = 1; foreach (var item in printData) { item.BeginPage = totalPage; totalPage += item.NeadPage; } int printPage = totalPage - curZupiPrintPage; foreach (var item in printData) { if (printPage >= item.BeginPage && printPage < item.EndPage) { item.Print(e.Graphics, printPage); break; } } if (curZupiPrintPage < totalPage - 1) { curZupiPrintPage++; e.HasMorePages = true; } else { curZupiPrintPage = 1; e.HasMorePages = false; } }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { List <ZupiData> printData = new List <ZupiData>(); foreach (var mix in printbill) { List <string> vehnos = new List <string>(); DbEntityTable <QC_Sample_Veh> vehs = new DbEntityTable <QC_Sample_Veh>(); vehs.LoadDataByWhere("main.Sample_Mix_ID=@Sample_Mix_ID order by begintime", mix.Sample_Mix_ID); //vehnos.Add(mix.SupplierName); vehnos.Add(mix.MatName); //if (mix.SampleType == SampleType.人工取样) //{ // vehnos.Add("人取"+"共" + vehs.Count+"车"); //} //else if (mix.SampleType == SampleType.机器取样) //{ // vehnos.Add("机取" + "共" + vehs.Count + "车"); //} //else if (mix.SampleType == SampleType.抽查样) //{ // vehnos.Add("抽查" + "共" + vehs.Count + "车"); //} if (vehs.Count > 0) { if (mix.SampleType == SampleType.人工取样) { vehnos.Add("人取" + "共" + vehs.Count + "车"); } else if (mix.SampleType == SampleType.机器取样) { vehnos.Add("机取" + "共" + vehs.Count + "车"); } else if (mix.SampleType == SampleType.抽查样) { vehnos.Add("抽查" + "共" + vehs.Count + "车"); } } else { if (mix.SampleType == SampleType.人工取样) { vehnos.Add("人取"); } else if (mix.SampleType == SampleType.机器取样) { vehnos.Add("机取"); } else if (mix.SampleType == SampleType.抽查样) { vehnos.Add("抽查"); } } if (vehs.Count > 0) { vehnos.Add(vehs[0].VehNo + "->" + vehs[vehs.Count - 1].VehNo); } //if (vehs.Count >0) //{ // vehnos.Add("共" + vehs.Count+"车"); //} //foreach (var item in vehs) //{ // vehnos.Add(item.VehNo); //} if (vehnos.Count > 0) { //ZupiData zd = new ZupiData(); //zd.Head = QC_Sample_Mix.ShortStoreCode(mix.CardID); //zd.ZupiItems = vehnos; //printData.Add(zd); ZupiData pbzd = new ZupiData(); //编号 //pbzd.Head = QC_Sample_Mix.ShortStoreCode("HY" + mix.CardID.Remove(0, 2)); pbzd.Head = QC_Sample_Mix.ShortStoreCode(mix.StoreCode); pbzd.ZupiItems = vehnos; printData.Add(pbzd); } } int totalPage = 1; foreach (var item in printData) { item.BeginPage = totalPage; totalPage += item.NeadPage; } int printPage = totalPage - curZupiPrintPage; foreach (var item in printData) { if (printPage >= item.BeginPage && printPage < item.EndPage) { item.Print(e.Graphics, printPage); break; } } if (curZupiPrintPage < totalPage - 1) { curZupiPrintPage++; e.HasMorePages = true; } else { curZupiPrintPage = 1; e.HasMorePages = false; } }