4c83bfe0b2
SVN-Revision: r476
83 lines
3.2 KiB
C#
83 lines
3.2 KiB
C#
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.PubArgoxPrint
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
public DynamicArgoxPrintModel Model;
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
this.Opacity = 0;
|
|
this.Load += OnFrmMainLoad;
|
|
}
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnFrmMainLoad(object sender, EventArgs e)
|
|
{
|
|
WaitForm.ShowForm("正在打印中...");
|
|
try
|
|
{
|
|
string printSql = Model.MainPrintSql;
|
|
printSql = ReplaceHelper.ReplaceRowParam(Model.MaintabFocusedRow, Model.MainPrintSql);
|
|
DataTable printTable = BaseImpl.GetDataTableResult(printSql);
|
|
if (printTable == null || printTable.Rows.Count == 0)
|
|
{
|
|
MessageUtil.Show("没有打印数据");
|
|
return;
|
|
}
|
|
int nLen = PrintUtil.A_GetUSBBufferLen() + 1;
|
|
if (nLen <= 1)
|
|
{
|
|
MessageUtil.Show("打印机未连接");
|
|
return;
|
|
}
|
|
byte[] pbuf = new byte[128];
|
|
int len1 = 128;
|
|
int len2 = 128;
|
|
byte[] buf1 = new byte[len1];
|
|
byte[] buf2 = new byte[len2];
|
|
PrintUtil.A_EnumUSB(pbuf);
|
|
PrintUtil.A_GetUSBDeviceInfo(1, buf1, out len1, buf2, out len2);
|
|
int ret = PrintUtil.A_CreatePrn(12, Encoding.ASCII.GetString(buf2, 0, len2));//open usb.
|
|
if (ret != 0)
|
|
{
|
|
MessageBox.Show("打印启动失败");
|
|
return;
|
|
}
|
|
PrintUtil.A_Set_DebugDialog(0);
|
|
PrintUtil.A_Set_Unit('m');
|
|
PrintUtil.A_Set_Syssetting(1, 0, 0, 0, 0);
|
|
PrintUtil.A_Set_Darkness(13);
|
|
PrintUtil.A_Del_Graphic(1, "*");//delete all picture.
|
|
string[] locationxArray = Model.LocationX.Split(',');
|
|
string[] printArgsArray = Model.PrintArgs.Split(',');
|
|
int columnCount = locationxArray.Length;
|
|
for (int i = 0; i < printTable.Rows.Count; i++)
|
|
{
|
|
if (i % columnCount == 0)
|
|
{
|
|
PrintUtil.A_Clear_Memory();//clear memory.
|
|
}
|
|
DataRow printRow = printTable.Rows[i];
|
|
for (int j = 0; j < printTable.Columns.Count; j++)
|
|
{
|
|
int locationX = int.TryParse(locationxArray[i % columnCount], out locationX) ? locationX : 0;
|
|
PrintModel printModel = new PrintModel(printArgsArray[j % columnCount].Split('_'));
|
|
string printValue = printRow[j] + "";
|
|
if (printModel.PrintType == 0)
|
|
|