发票打印,在线等待

cxyPioneer 2004-09-21 11:42:37
在水晶报表怎样打印发票(自定义),用针式打印机,并且能够连续打印
...全文
207 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
myflyer 2004-09-21
  • 打赏
  • 举报
回复
我做过的酒店结帐单的打印看看对你有没?

private void PrintPageTop(object sender,System.Drawing.Printing.PrintPageEventArgs e,float fltXPos,ref float fltYPos)
{
string strMain=null;
if(this.Consume)
strMain = "中银酒店客户消费单";
else
strMain = "中银酒店客户结帐单";
e.Graphics.DrawString(strMain,new Font("华文行楷",18F,FontStyle.Bold),Brushes.Black,100,fltYPos);
e.Graphics.DrawString("客户:" + this.strName,new Font("宋体",10F,FontStyle.Bold),Brushes.Black,fltXPos,fltYPos += new Font("华文行楷",18F,FontStyle.Bold).Height);
e.Graphics.DrawString(this.strUnit,new Font("宋体",8F,FontStyle.Italic),Brushes.Black,fltXPos + 312,fltYPos += new Font("宋体",10F,FontStyle.Bold).Height);
fltYPos += new Font("宋体",8F,FontStyle.Italic).Height;
e.Graphics.DrawString("商品名",new Font("宋体",9F,FontStyle.Bold),Brushes.Black,fltXPos,fltYPos);
e.Graphics.DrawString("数量",new Font("宋体",9F,FontStyle.Bold),Brushes.Black,fltXPos + 138,fltYPos);
e.Graphics.DrawString("商品名",new Font("宋体",9F,FontStyle.Bold),Brushes.Black,fltXPos + 203,fltYPos);
e.Graphics.DrawString("数量",new Font("宋体",9F,FontStyle.Bold),Brushes.Black,fltXPos + 340,fltYPos);

}
private void PrintPageList(object sender,System.Drawing.Printing.PrintPageEventArgs e,float fltXPos,ref float fltYPos)
{
float fltLineTop = fltYPos;
string strName=null;
Font fontList = new Font("宋体",8.5F);
double dPrice,dSumMoney,dSum;
decimal decCSum=0;
//菜
dv.RowFilter = "类别 not in('酒','扑克','干巾','湿巾','烟')";
for(int i=0;i<dv.Count;i++)
{
decCSum += Convert.ToDecimal(dv[i]["金额"]);
dSum = Convert.ToDouble(dv[i]["数量"]);
fltYPos += fontList.GetHeight(e.Graphics);
if(dv[i]["名称"].ToString().Length<8)
strName = dv[i]["名称"].ToString();
else
strName = dv[i]["名称"].ToString().Substring(0,7) + "..";

e.Graphics.DrawString((i+1).ToString() + strName ,fontList,Brushes.Black,fltXPos,fltYPos);
e.Graphics.DrawString(dSum.ToString("0.0"),fontList,Brushes.Black,fltXPos + 138,fltYPos);
i++;
if(i<dv.Count)
{
decCSum += Convert.ToDecimal(dv[i]["金额"]);
dSum = Convert.ToDouble(dv[i]["数量"]);
if(dv[i]["名称"].ToString().Length<8)
strName = dv[i]["名称"].ToString();
else
strName = dv[i]["名称"].ToString().Substring(0,7) + "..";
e.Graphics.DrawString((i+1).ToString() + strName,fontList,Brushes.Black,fltXPos + 203,fltYPos);
e.Graphics.DrawString(dSum.ToString("0.0"),fontList,Brushes.Black,fltXPos + 340,fltYPos);
}
}
fltYPos += fontList.GetHeight(e.Graphics);
e.Graphics.DrawString("菜单合计:" ,fontList,Brushes.Black,fltXPos,fltYPos);
e.Graphics.DrawString(decCSum.ToString("0.0"),fontList,Brushes.Black,fltXPos + 360,fltYPos);

Pen blackPen = new Pen(Color.Black,1);
blackPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;

fltYPos += fontList.GetHeight(e.Graphics);
e.Graphics.DrawLine(blackPen,230,fltLineTop,230,fltYPos);

//酒水
decimal decJXSum=0;
dv.RowFilter = "类别 in('酒','扑克','干巾','湿巾','烟')";
if(dv.Count>0)
{
e.Graphics.DrawString("商品名",new Font("宋体",9F,FontStyle.Bold),Brushes.Black,fltXPos,fltYPos);
e.Graphics.DrawString("售价",new Font("宋体",9F,FontStyle.Bold),Brushes.Black,fltXPos + 240,fltYPos);
e.Graphics.DrawString("数量",new Font("宋体",9F,FontStyle.Bold),Brushes.Black,fltXPos + 300,fltYPos);
e.Graphics.DrawString("金额" ,new Font("宋体",9F,FontStyle.Bold),Brushes.Black,fltXPos + 360,fltYPos);

for(int i=0;i<dv.Count;i++)
{
decJXSum += Convert.ToDecimal(dv[i]["金额"]);
dPrice = Convert.ToDouble(dv[i]["售价"]);
dSumMoney = Convert.ToDouble(dv[i]["金额"]);
dSum = Convert.ToDouble(dv[i]["数量"]);
fltYPos += fontList.GetHeight(e.Graphics);
e.Graphics.DrawString((i+1).ToString() + dv[i]["名称"].ToString(),fontList,Brushes.Black,fltXPos,fltYPos);
e.Graphics.DrawString(dPrice.ToString("##0'.';(##0'.');0'.'"),fontList,Brushes.Black,fltXPos + 240,fltYPos);
e.Graphics.DrawString(dSum.ToString("0.0"),fontList,Brushes.Black,fltXPos + 300,fltYPos);
e.Graphics.DrawString(dSumMoney.ToString("##0'.';(##0'.');0'.'"),fontList,Brushes.Black,fltXPos + 360,fltYPos);
}
fltYPos += fontList.GetHeight(e.Graphics);
e.Graphics.DrawString("酒水合计:",fontList,Brushes.Black,fltXPos,fltYPos);
e.Graphics.DrawString(decJXSum.ToString("0.0"),fontList,Brushes.Black,fltXPos + 360,fltYPos);
}

}
private void PrintPageButton(object sender,System.Drawing.Printing.PrintPageEventArgs e,float fltXPos,float fltYPos)
{
Font fontButton = new Font("宋体",9F);
fltYPos +=20;
e.Graphics.DrawString("合计消费:" + Convert.ToDouble(this.strSumPrice).ToString("¥#,##0.0;(¥#,##0.0);"),fontButton,Brushes.Black,fltXPos,fltYPos);
if(!this.Consume)
{
e.Graphics.DrawString("已收:" + Convert.ToDouble(this.strTruePrice).ToString("¥#,##0.0;(¥#,##0.0);"),fontButton,Brushes.Black,fltXPos + 160,fltYPos);
e.Graphics.DrawString("欠款:" + Convert.ToDouble(this.strOwe).ToString("¥#,##0.0;(¥#,##0.0);"),fontButton,Brushes.Black,fltXPos + 300,fltYPos);
fltYPos += 10 + fontButton.GetHeight(e.Graphics);
e.Graphics.DrawString("客户确认:",fontButton,Brushes.Black,fltXPos,fltYPos);
Pen blackPen = new Pen(Color.Black,1);
e.Graphics.DrawLine(blackPen, fltXPos + 66,fltYPos + fontButton.GetHeight(e.Graphics)-3,210,fltYPos + fontButton.GetHeight(e.Graphics)-3);
}
fltYPos += 10 + fontButton.GetHeight(e.Graphics);
e.Graphics.DrawString("打单日期时间:" + DateTime.Now.ToString(),fontButton,Brushes.Black,fltXPos,fltYPos);
e.Graphics.DrawString("- - - - - - - - 谢谢您的惠顾,欢迎下次光临 - - - - - - - -",new Font("宋体",10F),Brushes.Black,fltXPos,fltYPos + 20);

}
private void pd_PrintPage(object sender,System.Drawing.Printing.PrintPageEventArgs e)
{
float fltXPos,fltYPos;
fltYPos = e.MarginBounds.Top;
fltXPos = e.MarginBounds.Left;
this.PrintPageTop(sender,e,fltXPos,ref fltYPos);
this.PrintPageList(sender,e,fltXPos,ref fltYPos);
if(fltYPos<340)
this.PrintPageButton(sender,e,fltXPos,340);
else
this.PrintPageButton(sender,e,fltXPos,fltYPos);

}
myflyer 2004-09-21
  • 打赏
  • 举报
回复
如果是票据打印还是用printDocument类打印吧,这样比较灵活
cxyPioneer 2004-09-21
  • 打赏
  • 举报
回复
怎样设置水晶的尺寸,自定义

110,556

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧