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.
313 lines
11 KiB
313 lines
11 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;
|
|
|
|
LoadAssyMaterial();
|
|
}
|
|
|
|
#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;
|
|
if (MATERIAL_CODE.Contains("018D") || MATERIAL_CODE.Contains("278D"))
|
|
{
|
|
var bookS = _agent.InvokeServiceFunction<FJC.Entity.FIS.FISPhraseBook>("FISPhraseBLL_GetPHRASEBOOK", MATERIAL_CODE.Substring(5, 3).Trim(), "");
|
|
labeldata.Remark = bookS.Text;
|
|
}
|
|
else if (MATERIAL_CODE.Contains("493D"))
|
|
{
|
|
var bookS = _agent.InvokeServiceFunction<FJC.Entity.FIS.FISPhraseBook>("FISPhraseBLL_GetPHRASEBOOK", MATERIAL_CODE.Substring(5, 3).Trim(),"493D");
|
|
labeldata.Remark = bookS.Text;
|
|
}
|
|
|
|
}
|
|
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);
|
|
|
|
InsertProduct(labeldata.OrderNo, MATERIAL_CODE, MATERIAL_NAME);
|
|
}
|
|
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();
|
|
var TMPPath = string.Empty;
|
|
var DATPath = string.Empty;
|
|
foreach (var label in labeldata)
|
|
{
|
|
string[] texts = new string[8];
|
|
|
|
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}\",\"{13}\",\"{14}\",\"{15}\"\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],//装配详细信息
|
|
texts[6],//装配详细信息
|
|
texts[7],//装配详细信息
|
|
label.MATERIALCODE,//
|
|
label.Remark
|
|
);
|
|
if (label.OrderNo.Contains("018D") || label.OrderNo.Contains("278D") || label.OrderNo.Contains("493D"))
|
|
{
|
|
TMPPath = "PlanLabelTMPPath8D";
|
|
DATPath = "PlanLabelDATPath8D";
|
|
}
|
|
else
|
|
{
|
|
TMPPath = "PlanLabelTMPPath";
|
|
DATPath = "PlanLabelDATPath";
|
|
}
|
|
|
|
}
|
|
|
|
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[TMPPath].ToString
|
|
(), System.Configuration.ConfigurationManager.AppSettings[DATPath].ToString
|
|
());
|
|
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="ProductCode"></param>
|
|
/// <param name="Material_Code"></param>
|
|
public void InsertProduct(string ProductCode, string Material_Code, string prepare)
|
|
{
|
|
#region 组成新增产品实例
|
|
Product newProduct = new Product();
|
|
|
|
newProduct.PID = Guid.NewGuid().ToString();
|
|
|
|
newProduct.PRODUCTTYPE = string.Empty;
|
|
|
|
newProduct.PRODUCTCODE = ProductCode;
|
|
|
|
newProduct.PRODUCTSOURCE = "0";
|
|
|
|
newProduct.MACHINENAME = "门板打印";
|
|
|
|
newProduct.MACHINECODDE = "门板打印";
|
|
|
|
newProduct.MATERIAL_CODE = Material_Code;
|
|
|
|
newProduct.STATUS = "0";
|
|
|
|
newProduct.OUTFLAG = "0";
|
|
|
|
newProduct.CAPACITY = 1;
|
|
|
|
newProduct.USINGCOUNT = 0;
|
|
if (prepare.Contains("左"))
|
|
{
|
|
newProduct.WORKCELL_CODE = "DP_L_PREPARE1";
|
|
|
|
newProduct.WORKLOC_CODE = "DP_L_PREPARELOC1";
|
|
}
|
|
else if (prepare.Contains("右"))
|
|
{
|
|
newProduct.WORKCELL_CODE = "DP_R_PREPARE1";
|
|
|
|
newProduct.WORKLOC_CODE = "DP_R_PREPARELOC1";
|
|
}
|
|
else
|
|
{
|
|
newProduct.WORKCELL_CODE = "PREPARE1";
|
|
|
|
newProduct.WORKLOC_CODE = "DP_PREPARELOC1";
|
|
}
|
|
|
|
|
|
newProduct.WORKCENTER_CODE = "WORK770B";
|
|
|
|
newProduct.MATERIAL_TYPE = "DP_FINASSY";
|
|
|
|
newProduct.USINGSTATE = "0";
|
|
|
|
#endregion
|
|
|
|
//新增
|
|
_agent.InvokeServiceFunction<DataResult<int>>("ProductBLL_Insert", newProduct);
|
|
}
|
|
|
|
|
|
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 = Lines.Text });
|
|
foreach (var t in _Material)
|
|
{
|
|
t.MATERIAL_NAME = t.MATERIAL_CODE + "|" + t.MATERIAL_NAME;
|
|
}
|
|
//模腔号
|
|
this.cbMaterial.DataSource = _Material;
|
|
this.cbMaterial.DisplayMember = "MATERIAL_NAME";
|
|
this.cbMaterial.ValueMember = "MATERIAL_CODE";
|
|
//
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 加载总成物料
|
|
|
|
/// <summary>
|
|
/// 加载总成物料
|
|
/// </summary>
|
|
private void LoadAssyMaterial()
|
|
{
|
|
var list = new List<Linese>();
|
|
list.Add(new Linese() { NAME = "018D", CODE = "018D" });
|
|
list.Add(new Linese() { NAME = "770B", CODE = "770B" });
|
|
list.Add(new Linese() { NAME = "278D", CODE = "278D" });
|
|
list.Add(new Linese() { NAME = "493D", CODE = "493D" });
|
|
list.Add(new Linese() { NAME = "304D", CODE = "304D" });
|
|
this.Lines.DataSource = list;
|
|
this.Lines.DisplayMember = "NAME";
|
|
this.Lines.ValueMember = "CODE";
|
|
}
|
|
|
|
public class Linese
|
|
{
|
|
public string NAME { get; set; }
|
|
public string CODE { get; set; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
private void label2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|