public VoucherPrintCore(Template template, TemplatePrintModelVoucher templatePrintModel) { try { this.template = template; this.voucherModel = templatePrintModel; printDialog1 = new System.Windows.Forms.PrintDialog(); printDocument1 = new System.Drawing.Printing.PrintDocument(); printDocument1.PrinterSettings.PrinterName = template.PrintSetting.PrintModule; printDocument1.DefaultPageSettings.PaperSize = new PaperSize("comaond", (int)(template.Background.ImageWidth / 2.54), (int)(template.Background.ImageHeight / 2.54)); x = GetX(printDocument1.DefaultPageSettings.HardMarginX); y = GetY(printDocument1.DefaultPageSettings.HardMarginY); printDocument1.DefaultPageSettings.Margins.Left = 0; printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage); if (templatePrintModel.SerialNumber != "") { startNum = templatePrintModel.SerialNumber.Substring(0, 16); endNum = templatePrintModel.SerialNumber.Substring(17); PageNum = Convert.ToInt32(endNum.Substring(10)) - Convert.ToInt32(startNum.Substring(10)) + 1; } //printDialog1.AllowSomePages = true; printDocument1.PrinterSettings.Collate = true; } catch (Exception ex) { throw ex; } }
TemplatePrintModelVoucher CreateDemoTemplatePrintModelVoucher() { TemplatePrintModelVoucher voucher = new TemplatePrintModelVoucher(); voucher.Desciption = ""; voucher.ExpireDate = DateTime.Now.ToShortDateString(); voucher.ReleaseDate = DateTime.Now.ToShortDateString(); voucher.VoucherName = "票券名称"; voucher.VoucherPrice = "60.00"; voucher.VoucherSubType = "券类"; voucher.VoucherType = "类型"; voucher.VoucheTheaterName = ""; voucher.SerialNumber = "2011121401000001-2011121401000003"; return(voucher); }