天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

177 lines
7.4 KiB

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;
using QMAPP.WinForm.Forms.Operation;
using QMAPP.Entity;
using QMAPP.MD.Entity;
namespace QMAPP.WinForm.Forms.RePrint
{
public partial class DPAssemblyCodePrintForm : Form
{
QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent();
public DPAssemblyCodePrintForm()
{
InitializeComponent();
}
/// <summary>
/// 确认
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void butOk_Click(object sender, EventArgs e)
{
SearchProduct();
}
/// <summary>
/// 条码回车
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtProductCode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter)//如果输入的是回车键
{
return;
}
SearchProduct();
}
/// <summary>
///
/// </summary>
private void SearchProduct()
{
if (string.IsNullOrEmpty(this.txtProductCode.Text))
{
txtProductCode.Focus();
this.labErrorMessage.Text = "请输入零件条码信息!";
return;
}
Entity.DataResult<FJC.Entity.Operation.ProductFullInfo> result
= _agent.InvokeServiceFunction<Entity.DataResult<FJC.Entity.Operation.ProductFullInfo>>("ProductBLL_GetProductAllInfo", txtProductCode.Text);
if (result.IsSuccess)
{
var info = result.Result;
string FisCode = info.ProductBasicInfo.PLAN_NO.ToString();
if (string.IsNullOrEmpty(FisCode))
{
txtProductCode.Focus();
this.labErrorMessage.Text = "此产品未绑定FIS码信息!";
return;
}
txtProductCode.Focus();
this.txtFisCode.Text = FisCode;
this.labErrorMessage.Text = "";
}
else
{
txtProductCode.Focus();
this.labErrorMessage.Text = "此产品未绑定FIS码信息!";
return;
}
}
/// <summary>
/// 打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbPrint_Click(object sender, EventArgs e)
{
//去 查询信息
string orderplanno = this.txtFisCode.Text;
//var order = new List<FJC.Entity.ProductionPlan.WorkOrder>();
var orders = _agent.InvokeServiceFunction<List<FJC.Entity.ProductionPlan.WorkOrder>>("WorkOrderBLL_GetOrderInfo", orderplanno);
List<LabelData> labels = new List<LabelData>();
if (orders.Count > 0)
{
foreach (var order in orders)
{
var codematch = System.Text.RegularExpressions.Regex.Match(order.PBOM_CODE, "_[LR][FR]_");
string positioncode = codematch.Success ? codematch.Value.Trim('_') : "";
var book = _agent.InvokeServiceFunction<FJC.Entity.FIS.FISPhraseBook>("FISPhraseBLL_GetFisPhraseBook", order.MATERIAL_CODE + "", positioncode);
LabelData labeldata = new LabelData();
labeldata.OrderNo = order.ORDERPLAN_NO;
labeldata.PlanDate = order.PLAN_DATE;
if (book != null)
{
labeldata.Class = " " + book.Class.Substring(0, 2);
labeldata.Description = book.Text;
}
var mcresult = _agent.InvokeServiceFunction<DataResult<Material>>("MaterialBLL_Get", new Material { MATERIAL_CODE = order.MATERIAL_CODE });
var material = mcresult.IsSuccess ? mcresult.Result : null;
if (material != null)
{
labeldata.MaterialName = material.MATERIAL_SHORT;
labeldata.CarModel = material.PROJECTCODE;
}
labels.Add(labeldata);
}
}
else
{
this.labErrorMessage.Text = "此产品未绑定FIS码信息!";
this.txtProductCode.Text = "";
this.txtFisCode.Text = "";
this.txtProductCode.Focus();
return;
}
PrintLabel(labels);
}
private void PrintLabel(List<LabelData> labeldata)
{
#region 计划标签打印
//string xmlPath = System.Configuration.ConfigurationSettings.AppSettings["XmlName"].ToString(); ;
//BarcodeLib.BarCodeGenerate g = new BarcodeLib.BarCodeGenerate( xmlPath);
//bool b = g.PrintBarCode(_operationServiceParam.main.MAINCODE);
QM.Assist.LabelInfo ll = new QM.Assist.LabelInfo();
StringBuilder dataline = new StringBuilder();
foreach (var label in labeldata)
{
string[] texts = new string[6];
var sourcetext = label.Description.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < texts.Length && i < sourcetext.Length; i++)
{
texts[i] = sourcetext[i];
}
//OrderNo,OrderType,PlanDate,Name,Class,CarModel,Text1,Text2,Text3,Text4,Text5,Text6
dataline.AppendFormat("\"{0}\",\"{1}\",\"{2:yyyy-MM-dd HH:mm:ss}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\"\r\n",
label.OrderNo,//计划号
label.OrderType,//计划类型(0:FIS,1:STOCK,2:INSERT)
label.PlanDate,//计划日期
label.MaterialName,//总成物料名称
label.Class,//
label.CarModel,//车型
texts[0],//装配详细信息
texts[1],//装配详细信息
texts[2],//装配详细信息
texts[3],//装配详细信息
texts[4],//装配详细信息
texts[5]//装配详细信息
);
}
ll.BarCode = dataline.ToString().TrimEnd('\r', '\n');
QM.Assist.PrintUtil.LabelList2.Add(ll);
QM.Assist.PrintUtil pu = new QM.Assist.PrintUtil();
pu.PrintLabel2(System.Configuration.ConfigurationManager.AppSettings["proPath"].ToString
(), System.Configuration.ConfigurationManager.AppSettings["PlanLabelTMPPath"].ToString
(), System.Configuration.ConfigurationManager.AppSettings["PlanLabelDATPath"].ToString
());
#endregion
}
}
}