using DevExpress.Utils.DirectXPaint;
|
using DevExpress.XtraEditors;
|
using FastReport;
|
using Gs.DevApp.ToolBox;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.IO;
|
using System.Linq;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace Gs.DevApp.UserControl
|
{
|
public partial class UcBtnPrintAll : DevExpress.XtraEditors.XtraUserControl
|
{
|
public UcBtnPrintAll()
|
{
|
InitializeComponent();
|
}
|
/// <summary>
|
/// 打印
|
/// </summary>
|
public event EventHandler btnPrintClick;
|
|
public string rptType { get; set; }
|
public List<dynamic> mxList { get; set; }
|
private void simpleButton1_Click(object sender, EventArgs e)
|
{
|
if (btnPrintClick != null)
|
btnPrintClick(this, e);
|
else
|
return;
|
|
if (string.IsNullOrEmpty(rptType))
|
{
|
return;
|
}
|
if (mxList.Count<=0)
|
{
|
return;
|
}
|
int rowsCount = 0;
|
foreach (dynamic obj in mxList)
|
{
|
string guid = obj.guid.ToString();
|
string psnQty = obj.kdy.ToString();
|
if (string.IsNullOrEmpty(psnQty))
|
{
|
continue;
|
}
|
if (psnQty == "0")
|
{
|
continue;
|
}
|
string rptParameter = rptType + "{"
|
+ guid//关联主键
|
+ "," + ""
|
+ "," + 0//余数
|
+ "," + 1//张数
|
+ "," + psnQty//每张条码数量,目前等于申请量
|
+ "}";
|
var _obj = new
|
{
|
rptParameter = rptParameter,
|
guid = guid,
|
isDesign = 0
|
};
|
try
|
{
|
var strJson = UtilityHelper.HttpPost("", "Report/GetRptData",
|
JsonConvert.SerializeObject(_obj));
|
var _job = JObject.Parse(strJson);
|
var rtnCode = _job["rtnCode"].ToString();
|
if (int.Parse(rtnCode) > 0)
|
{
|
//模板
|
var report = new FastReport.Report();
|
|
EnvironmentSettings eSet = new EnvironmentSettings();
|
eSet.ReportSettings.ShowProgress = false;
|
report = new FastReport.Report();
|
|
var buffer = (byte[])_job["rtnData"]["reportTemplateData"];
|
using (var Stream = new MemoryStream(buffer))
|
{
|
report.Load(Stream);
|
}
|
//主表
|
var array = new JArray();
|
foreach (var a in _job["rtnData"]["zb"]) array.Add(a);
|
var _zb = JsonConvert.DeserializeObject<DataTable>(array.ToString());
|
_zb.TableName = "zb";
|
//明细表1
|
var array1 = new JArray();
|
foreach (var a in _job["rtnData"]["mx1"]) array1.Add(a);
|
var _mx1 = JsonConvert.DeserializeObject<DataTable>(array1.ToString());
|
_mx1.TableName = "mx1";
|
//明细表2
|
var array2 = new JArray();
|
foreach (var a in _job["rtnData"]["mx2"]) array2.Add(a);
|
var _mx2 = JsonConvert.DeserializeObject<DataTable>(array2.ToString());
|
_mx2.TableName = "mx2";
|
//加到数据集中
|
var ds = new DataSet();
|
ds.Tables.Add(_zb);
|
ds.Tables.Add(_mx1);
|
ds.Tables.Add(_mx2);
|
report.RegisterData(ds);
|
report.PrintSettings.ShowDialog = false;
|
report.Print();
|
report.PrintSettings.ShowDialog = false;
|
report.Dispose();
|
rowsCount++;
|
}
|
else
|
{
|
|
}
|
}
|
catch (Exception ex)
|
{
|
|
}
|
Thread.Sleep(50);
|
}
|
if (rowsCount > 0)
|
MsgHelper.ShowInformation("提示:操作成功,共打印" + rowsCount.ToString() + "张!");
|
else
|
MsgHelper.ShowError("提示:暂无可打印物料!");
|
}
|
}
|
}
|