using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing; namespace Zsh.print
{
public partial class frmBadHzd : Form
{
public frmBadHzd()
{
InitializeComponent();
} private void frmBadHzd_Paint(object sender, PaintEventArgs e)
{
Font font;
string str;
float xPos; //x点坐标
 float yPos; //y点的坐标
  float topMargin = ;
float leftMargin = ; font = new Font("宋体", );
str = "欢迎光临";
xPos = leftMargin + ;
yPos = topMargin;
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "客 户 回 执 单";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 凭单号";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "业务类型";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 卡号";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 原余额";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 现余额";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "客户签名";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) - ;
font = new Font("宋体", );
str = "-----------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics);
font = new Font("宋体", );
str = "受理单位名称";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 操作员名称";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "   日期";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("华文行楷", );
str = "此凭单为购物凭证,请妥善保管!";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat());
} private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
Font font;
string str;
float xPos; //x点坐标
 float yPos; //y点的坐标
 float topMargin = ;
float leftMargin = ; font = new Font("宋体", );
str = "欢迎光临";
xPos = leftMargin + ;
yPos = topMargin;
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "客 户 回 执 单";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 凭单号";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "业务类型";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 卡号";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 原余额";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 现余额";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "客户签名";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) - ;
font = new Font("宋体", );
str = "-----------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics);
font = new Font("宋体", );
str = "受理单位名称";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 操作员名称";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "   日期";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("华文行楷", );
str = "此凭单为购物凭证,请妥善保管!";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat());
} /// <summary>
/// 打印票据信息
/// </summary>
/// <param name="?">打印机名称</param>
/// <param name="sho_printNum">打印数量</param>
public void print(string str_Printer, short sho_printNum)
{
try
{
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = str_Printer;
pd.PrinterSettings.Copies = sho_printNum;
pd.PrintController = new StandardPrintController();
pd.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
if (pd.PrinterSettings.IsValid)
{
pd.Print();
}
else
{
MessageBox.Show("打印机连接错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
}
}

源码源于 ==》 http://bbs.csdn.net/topics/310215237

最新文章

  1. Linux进程管理子系统分析【转】
  2. easyUI-combobox 动态绑定数据源
  3. git 本地仓库和远程仓库及本地分支和远程分支
  4. 用C语言计算圆的面积~!!!!!!!
  5. Complete The Pattern #1
  6. C++ Vector
  7. MUH and Cube Walls
  8. jmeter中webdriver插件,进行自动化压测
  9. 在python中编写socket服务端模块(二):使用poll或epoll
  10. SQLSERVER如何导入数据保持ID不变(ID为自增主键)
  11. 【翻译】使用Sencha Ext JS 6打造通用应用程序
  12. 【坑】linux目录软连接的相关操作--很容易误操作
  13. CSS集锦
  14. [openjudge-贪心]删数问题
  15. 《CSS揭秘》之毛玻璃效果知识点
  16. box-sizing:border-box的作用
  17. 部署---阿里云服务器,linux, ubuntu ,部署django用到的一些命令
  18. css-通过hover实现鼠标进过背景色变化
  19. [leetcode]Remove Duplicates from Sorted List @ Python
  20. Checkbox: ListView 与CheckBox 触发事件冲突的问题

热门文章

  1. h5 html5 模拟时钟 页面
  2. h2数据库的简单使用
  3. 之前为dd写的一个小的demo(robotium)
  4. c++ 网络编程(十一) LINUX下 初步制作基于HTTP的WEB服务器
  5. 闲话handle和handler
  6. OSI及TCP/IP的概念和区别
  7. JAVA练手--链表
  8. 数据适配:DataAdapter对象概述
  9. [Telegram X]旧版分享 突破被锁群组
  10. python(九):迭代器与生成器