请教各位老师 C#如何打印小票呢? 现在正在做一个程序,需要连接小票打印机,而且是RJ45接口的。 请教一下各位 有这方面的例子吗?小弟想学习一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 百度 google 是最后的老师! 你买打印机的时候他们没有提供API吗??? 买打印机的时候有API借口的例子 水晶报表打印小票啊。//upd by hu 20100608 交易小票打印 PrintDocument prtdoc = new PrintDocument(); string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;//获取默认的打印机名 if (strDefaultPrinter.ToUpper() == "POS58") //判断是否为默认打印机 { DataTable print_dt = new DataTable(); string salecd = cs.salecd; rtn = cs.GetdataDetail(1); if (rtn == ComConst.FAILED) { if (cs.errMode) { lblMsg.Text = cs.strErr; } else { ComLibrary.getMsg(cs.strErr, "E", "错误"); } lblMsg.ForeColor = Color.Red; return; } #region 添加列 print_dt.Columns.Add("SALECD", typeof(string)); print_dt.Columns.Add("CRID", typeof(string)); print_dt.Columns.Add("SALEDATE", typeof(decimal)); print_dt.Columns.Add("ITEMCD", typeof(string)); print_dt.Columns.Add("ITEMNAME", typeof(string)); print_dt.Columns.Add("TYPECD", typeof(string)); print_dt.Columns.Add("TYPENAME", typeof(string)); print_dt.Columns.Add("PRICE", typeof(decimal)); print_dt.Columns.Add("QTY", typeof(decimal)); //print_dt.Columns.Add("UNITCD", typeof(string)); //print_dt.Columns.Add("DISCOUNT", typeof(decimal)); print_dt.Columns.Add("SUMAMT", typeof(decimal)); print_dt.Columns.Add("ITEMTY", typeof(string)); //print_dt.Columns.Add("ADJUSTAMT", typeof(decimal)); //print_dt.Columns.Add("ACTAMT", typeof(decimal)); //print_dt.Columns.Add("CHANGE", typeof(decimal)); print_dt.Columns.Add("COMPANY", typeof(string)); print_dt.Columns.Add("ADDRESS", typeof(string)); print_dt.Columns.Add("TEL", typeof(string)); print_dt.Columns.Add("NOTE", typeof(string)); #endregion for (int i = 0; i < dgvITList.RowCount - 1; i++) { print_dt.Rows.Add(salecd, ComLibrary.ToString(this.Tag), ComLibrary.ToInt(dtpSalesDate.txtDate.Text),//upd by hu 20100701 dgvITList.Rows[i].Cells[COLITEMCD].Value, dgvITList.Rows[i].Cells[COLITEMNM].Value, dgvITList.Rows[i].Cells[COLTYPECD].FormattedValue, dgvITList.Rows[i].Cells[COLTYPENM].Value, ComLibrary.ToDecimal(dgvITList.Rows[i].Cells[COLSELLPRICE].Value), ComLibrary.ToInt(dgvITList.Rows[i].Cells[COLAMOUNT].Value), ComLibrary.ToDecimal(dgvITList.Rows[i].Cells[COLMONEY].Value), dgvITList.Rows[i].Cells[COLITEMTYPE].Value, cs.company, cs.address, cs.tel, cs.note); } try { //打印 this.Cursor = Cursors.WaitCursor; CsReport.CS012CLS report = new LMS.CsReport.CS012CLS(); report.Viewer = false; report.ZoomLevel = 100; report.FormWindowState = FormWindowState.Maximized; report.SetDataSource(print_dt); report.Publish(); } catch (Exception ew) { ComLibrary.getMsg(ew.Message, "E", "错误"); } finally { this.Cursor = Cursors.Default; } } /********************************************************************/ ComLibrary.ClearControl(pnlDetail); ComLibrary.ClearControl(pnlKey); comScomb.Rows.Clear(); dtpSalesDate.txtDate.Text = DateTime.Now.ToString("yyyyMMdd");//upd by hu 20100701 rdoNVip.Focus(); } 你可以做个EXCEL模版,(做成你小票需要的格式).然后再将数据写入到EXCEL模版中,再打印.这些和是什么口的打印机没关系. 打印机厂家会提供JDK开发接口或者dll接口,要说明文档或者demo程序。 安装驱动;有程式设计时用System.Drawing.Printing 最简单 请教:在WinFrom中如何为百度贴吧内容框赋值 关于异步通信服务端问题 求一个进度条!假的真的都可以,只要实现就行。 我的TFS服务器: TFS、VS 2005、SQL Server 2005 谁来帮我做毕业设计 急!!!怎样远程监视数据库? 怎样写以下两个事件代码? 如何运c#代码 我是一名新手刚刚接触C#号,请各位高手帮忙! 怎样删除系统剪切板中的内容? C# directshow播放视频问题 DataTable 临时表
//upd by hu 20100608 交易小票打印
PrintDocument prtdoc = new PrintDocument();
string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;//获取默认的打印机名 if (strDefaultPrinter.ToUpper() == "POS58") //判断是否为默认打印机
{
DataTable print_dt = new DataTable();
string salecd = cs.salecd; rtn = cs.GetdataDetail(1);
if (rtn == ComConst.FAILED)
{
if (cs.errMode)
{
lblMsg.Text = cs.strErr;
}
else
{
ComLibrary.getMsg(cs.strErr, "E", "错误");
}
lblMsg.ForeColor = Color.Red;
return;
} #region 添加列 print_dt.Columns.Add("SALECD", typeof(string));
print_dt.Columns.Add("CRID", typeof(string));
print_dt.Columns.Add("SALEDATE", typeof(decimal));
print_dt.Columns.Add("ITEMCD", typeof(string));
print_dt.Columns.Add("ITEMNAME", typeof(string));
print_dt.Columns.Add("TYPECD", typeof(string));
print_dt.Columns.Add("TYPENAME", typeof(string));
print_dt.Columns.Add("PRICE", typeof(decimal));
print_dt.Columns.Add("QTY", typeof(decimal));
//print_dt.Columns.Add("UNITCD", typeof(string));
//print_dt.Columns.Add("DISCOUNT", typeof(decimal));
print_dt.Columns.Add("SUMAMT", typeof(decimal));
print_dt.Columns.Add("ITEMTY", typeof(string));
//print_dt.Columns.Add("ADJUSTAMT", typeof(decimal));
//print_dt.Columns.Add("ACTAMT", typeof(decimal));
//print_dt.Columns.Add("CHANGE", typeof(decimal));
print_dt.Columns.Add("COMPANY", typeof(string));
print_dt.Columns.Add("ADDRESS", typeof(string));
print_dt.Columns.Add("TEL", typeof(string));
print_dt.Columns.Add("NOTE", typeof(string));
#endregion
for (int i = 0; i < dgvITList.RowCount - 1; i++)
{
print_dt.Rows.Add(salecd, ComLibrary.ToString(this.Tag), ComLibrary.ToInt(dtpSalesDate.txtDate.Text),//upd by hu 20100701
dgvITList.Rows[i].Cells[COLITEMCD].Value, dgvITList.Rows[i].Cells[COLITEMNM].Value,
dgvITList.Rows[i].Cells[COLTYPECD].FormattedValue, dgvITList.Rows[i].Cells[COLTYPENM].Value,
ComLibrary.ToDecimal(dgvITList.Rows[i].Cells[COLSELLPRICE].Value), ComLibrary.ToInt(dgvITList.Rows[i].Cells[COLAMOUNT].Value),
ComLibrary.ToDecimal(dgvITList.Rows[i].Cells[COLMONEY].Value),
dgvITList.Rows[i].Cells[COLITEMTYPE].Value, cs.company, cs.address, cs.tel, cs.note);
} try
{
//打印
this.Cursor = Cursors.WaitCursor;
CsReport.CS012CLS report = new LMS.CsReport.CS012CLS();
report.Viewer = false;
report.ZoomLevel = 100;
report.FormWindowState = FormWindowState.Maximized;
report.SetDataSource(print_dt);
report.Publish();
}
catch (Exception ew)
{
ComLibrary.getMsg(ew.Message, "E", "错误");
}
finally
{
this.Cursor = Cursors.Default;
}
}
/********************************************************************/
ComLibrary.ClearControl(pnlDetail);
ComLibrary.ClearControl(pnlKey);
comScomb.Rows.Clear();
dtpSalesDate.txtDate.Text = DateTime.Now.ToString("yyyyMMdd");//upd by hu 20100701
rdoNVip.Focus();
}