天津投入产出系统后端
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.
 
 
 
 
 
 

205 lines
7.3 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using QMAPP.FJC.Entity.Operation;
using QMAPP.ServicesAgent;
using QMAPP.FJC.Entity.BZD;
using QMAPP.Entity;
using QMAPP.MD.Entity;
using System.Text;
namespace QMAPP.WinForm.Forms.TianJin
{
public partial class PlanRePrintForm : Form
{
//获取服务代理
QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent();
List<Material> _Material = null;
Product _CurrentProduct = null;
private TJPrintPlanLabel _parentForm;
public PlanRePrintForm(TJPrintPlanLabel parentForm)
{
InitializeComponent();
infolabel.Text = "";
infolabel.ForeColor = Color.Red;
_parentForm = parentForm;
}
#region 打印按钮
/// <summary>
/// 打印按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(cbMaterial.Text))
{
infolabel.Text = "请选择物料号!";
cbMaterial.Focus();
return;
}
var data = DateTime.Now.ToString("yyyyMMddHHmmssfff");
data = data.Substring(2, data.Length - 2);
var MATERIAL_CODE = cbMaterial.Text.Split('|')[0];
var MATERIAL_NAME = cbMaterial.Text.Split('|')[1];
List<LabelData> labels = new List<LabelData>();
LabelData labeldata = new LabelData();
labeldata.MATERIALCODE = MATERIAL_CODE;
string positioncode = GetNameCode(MATERIAL_NAME);
var book = _agent.InvokeServiceFunction<FJC.Entity.FIS.FISPhraseBook>("FISPhraseBLL_GetFisPhraseBook", MATERIAL_CODE , positioncode);
if (book != null)
{
labeldata.Class = " " + book.Class.Substring(0, 2);
labeldata.Description = book.Text;
labeldata.OrderNo = book.CarModel + positioncode + data;
}
var mcresult = _agent.InvokeServiceFunction<DataResult<Material>>("MaterialBLL_Get", new Material { MATERIAL_CODE = MATERIAL_CODE });
var material = mcresult.IsSuccess ? mcresult.Result : null;
if (material != null)
{
labeldata.MaterialName = material.MATERIAL_SHORT;
labeldata.CarModel = material.PROJECTCODE;
}
labels.Add(labeldata);
// _parentForm.planMATERIAL_CODE = MATERIAL_CODE;
PrintLabel(labels);
}
catch (Exception exception)
{
MessageBox.Show("打印失败!");
throw;
}
}
#endregion
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}\",\"{12}\"\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],//装配详细信息
label.MATERIALCODE//
);
}
ll.BarCode = dataline.ToString().TrimEnd('\r', '\n');
ll.PrinterName = "";
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
}
public string GetNameCode(string Name)
{
var Code = "";
if (!string.IsNullOrEmpty(Name))
{
if (Name.Contains("左前"))
Code = "FL";
else if (Name.Contains("左后"))
Code = "RL";
else if (Name.Contains("右前"))
Code = "FR";
else if (Name.Contains("右后"))
Code = "RR";
return Code;
}
else
return null;
}
#region 初始界面
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PrintForm_Load(object sender, EventArgs e)
{
_Material = _agent.InvokeServiceFunction<List<Material>>("MaterialBLL_GetMaterialList", new Material { REMARK = "REMARK" });
foreach (var t in _Material)
{
t.MATERIAL_NAME = t.MATERIAL_CODE + "|" + t.MATERIAL_NAME;
}
LoadAssyMaterial();
}
#endregion
#region 加载总成物料
/// <summary>
/// 加载总成物料
/// </summary>
private void LoadAssyMaterial()
{
//模腔号
this.cbMaterial.DataSource = _Material;
this.cbMaterial.DisplayMember = "MATERIAL_NAME";
this.cbMaterial.ValueMember = "MATERIAL_CODE";
}
#endregion
private void label2_Click(object sender, EventArgs e)
{
}
}
}