184 lines
7.7 KiB
C#
184 lines
7.7 KiB
C#
|
|
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
|||
|
|
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
|||
|
|
using Kingdee.BOS.Core.List;
|
|||
|
|
using Kingdee.BOS.Util;
|
|||
|
|
using Kingdee.K3.BD.BarCode.Business.PlugIn;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using Kingdee.BOS.Core.Bill;
|
|||
|
|
using Kingdee.BOS.Core.Metadata;
|
|||
|
|
using Kingdee.BOS.Orm.DataEntity;
|
|||
|
|
using Kingdee.BOS.Core.DynamicForm;
|
|||
|
|
using Kingdee.BOS.Core.Bill.PlugIn;
|
|||
|
|
using Kingdee.BOS.Core.NotePrint;
|
|||
|
|
using Kingdee.BOS.Resource;
|
|||
|
|
using Kingdee.K3.BD.BarCode.App.Core;
|
|||
|
|
using Kingdee.K3.BD.BarCode.Core.DataModel.Service;
|
|||
|
|
using Kingdee.K3.BD.BarCode.ServiceHelper;
|
|||
|
|
using Kingdee.BOS.Core;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using Kingdee.BOS.Core.Metadata.FieldElement;
|
|||
|
|
using Kingdee.BOS;
|
|||
|
|
|
|||
|
|
namespace GZ.LJY000.Biori.UHIK_BAR_BarCodePrint
|
|||
|
|
{
|
|||
|
|
[Description("条码打印重写2"), HotUpdate]
|
|||
|
|
public class BarCodePrintEditEx : BarCodePrintEditRewrite
|
|||
|
|
{
|
|||
|
|
private List<DynamicObject> printDatas2 = new List<DynamicObject>();
|
|||
|
|
|
|||
|
|
private List<DynamicObject> newPrintDatas2 = new List<DynamicObject>();
|
|||
|
|
|
|||
|
|
public override void OnInitialize(InitializeEventArgs e)
|
|||
|
|
{
|
|||
|
|
base.OnInitialize(e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void OnLoad(EventArgs e)
|
|||
|
|
{
|
|||
|
|
base.OnLoad(e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void EntryBarItemClick(BarItemClickEventArgs e)
|
|||
|
|
{
|
|||
|
|
base.EntryBarItemClick(e);
|
|||
|
|
if (e.BarItemKey.ToUpperInvariant().Equals("TBPRINTBARCODE2"))
|
|||
|
|
{
|
|||
|
|
PrintBarCode("print");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PrintBarCode(string printType)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var printDatas = new List<DynamicObject>();
|
|||
|
|
var newPrintDatas = new List<DynamicObject>();
|
|||
|
|
string defaultBarCodeModel = Convert.ToString(base.View.Model.GetValue("FBarCodeModel"));
|
|||
|
|
BarCodePrintOperation printOperation = new BarCodePrintOperation();
|
|||
|
|
|
|||
|
|
string printAddress = Convert.ToString(base.View.Model.GetValue("FPrintAddress")).Trim().ToLowerInvariant();
|
|||
|
|
if (string.IsNullOrWhiteSpace(printAddress))
|
|||
|
|
{
|
|||
|
|
base.View.ShowNotificationMessage(ResManager.LoadKDString("请填写打印机名称!", "0011019000003156", SubSystemType.BASE));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (!CheckPrintData(printDatas) || printDatas == null || printDatas.Count <= 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
List<string> list = new List<string>();
|
|||
|
|
List<string> list2 = new List<string>();
|
|||
|
|
List<string> list3 = new List<string>();
|
|||
|
|
int num = 0;
|
|||
|
|
foreach (DynamicObject printData2 in printDatas)
|
|||
|
|
{
|
|||
|
|
if (printData2 != null)
|
|||
|
|
{
|
|||
|
|
int num2 = Convert.ToInt32(printData2["PrintNumber"]);
|
|||
|
|
for (int i = 0; i < num2; i++)
|
|||
|
|
{
|
|||
|
|
newPrintDatas.Add(printData2);
|
|||
|
|
string item = Convert.ToString(printData2["BarCode"]);
|
|||
|
|
string text = Convert.ToString(printData2["BARCODEMODEL"]);
|
|||
|
|
text = (string.IsNullOrWhiteSpace(text) ? defaultBarCodeModel : text);
|
|||
|
|
text = text.Replace(" ", "");
|
|||
|
|
list2.Add(text);
|
|||
|
|
list3.Add(item);
|
|||
|
|
list.Add(num.ToString());
|
|||
|
|
num++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UNWLogger.Info(base.Context, "PrintBarCode:", "printDataId=" + string.Join(",", list));
|
|||
|
|
UNWLogger.Info(base.Context, "PrintBarCode:", ResManager.LoadKDString("总数量:", "14512b12f13e4f85", "APP_ISVPAAC2016062210550") + list3.Count() + "," + printType + ",BarCode=" + string.Join(",", list3));
|
|||
|
|
printOperation.BarCodePrintDoAction(this, null, list, list2, printType, printAddress);
|
|||
|
|
//printOperationType = printType;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
ex.StackTrace.ToString();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool CheckPrintData(List<DynamicObject> printDatas)
|
|||
|
|
{
|
|||
|
|
bool flag = true;
|
|||
|
|
ExtendedDataEntitySet extendedDataEntitySet = new ExtendedDataEntitySet();
|
|||
|
|
extendedDataEntitySet.Parse(new DynamicObject[1] { base.View.Model.DataObject }, base.View.Model.BusinessInfo);
|
|||
|
|
ExtendedDataEntity[] array = (from p in extendedDataEntitySet.FindByEntityKey("FEntityToBar")
|
|||
|
|
where p.DataEntity["BarCodeCheck"].ToString().EqualsIgnoreCase("True")
|
|||
|
|
select p).ToArray();
|
|||
|
|
if (array.Count() < 1)
|
|||
|
|
{
|
|||
|
|
base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择打印数据行!", "0011019000003158", SubSystemType.BASE));
|
|||
|
|
flag = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string text = Convert.ToString(base.View.Model.GetValue("FBarCodeModel"));
|
|||
|
|
List<int> list = new List<int>();
|
|||
|
|
List<int> list2 = new List<int>();
|
|||
|
|
for (int i = 0; i < array.Count(); i++)
|
|||
|
|
{
|
|||
|
|
DynamicObject dataEntity = array[i].DataEntity;
|
|||
|
|
printDatas.Add(dataEntity);
|
|||
|
|
string text2 = Convert.ToString(dataEntity["BARCODEMODEL"]);
|
|||
|
|
text2 = (string.IsNullOrWhiteSpace(text2) ? text : text2);
|
|||
|
|
text2 = text2.Replace(" ", "");
|
|||
|
|
string value = Convert.ToString(dataEntity["BarCode"]);
|
|||
|
|
int item = Convert.ToInt32(dataEntity["Seq"]);
|
|||
|
|
if (string.IsNullOrWhiteSpace(value))
|
|||
|
|
{
|
|||
|
|
list.Add(item);
|
|||
|
|
flag = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (string.IsNullOrWhiteSpace(text2))
|
|||
|
|
{
|
|||
|
|
list2.Add(item);
|
|||
|
|
flag = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string text3 = "";
|
|||
|
|
if (list.Count > 0)
|
|||
|
|
{
|
|||
|
|
for (int j = 0; j < list.Count; j++)
|
|||
|
|
{
|
|||
|
|
text3 = ((j < list.Count - 1) ? (list[j] + "、") : list[j].ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
text3 = (string.IsNullOrWhiteSpace(text3) ? "" : string.Format(ResManager.LoadKDString(ResManager.LoadKDString("第", "5e2976b208924f20", "APP_ISVPAAC2016062210550"), "0011019000003159", SubSystemType.BASE) + text3 + ResManager.LoadKDString("行条形码尚未生成!", "0011019000003160", SubSystemType.BASE)));
|
|||
|
|
string text4 = "";
|
|||
|
|
if (list2.Count > 0)
|
|||
|
|
{
|
|||
|
|
for (int k = 0; k < list2.Count; k++)
|
|||
|
|
{
|
|||
|
|
text4 = ((k < list2.Count - 1) ? (list2[k] + "、") : list2[k].ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
text4 = (string.IsNullOrWhiteSpace(text4) ? "" : string.Format(ResManager.LoadKDString(ResManager.LoadKDString("第", "5e2976b208924f20", "APP_ISVPAAC2016062210550"), "0011019000003159", SubSystemType.BASE) + text4 + ResManager.LoadKDString("行条形码未设置条码模板!", "0011019000003161", SubSystemType.BASE)));
|
|||
|
|
if (!string.IsNullOrWhiteSpace(text3 + text4))
|
|||
|
|
{
|
|||
|
|
base.View.ShowNotificationMessage(text3 + text4);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!flag)
|
|||
|
|
{
|
|||
|
|
printDatas = new List<DynamicObject>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return flag;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|