using Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using com.hnshituo.core.webapp.vo;
namespace MeterPlugInLibrary
{
public class Print
{
//MeterWorkCarActualFirstService firstService = new MeterWorkCarActualFirstService();
QRCode qr = new QRCode();
///
/// 打印纸数量递减
///
///
public void PrintNum(string strPntID)
{//update jl_pointinfo t set t.remainpaper=t.remainpaper-1 where t.pointid='CAR04'
try
{
MeterWorkMonitorService monitorService = new MeterWorkMonitorService();
RESTfulResult rm = monitorService.doUpdateWf(new MeterWorkMonitor { pointNo = strPntID, printNum = PbCache.monitor.printNum - 1 });
if (!rm.Succeed)
{
string log = "打印纸数量递减错误!" + rm.ResultMessage;
WriteLog(log);
}
}
catch (Exception exp)
{
WriteLog("打印纸数量递减写入异常!" + exp.Message);
}
}
///
/// 结净打印
///
///
///
public void PrintAllPage(System.Drawing.Printing.PrintPageEventArgs e, MeterWorkCarActual first, string strCode)
{
try
{
Image img = qr.rtImgQRCode(strCode);
int oX = 0, oY = -2; //偏移量
int[] xPos = { 0, 65, 140, 210, 280 };
int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420 };
Font headFont = new Font("Arial", 10);
Font txtFont = new Font("Arial", 9);
Font txtFont1 = new Font("Arial", 8);//注的字体
Font MemoFont = new Font("Arial", 12);
Font txtFont2 = new Font("Arial", 7);
Font txtFontWeight = new Font("Arial", 9);
Pen blackPen = new Pen(Color.Black, 2);
StringFormat drawFormat1 = new StringFormat();
drawFormat1.Alignment = StringAlignment.Center;
drawFormat1.LineAlignment = StringAlignment.Center;
StringFormat drawFormat3 = new StringFormat();//注的字体
drawFormat3.Alignment = StringAlignment.Near;
drawFormat3.LineAlignment = StringAlignment.Near;
StringFormat drawFormat5 = new StringFormat();//注的字体
drawFormat5.Alignment = StringAlignment.Center;
drawFormat5.LineAlignment = StringAlignment.Near;
StringFormat drawFormat2 = new StringFormat();
drawFormat2.Alignment = StringAlignment.Near;
drawFormat2.LineAlignment = StringAlignment.Center;
StringFormat drawFormat4 = new StringFormat();//
drawFormat4.Alignment = StringAlignment.Far;
drawFormat4.LineAlignment = StringAlignment.Far;
//*
Rectangle rec = new Rectangle(oX + xPos[0], oY + yPos[0], xPos[4] - xPos[0], yPos[1] - yPos[0]);
e.Graphics.DrawString("九钢集团股份有限公司", headFont, Brushes.Black, rec, drawFormat1);
rec = new Rectangle(oX + xPos[0], oY + yPos[1], xPos[4] - xPos[0], yPos[2] - yPos[1]);
e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
//e.Graphics.DrawString("凌字311-005", txtFont2, Brushes.Black, rec, drawFormat4);
//*/
//-----------------------------
//-----------------------正文
rec.X = xPos[0] + oX; //35
rec.Y = yPos[2] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("流水号", txtFont2, Brushes.Black, rec, drawFormat1); //35
rec.X = xPos[1] + oX;
rec.Y = yPos[2] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.actualNo, txtFont2, Brushes.Black, rec, drawFormat1); //流水号值
rec.X = xPos[0] + oX;
rec.Y = yPos[3] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("预报编号", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[3] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.predictionNo, txtFont2, Brushes.Black, rec, drawFormat1); //预报编号值
rec.X = xPos[0] + oX;
rec.Y = yPos[4] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("车号", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[4] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.carNo, txtFont2, Brushes.Black, rec, drawFormat1); //车号
rec.X = xPos[0] + oX;
rec.Y = yPos[5] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("检斤类型", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[5] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.meterTypeName, txtFont2, Brushes.Black, rec, drawFormat1); //检斤类型值
rec.X = xPos[0] + oX;
rec.Y = yPos[6] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("毛重(t)", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[6] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
//e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFont2, Brushes.Black, rec, drawFormat1); //车号
switch (first.meterTypeNo)
{
case "0":
e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
break;
case "x":
e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
break;
default:
e.Graphics.DrawString("", txtFontWeight, Brushes.Black, rec, drawFormat1);
break;
}
rec.X = xPos[0] + oX;
rec.Y = yPos[7] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("皮重(t)", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[7] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
switch (first.meterTypeNo)
{
case "0":
e.Graphics.DrawString("", txtFontWeight, Brushes.Black, rec, drawFormat1);
break;
case "x":
e.Graphics.DrawString((first.tareWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
break;
default:
e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
break;
}
rec.X = xPos[0] + oX;
rec.Y = yPos[8] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("净重(t)", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[8] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
switch (first.meterTypeNo)
{
case "x":
e.Graphics.DrawString((first.netWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
break;
default:
e.Graphics.DrawString("", txtFontWeight, Brushes.Black, rec, drawFormat1);
break;
}
#region 二维码部分
/*
rec.X = xPos[2] + oX + 2;
rec.Y = yPos[2] + oY + 2;
rec.Width = xPos[4] - xPos[2] - 4;
rec.Height = 136; //140-4
//*/
e.Graphics.DrawImage(img, xPos[2] + oX + 5, yPos[2] + oY + 5, xPos[4] - xPos[2] - 10, 128);
#endregion
rec.X = xPos[0] + oX;
rec.Y = yPos[9] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("附加重量(t)", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[9] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
if (first.addWeight == null)
{
e.Graphics.DrawString("", txtFont2, Brushes.Black, rec, drawFormat1); //附加重量
}
else if (first.meterTypeNo == "x" || first.meterTypeNo == "0") //结净或者过毛
{
e.Graphics.DrawString((first.addWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1); //附加重量
}
rec.X = xPos[0] + oX;
rec.Y = yPos[10] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("物资名称", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[10] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.matterName, txtFont2, Brushes.Black, rec, drawFormat1); //物资名称
rec.X = xPos[0] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("来源", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.forwardingUnitName, txtFont2, Brushes.Black, rec, drawFormat1); //来源值
rec.X = xPos[0] + oX;
rec.Y = yPos[12] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("去向", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[12] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.receivingUintName, txtFont2, Brushes.Black, rec, drawFormat1); //去向值
rec.X = xPos[0] + oX;
rec.Y = yPos[13] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("计量时间", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[13] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
//first.meterTypeNo == "0" ? "毛重" : "皮重";
switch (first.meterTypeNo)
{
case "0":
e.Graphics.DrawString(first.grossTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont2, Brushes.Black, rec, drawFormat1);
break;
case "x":
e.Graphics.DrawString(first.netTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont2, Brushes.Black, rec, drawFormat1);
break;
default:
e.Graphics.DrawString(first.tareTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont2, Brushes.Black, rec, drawFormat1);
break;
}
rec.X = xPos[0] + oX;
rec.Y = yPos[14] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("规格", txtFont2, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[14] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.specName, txtFont2, Brushes.Black, rec, drawFormat1);
//*/
rec.X = xPos[0] + oX;
rec.Y = yPos[15] + oY;
rec.Width = xPos[4] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("注:本小票不作为结算凭证,请注意保管!", txtFont2, Brushes.Black, rec, drawFormat3); //注意
rec.X = xPos[0] + oX;
rec.Y = yPos[16] + oY;
rec.Width = xPos[4] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("打票时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtFont2, Brushes.Black, rec, drawFormat3);//注意//Now.ToString("yyyy-MM-dd HH:mm:ss")
//打印横线
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[4] + oX, yPos[2] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[3] + oY, xPos[2] + oX, yPos[3] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[4] + oY, xPos[2] + oX, yPos[4] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[5] + oY, xPos[2] + oX, yPos[5] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[6] + oY, xPos[2] + oX, yPos[6] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[7] + oY, xPos[2] + oX, yPos[7] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[8] + oY, xPos[2] + oX, yPos[8] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[9] + oY, xPos[4] + oX, yPos[9] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[10] + oY, xPos[4] + oX, yPos[10] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[11] + oY, xPos[4] + oX, yPos[11] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[12] + oY, xPos[4] + oX, yPos[12] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[13] + oY, xPos[4] + oX, yPos[13] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[14] + oY, xPos[4] + oX, yPos[14] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[15] + oY, xPos[4] + oX, yPos[15] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[16] + oY, xPos[4] + oX, yPos[16] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[17] + oY, xPos[4] + oX, yPos[17] + oY);
//打印竖线
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[0] + oX, yPos[17] + oY);
e.Graphics.DrawLine(blackPen, xPos[1] + oX, yPos[2] + oY, xPos[1] + oX, yPos[15] + oY);
e.Graphics.DrawLine(blackPen, xPos[2] + oX, yPos[2] + oY, xPos[2] + oX, yPos[9] + oY);
e.Graphics.DrawLine(blackPen, xPos[4] + oX, yPos[2] + oY, xPos[4] + oX, yPos[17] + oY);
PrintNum(PbCache.sportInfo.baseSpotNo);
WriteLog("完成打印!" + PbCache.sportInfo.baseSpotNo);
}
catch (Exception exp)
{
WriteLog("计量打印异常!" + exp.Message);
}
}
///
/// 结净打印
///
///
///
public void PrintPage(System.Drawing.Printing.PrintPageEventArgs e, MeterWorkCarActual first, string strCode)
{
try
{
Image img = qr.rtImgQRCode(strCode);
int oX = 0, oY = -2; //偏移量
int[] xPos = { 0, 65, 125, 205, 265 };
int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 420, 440, 420, 440, 460 };
//int[] xPos = { 0, 65, 110, 170, 220 };
//int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 160, 180, 220, 240, 260, 280, 300, 320, 350, 390, 410, 430, 450, 470, 490 };
Font headFont = new Font("Arial", 10);
Font txtFont = new Font("Arial", 9);
Font txtFont1 = new Font("Arial", 8);//注的字体
Font MemoFont = new Font("Arial", 12);
Font txtFont2 = new Font("Arial", 7);
Pen blackPen = new Pen(Color.Black, 2);
StringFormat drawFormat1 = new StringFormat();
drawFormat1.Alignment = StringAlignment.Center;
drawFormat1.LineAlignment = StringAlignment.Center;
StringFormat drawFormat3 = new StringFormat();//注的字体
drawFormat3.Alignment = StringAlignment.Near;
drawFormat3.LineAlignment = StringAlignment.Near;
StringFormat drawFormat5 = new StringFormat();//注的字体
drawFormat5.Alignment = StringAlignment.Center;
drawFormat5.LineAlignment = StringAlignment.Near;
StringFormat drawFormat2 = new StringFormat();
drawFormat2.Alignment = StringAlignment.Near;
drawFormat2.LineAlignment = StringAlignment.Center;
StringFormat drawFormat4 = new StringFormat();//
drawFormat4.Alignment = StringAlignment.Far;
drawFormat4.LineAlignment = StringAlignment.Far;
//-----------------------标题
/*
Rectangle rec = new Rectangle(oX + xPos[1], oY + yPos[0], xPos[4] - xPos[1], yPos[1] - yPos[0]);
e.Graphics.DrawString("九钢集团有限责任公司", headFont, Brushes.Black, rec, drawFormat1);
rec = new Rectangle(oX + xPos[1], oY + yPos[1], xPos[4] - xPos[1], yPos[2] - yPos[1]);
e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
e.Graphics.DrawImage(img, oX + xPos[0], oY + yPos[0], xPos[1] - xPos[0], 40);
//*/
//*
Rectangle rec = new Rectangle(oX + xPos[0], oY + yPos[0], xPos[4] - xPos[0], yPos[1] - yPos[0]);
e.Graphics.DrawString("九钢集团股份有限公司", headFont, Brushes.Black, rec, drawFormat1);
rec = new Rectangle(oX + xPos[0], oY + yPos[1], xPos[4] - xPos[0], yPos[2] - yPos[1]);
e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
//e.Graphics.DrawString("凌字311-005", txtFont2, Brushes.Black, rec, drawFormat4);
//*/
//-----------------------------
//-----------------------正文
rec.X = xPos[0] + oX; //35
rec.Y = yPos[2] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("流水号", txtFont, Brushes.Black, rec, drawFormat1); //35
rec.X = xPos[1] + oX;
rec.Y = yPos[2] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.actualNo, txtFont, Brushes.Black, rec, drawFormat1); //流水号值
rec.X = xPos[0] + oX;
rec.Y = yPos[3] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("预报编号", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[3] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.predictionNo, txtFont, Brushes.Black, rec, drawFormat1); //预报编号值
rec.X = xPos[0] + oX;
rec.Y = yPos[4] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("车号", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[4] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.carNo, txtFont, Brushes.Black, rec, drawFormat1); //车号
rec.X = xPos[0] + oX;
rec.Y = yPos[5] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("物资名称", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[5] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.matterName, txtFont, Brushes.Black, rec, drawFormat1); //物资名称
rec.X = xPos[0] + oX;
rec.Y = yPos[6] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("检斤类型", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[6] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.meterTypeName, txtFont, Brushes.Black, rec, drawFormat1); //检斤类型值
rec.X = xPos[0] + oX;
rec.Y = yPos[7] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("来源", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[7] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.forwardingUnitName, txtFont2, Brushes.Black, rec, drawFormat1); //来源值
rec.X = xPos[0] + oX;
rec.Y = yPos[8] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("去向", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[8] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.receivingUintName, txtFont2, Brushes.Black, rec, drawFormat1); //去向值
rec.X = xPos[0] + oX;
rec.Y = yPos[9] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("毛重时间", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[9] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.grossTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont, Brushes.Black, rec, drawFormat1); //一次计量时间值
rec.X = xPos[0] + oX;
rec.Y = yPos[10] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("皮重时间", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[10] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.tareTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont, Brushes.Black, rec, drawFormat1); //二次计量时间值
rec.X = xPos[0] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("毛重(t)", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1); //毛重值
rec.X = xPos[2] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[3] - xPos[2];
rec.Height = 20;
e.Graphics.DrawString("附加重量", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[3] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[4] - xPos[3];
rec.Height = 20;
e.Graphics.DrawString(((first.grossWeight.Value - first.tareWeight.Value - first.netWeight.Value) / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[0] + oX;
rec.Y = yPos[12] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("皮重(t)", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[12] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString((first.tareWeight.Value / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1); //皮重值
rec.X = xPos[2] + oX;
rec.Y = yPos[12] + oY;
rec.Width = xPos[3] - xPos[2];
rec.Height = 20;
e.Graphics.DrawString("净重(t)", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[3] + oX;
rec.Y = yPos[12] + oY;
rec.Width = xPos[4] - xPos[3];
rec.Height = 20;
e.Graphics.DrawString((first.netWeight.Value / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1); //净重值
rec.X = xPos[0] + oX;
rec.Y = yPos[13] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("规格", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[13] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.specName, txtFont, Brushes.Black, rec, drawFormat1);
//*/
rec.X = xPos[0] + oX;
rec.Y = yPos[14] + oY;
rec.Width = xPos[4] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("注:本小票不作为结算凭证,请注意保管!", txtFont1, Brushes.Black, rec, drawFormat3); //注意
rec.X = xPos[0] + oX;
rec.Y = yPos[15] + oY;
rec.Width = xPos[4] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("打票时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtFont1, Brushes.Black, rec, drawFormat3);//注意//Now.ToString("yyyy-MM-dd HH:mm:ss")
e.Graphics.DrawImage(img, 180, 2 + yPos[16], xPos[1] - xPos[0], 40);
//打印横线
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[4] + oX, yPos[2] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[3] + oY, xPos[4] + oX, yPos[3] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[4] + oY, xPos[4] + oX, yPos[4] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[5] + oY, xPos[4] + oX, yPos[5] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[6] + oY, xPos[4] + oX, yPos[6] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[7] + oY, xPos[4] + oX, yPos[7] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[8] + oY, xPos[4] + oX, yPos[8] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[9] + oY, xPos[4] + oX, yPos[9] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[10] + oY, xPos[4] + oX, yPos[10] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[11] + oY, xPos[4] + oX, yPos[11] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[12] + oY, xPos[4] + oX, yPos[12] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[13] + oY, xPos[4] + oX, yPos[13] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[14] + oY, xPos[4] + oX, yPos[14] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[15] + oY, xPos[4] + oX, yPos[15] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[16] + oY, xPos[4] + oX, yPos[16] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[17] + oY, xPos[4] + oX, yPos[17] + oY);
//打印竖线
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[0] + oX, yPos[17] + oY);
e.Graphics.DrawLine(blackPen, xPos[1] + oX, yPos[2] + oY, xPos[1] + oX, yPos[14] + oY);
e.Graphics.DrawLine(blackPen, xPos[2] + oX, yPos[11] + oY, xPos[2] + oX, yPos[13] + oY);
e.Graphics.DrawLine(blackPen, xPos[3] + oX, yPos[11] + oY, xPos[3] + oX, yPos[13] + oY);
e.Graphics.DrawLine(blackPen, xPos[4] + oX, yPos[2] + oY, xPos[4] + oX, yPos[17] + oY);
PrintNum(PbCache.sportInfo.baseSpotNo);
}
catch (Exception exp)
{
WriteLog("结净计量打印异常!" + exp.Message);
}
}
///
/// 过磅打印
///
///
///
public void PrintWgtPage(System.Drawing.Printing.PrintPageEventArgs e, MeterWorkCarActual first, string strCode)
{
try
{
Image img = qr.rtImgQRCode(strCode);
int oX = 0, oY = -2; //偏移量
int[] xPos = { 0, 65, 125, 205, 265 };
int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 360, 380, 400, 420, 440, 460 };
//int[] xPos = { 0, 65, 110, 170, 220 };
//int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 160, 180, 220, 240, 260, 280, 300, 320, 350, 390, 410, 430, 450, 470, 490 };
Font headFont = new Font("Arial", 10);
Font txtFont = new Font("Arial", 9);
Font txtFont1 = new Font("Arial", 8);//注的字体
Font MemoFont = new Font("Arial", 12);
Font txtFont2 = new Font("Arial", 7);
Pen blackPen = new Pen(Color.Black, 2);
StringFormat drawFormat1 = new StringFormat();
drawFormat1.Alignment = StringAlignment.Center;
drawFormat1.LineAlignment = StringAlignment.Center;
StringFormat drawFormat3 = new StringFormat();//注的字体
drawFormat3.Alignment = StringAlignment.Near;
drawFormat3.LineAlignment = StringAlignment.Near;
StringFormat drawFormat5 = new StringFormat();//注的字体
drawFormat5.Alignment = StringAlignment.Center;
drawFormat5.LineAlignment = StringAlignment.Near;
StringFormat drawFormat2 = new StringFormat();
drawFormat2.Alignment = StringAlignment.Near;
drawFormat2.LineAlignment = StringAlignment.Center;
StringFormat drawFormat4 = new StringFormat();//
drawFormat4.Alignment = StringAlignment.Far;
drawFormat4.LineAlignment = StringAlignment.Far;
//-----------------------标题
Rectangle rec = new Rectangle(oX + xPos[1], oY + yPos[0], xPos[4] - xPos[1], yPos[1] - yPos[0]);
e.Graphics.DrawString("九钢集团股份有限公司", headFont, Brushes.Black, rec, drawFormat1);
rec = new Rectangle(oX + xPos[1], oY + yPos[1], xPos[4] - xPos[1], yPos[2] - yPos[1]);
e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
e.Graphics.DrawImage(img, oX + xPos[0], oY + yPos[0], xPos[1] - xPos[0], 40);
/*
Rectangle rec = new Rectangle(oX + xPos[0], oY + yPos[0], xPos[4] - xPos[0], yPos[1] - yPos[0]);
e.Graphics.DrawString("九钢集团股份有限公司", headFont, Brushes.Black, rec, drawFormat1);
rec = new Rectangle(oX + xPos[0], oY + yPos[1], xPos[4] - xPos[0], yPos[2] - yPos[1]);
e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
//e.Graphics.DrawString("凌字311-005", txtFont2, Brushes.Black, rec, drawFormat4);
//*/
//-----------------------------
//-----------------------正文
rec.X = xPos[0] + oX; //35
rec.Y = yPos[2] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("流水号", txtFont, Brushes.Black, rec, drawFormat1); //35
rec.X = xPos[1] + oX;
rec.Y = yPos[2] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.actualNo, txtFont, Brushes.Black, rec, drawFormat1); //流水号值
rec.X = xPos[0] + oX;
rec.Y = yPos[3] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("预报编号", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[3] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.predictionNo, txtFont, Brushes.Black, rec, drawFormat1); //预报编号值
rec.X = xPos[0] + oX;
rec.Y = yPos[4] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("车号", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[4] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.carNo, txtFont, Brushes.Black, rec, drawFormat1); //车号
rec.X = xPos[0] + oX;
rec.Y = yPos[5] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("物资名称", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[5] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.matterName, txtFont, Brushes.Black, rec, drawFormat1); //物资名称
rec.X = xPos[0] + oX;
rec.Y = yPos[6] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("检斤类型", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[6] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.meterTypeName, txtFont, Brushes.Black, rec, drawFormat1); //检斤类型值
rec.X = xPos[0] + oX;
rec.Y = yPos[7] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("来源", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[7] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.forwardingUnitName, txtFont2, Brushes.Black, rec, drawFormat1); //来源值
rec.X = xPos[0] + oX;
rec.Y = yPos[8] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("去向", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[8] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.receivingUintName, txtFont2, Brushes.Black, rec, drawFormat1); //去向值
rec.X = xPos[0] + oX;
rec.Y = yPos[9] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("计量类型", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[9] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.meterTypeNo == "0" ? "毛重" : "皮重", txtFont, Brushes.Black, rec, drawFormat1); //计量类型
rec.X = xPos[0] + oX;
rec.Y = yPos[10] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("计量时间", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[10] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.grossTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont, Brushes.Black, rec, drawFormat1); //计量时间
rec.X = xPos[0] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("重量(t)", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[2] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1); //毛重值
rec.X = xPos[2] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[3] - xPos[2];
rec.Height = 20;
e.Graphics.DrawString("附加重量", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[3] + oX;
rec.Y = yPos[11] + oY;
rec.Width = xPos[4] - xPos[3];
rec.Height = 20;
e.Graphics.DrawString(((string.IsNullOrEmpty(first.valueFlag)?0:Convert.ToInt32(first.valueFlag)) / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[0] + oX;
rec.Y = yPos[12] + oY;
rec.Width = xPos[1] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("规格", txtFont, Brushes.Black, rec, drawFormat1);
rec.X = xPos[1] + oX;
rec.Y = yPos[12] + oY;
rec.Width = xPos[4] - xPos[1];
rec.Height = 20;
e.Graphics.DrawString(first.specName, txtFont, Brushes.Black, rec, drawFormat1);
//*/
rec.X = xPos[0] + oX;
rec.Y = yPos[13] + oY;
rec.Width = xPos[4] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("注:本小票不作为结算凭证,请注意保管!", txtFont1, Brushes.Black, rec, drawFormat3); //注意
rec.X = xPos[0] + oX;
rec.Y = yPos[14] + oY;
rec.Width = xPos[4] - xPos[0];
rec.Height = 20;
e.Graphics.DrawString("打票时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtFont1, Brushes.Black, rec, drawFormat3);//注意//Now.ToString("yyyy-MM-dd HH:mm:ss")
e.Graphics.DrawImage(img, 180, 2 + yPos[15], xPos[1] - xPos[0], 40);
//打印横线
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[4] + oX, yPos[2] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[3] + oY, xPos[4] + oX, yPos[3] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[4] + oY, xPos[4] + oX, yPos[4] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[5] + oY, xPos[4] + oX, yPos[5] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[6] + oY, xPos[4] + oX, yPos[6] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[7] + oY, xPos[4] + oX, yPos[7] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[8] + oY, xPos[4] + oX, yPos[8] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[9] + oY, xPos[4] + oX, yPos[9] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[10] + oY, xPos[4] + oX, yPos[10] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[11] + oY, xPos[4] + oX, yPos[11] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[12] + oY, xPos[4] + oX, yPos[12] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[13] + oY, xPos[4] + oX, yPos[13] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[14] + oY, xPos[4] + oX, yPos[14] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[15] + oY, xPos[4] + oX, yPos[15] + oY);
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[16] + oY, xPos[4] + oX, yPos[16] + oY);
//打印竖线
e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[0] + oX, yPos[16] + oY);
e.Graphics.DrawLine(blackPen, xPos[1] + oX, yPos[2] + oY, xPos[1] + oX, yPos[12] + oY);
e.Graphics.DrawLine(blackPen, xPos[2] + oX, yPos[11] + oY, xPos[2] + oX, yPos[12] + oY);
e.Graphics.DrawLine(blackPen, xPos[3] + oX, yPos[11] + oY, xPos[3] + oX, yPos[12] + oY);
e.Graphics.DrawLine(blackPen, xPos[4] + oX, yPos[2] + oY, xPos[4] + oX, yPos[16] + oY);
PrintNum(PbCache.sportInfo.baseSpotNo);
}
catch (Exception exp)
{
WriteLog("一次计量打印异常!" + exp.Message);
}
}
private void WriteLog(string str)
{
string m_szRunPath;
m_szRunPath = System.Environment.CurrentDirectory;
if (System.IO.Directory.Exists(m_szRunPath + "\\log") == false)
{
System.IO.Directory.CreateDirectory(m_szRunPath + "\\log");
}
string strDate = System.DateTime.Now.ToString("yyyyMMdd");
string strPathFile = m_szRunPath + "\\log\\" + strDate;
if (!Directory.Exists(strPathFile))//如果不存在就创建file文件夹
{
Directory.CreateDirectory(strPathFile);
}
System.IO.TextWriter tw = new System.IO.StreamWriter(strPathFile + "\\打印_" + strDate + ".log", true);
tw.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
tw.WriteLine(str);
tw.WriteLine("\r\n");
tw.Close();
}
}
}