后台代码

   panPrintContent.Visible = true;
var strlPrinterMode = ""; this.pageSetupDialog1.PageSettings.Margins.Left = ;
this.pageSetupDialog1.PageSettings.Margins.Top = ;
this.pageSetupDialog1.PageSettings.Margins.Right = ;
this.pageSetupDialog1.PageSettings.Margins.Bottom = ;
panPrintContent.Visible = true; //打印设置
try
{
string sqls = "select PrinterMode from User_Org where UserID='" + DBCommonServer.strUserName + "' and OID='" + DBCommonServer.strOrgId + "' ";
DataTable dt1 = helps.GetDataTable(sqls);
if (dt == null)
{
return;
}
if (dt1.Rows.Count > )
{
strlPrinterMode = dt1.Rows[][].ToString();
}
if (strlPrinterMode == "")
{
this.printPreviewDialog1.ShowDialog();
}
else
{
for (int i = ; i < Convert.ToInt32(strlPrinterMode); i++)
{ this.printDocument1.Print();
}
}
}
catch (Exception)
{
MessageBox.Show("您好!您的电脑有可能打印服务没有启动或是没有安装打印机。"
+ Environment.NewLine + Environment.NewLine + "请先启动打印服务或是安装打印机!");
}
  /// <summary>
/// 打印内容
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void printDocument1_PrintPage_1(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
////打印内容 为 局部的 this.groupBox1
Bitmap _NewBitmap = new Bitmap(this.panPrintContent.Width, this.panPrintContent.Height);
this.panPrintContent.DrawToBitmap(_NewBitmap, new Rectangle(, , _NewBitmap.Width, _NewBitmap.Height));
e.Graphics.DrawImage(_NewBitmap, , , _NewBitmap.Width, _NewBitmap.Height);
}

动态获得控件

   int iheight = iLabHeight * i;
Label LlabPrintPayType = new Label();
LlabPrintPayType.Name = "LlabPrintPayType" + i;
// LlabPrintPayType.Location = new Point(ilabPrintPayType_X, ilabPrintPayType_Y + iheight);
LlabPrintPayType.Location = new Point(,i*+);
LlabPrintPayType.Text = dtlistPay.Rows[i]["付款方式名称"].ToString() + (dtlistPay.Rows[i]["卡号"].ToString() == "" ? "" : "(" + dtlistPay.Rows[i]["卡号"].ToString() + ")");
LlabPrintPayType.Height = ;
panFkfs.Controls.Add(LlabPrintPayType);
Label LlabPrintCost = new Label();
LlabPrintCost.Name = "LlabPrintCost" + i;
LlabPrintCost.Location = new Point(, i * + );
string strPrintCost = decimal.Round(Convert.ToDecimal(dtlistPay.Rows[i]["金额"].ToString()), , MidpointRounding.AwayFromZero).ToString();

前台代码

winform 打印小票的更多相关文章

  1. C# 收银机顾显(客显)及打印小票(58热敏打印机)

    最近做winform收银机,设计顾显及打印小票总结. 1.顾显(串口COM1) 只涉及到总计,所以只是简单的功能. public static ClientDisplayResult Display( ...

  2. 【转】C#使用ESC指令控制POS打印机打印小票

    .前言 C#打印小票可以与普通打印机一样,调用PrintDocument实现.也可以发送标注你的ESC指令实现.由于 调用PrintDocument类时,无法操作使用串口或TCP/IP接口连接的pos ...

  3. C#使用ESC指令控制POS打印机打印小票

    1.前言 C#打印小票可以与普通打印机一样,调用PrintDocument实现.也可以发送标注你的ESC指令实现.由于 调用PrintDocument类时,无法操作使用串口或TCP/IP接口连接的po ...

  4. WinForm打印

    WinForm打印要用打印控件: PageSetupDialog:打印设置对话框 PrintDialog:打印对话框 PrintDocument:要打印的对象,非常重要 PrintPreviewCon ...

  5. ActiveXObject Word.Application 打印小票

    javascript 时间格式 Date.prototype.format = function (format) { var o = { "M+": this.getMonth( ...

  6. C# 打印小票 POS

    C# 打印小票 POS 最近在写一个餐饮的收银系统,以前从来没有碰过打印机这玩意.感觉有些无从下手,在前面做报表时,总想找第三方的控件来用用,结果始终不行没搞定.没研究透,催得急没办法还是的动手自己写 ...

  7. c# winform打印excel(使用NPOI+Spire.xls+PrintDocument直接打印excel)

    前言 c#做winform程序要求生成并打印Excel报告,为了不安装Office相应组件,我选择了NPOI来生成Excel报告,用winform的PrintDocument控件来触发打印操作,而难点 ...

  8. 按照已有的模板打印小票<二> ——调用windows打印机打印 可设置字体样式

    按照已有的模板打印小票<二> ——调用windows打印机打印 可设置字体样式 之前写过一篇文章<按照已有的模板输出一(如发票)>,是关于如何给已有的模板赋值.在项目的实践过程 ...

  9. C# 网络打印机ESC指令打印小票

    public void SendSocketMsg(String ip, int port, int times, byte[] data) { try { byte[] mData; ) { mDa ...

随机推荐

  1. Android开发环境搭建时遇到问题的解决方法

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/linux_loajie/article/details/33823637 Android开发环境搭建 ...

  2. Mac开发必备工具(三)—— Fish shell

    Fish shell 简介 fish 可以根据输入自动匹配历史命令.它的一大特点是开箱即用,没有zsh那些繁琐的配置.官网:http://www.fishshell.com/. 安装与配置 在终端里使 ...

  3. spring cloud 启动报错-must be declared as an @AliasFor [serviceId], not [name].

    项目加入FeignClient后再启动就报错,具体报错信息如下: org.springframework.core.annotation.AnnotationConfigurationExceptio ...

  4. confluence的使用

    搜索文档的技巧 在confluence中进行搜索的时候,也需要使用通配符.比如搜索cmscontext,需要这么搜索cmscontex*,如果搜索的话,cmscontext.geturl是会被过滤掉的 ...

  5. javascript flash 弹框

    1. [代码]FlashBox     // JavaScript Documentfunction FlashBox(src,width,height){var docbody = document ...

  6. hdu 1075 What Are You Talking About(map)

    题意:单词翻译 思路:map #include<iostream> #include<stdio.h> #include<string.h> #include< ...

  7. CodeForces-816B:Karen and Coffee (简单线段树)

    To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...

  8. PostgreSQL 图形化客户端工具有哪些

    linux下有字符界面的:psql         图形界面的:pgaccesswindows系统可以用:phpPgAdmin或者telnet+psql 和phpmyadmin 一家的phpPgAdm ...

  9. linux下Postgresql-9.2安装及数据库的创建过程

    公司写部署手册需要,现总结一些linux下postgresql的安装及数据库创建的详细步骤吧! 1.1.1  软件安装   1.设置用户组和用户级别 Postgresql不能以root身份运行,要以其 ...

  10. spring+mybatis 多数据源整合--temp

    <!-- 数据源配置 -->   <bean id="ds1" class="org.apache.commons.dbcp.BasicDataSour ...