|
|
|
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;
|
|
|
|
|
|
|
|
namespace QMAPP.WinForm.Forms.Operation
|
|
|
|
{
|
|
|
|
public partial class BZDRePrintForm : Form
|
|
|
|
{
|
|
|
|
//获取服务代理
|
|
|
|
QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent();
|
|
|
|
|
|
|
|
List<BZDConfig> _bzdConfig = null;
|
|
|
|
|
|
|
|
Product _CurrentProduct = null;
|
|
|
|
private OperationForm _parentForm;
|
|
|
|
private OperationForm_316 operationForm_316;
|
|
|
|
public bool state = false;
|
|
|
|
|
|
|
|
public BZDRePrintForm(OperationForm parentForm)
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
infolabel.Text = "";
|
|
|
|
infolabel.ForeColor = Color.Red;
|
|
|
|
|
|
|
|
Line();
|
|
|
|
|
|
|
|
_parentForm = parentForm;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 查询产线信息
|
|
|
|
/// </summary>
|
|
|
|
public void Line()
|
|
|
|
{
|
|
|
|
_bzdConfig = _agent.InvokeServiceFunction<List<BZDConfig>>(B9IPCService.BZDConfigBLL_GetGroupList.ToString(), "");
|
|
|
|
|
|
|
|
var list_line = new List<Lines>();
|
|
|
|
foreach (var t in _bzdConfig)
|
|
|
|
{
|
|
|
|
list_line.Add(new Lines { Code = t.Column2, Name = t.Column2 });
|
|
|
|
state = true;
|
|
|
|
}
|
|
|
|
//产线
|
|
|
|
|
|
|
|
this.cbLine.DataSource = list_line;
|
|
|
|
this.cbLine.DisplayMember = "Name";
|
|
|
|
this.cbLine.ValueMember = "Code";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public BZDRePrintForm(OperationForm_316 operationForm_316)
|
|
|
|
{
|
|
|
|
this.operationForm_316 = operationForm_316;
|
|
|
|
}
|
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(txtMainCode.Text))
|
|
|
|
{
|
|
|
|
infolabel.Text = "请扫描或填写装配码!";
|
|
|
|
|
|
|
|
txtMainCode.Focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************
|
|
|
|
var _Product = _agent.InvokeServiceFunction<BZDRecorder2>(B9IPCService.BZDRecorderBLL_GetRecord.ToString(), new BZDRecorder2() { PRODUCTCODE = txtMainCode.Text });
|
|
|
|
|
|
|
|
if (_Product == null)
|
|
|
|
{
|
|
|
|
string BZDRule = "";
|
|
|
|
//old
|
|
|
|
//DataTable dataTable = _agent.InvokeServiceFunction<DataTable>(B9IPCService.BZDConfigBLL_GetAppConfigValue.ToString(), "BZDRule");
|
|
|
|
//if (dataTable.Rows.Count > 0)
|
|
|
|
//{
|
|
|
|
// BZDRule = dataTable.Rows[0]["Value"].ToString();
|
|
|
|
//}
|
|
|
|
//if (string.IsNullOrEmpty(BZDRule))
|
|
|
|
//{
|
|
|
|
// MessageBox.Show("未配置总成规则!");
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
string MATERIAL_CODE = cbMaterial.Text.Split('|')[0];
|
|
|
|
string LINE_CODE = cbMaterial.Text.Split('|')[2];
|
|
|
|
|
|
|
|
//*******************20221009DQZhang 成都补码增加条码规则校验*****************************************************************************************************************
|
|
|
|
LINE_CODE = LINE_CODE.Substring(0, 5);
|
|
|
|
if (LINE_CODE.Equals("BC316"))
|
|
|
|
{
|
|
|
|
DataTable dataTable = _agent.InvokeServiceFunction<DataTable>(B9IPCService.BZDConfigBLL_GetAppConfigValue.ToString(), "316BZDRule");
|
|
|
|
if (dataTable.Rows.Count > 0)
|
|
|
|
{
|
|
|
|
BZDRule = dataTable.Rows[0]["Value"].ToString();
|
|
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(BZDRule))
|
|
|
|
{
|
|
|
|
MessageBox.Show("未配置总成规则!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}else if (LINE_CODE.Equals("VW371"))
|
|
|
|
{
|
|
|
|
DataTable dataTable = _agent.InvokeServiceFunction<DataTable>(B9IPCService.BZDConfigBLL_GetAppConfigValue.ToString(), "371BZDRule");
|
|
|
|
if (dataTable.Rows.Count > 0)
|
|
|
|
{
|
|
|
|
BZDRule = dataTable.Rows[0]["Value"].ToString();
|
|
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(BZDRule))
|
|
|
|
{
|
|
|
|
MessageBox.Show("未配置总成规则!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//****************************************************************************************************************************************************************************
|
|
|
|
|
|
|
|
if (System.Text.RegularExpressions.Regex.IsMatch(txtMainCode.Text, BZDRule))
|
|
|
|
{
|
|
|
|
//添加补打记录
|
|
|
|
_agent.InvokeServiceFunction<int>(B9IPCService.BarCodeReplacementBLL_Insert.ToString(), new BarCodeReplacement() { ProductCode = txtMainCode.Text, Type = "BZD条码补打" });
|
|
|
|
|
|
|
|
_parentForm.planMATERIAL_CODE = MATERIAL_CODE;
|
|
|
|
_parentForm.processMainCode = txtMainCode.Text;
|
|
|
|
//_parentForm.cBoxVAN = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//添加T_AW_PRODUCT
|
|
|
|
var ProductList = SelectProduct(txtMainCode.Text);
|
|
|
|
var PID = Guid.NewGuid().ToString();
|
|
|
|
var ProductNew = new Product()
|
|
|
|
{
|
|
|
|
PRODUCTCODE = txtMainCode.Text,
|
|
|
|
PID = PID,
|
|
|
|
//MACHINECODDE = _operationServiceParam.machineInfo.MACHINECODDE,
|
|
|
|
//MACHINENAME = _operationServiceParam.machineInfo.MACHINENAME,
|
|
|
|
PRODUCTSOURCE = "0",
|
|
|
|
MATERIAL_CODE = MATERIAL_CODE,
|
|
|
|
STATUS = "0",
|
|
|
|
OUTFLAG = "0",
|
|
|
|
USINGSTATE = "0",
|
|
|
|
CAPACITY = 1,
|
|
|
|
USINGCOUNT = 0,
|
|
|
|
//WORKCELL_CODE = ProductList.WORKCELL_CODE,
|
|
|
|
//WORKLOC_CODE = ProductList.WORKLOC_CODE,
|
|
|
|
//WORKCENTER_CODE = ProductList.WORKCENTER_CODE,
|
|
|
|
WORKCENTER_CODE = "ASSLINE",
|
|
|
|
MATERIAL_TYPE = "IP_FINASSY"
|
|
|
|
};
|
|
|
|
//_agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.ProductBLL_Insert.ToString(), ProductNew);
|
|
|
|
DataResult<int> result;//判断是否成功
|
|
|
|
//result = _agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.ProductBLL_Insert.ToString(), ProductNew);
|
|
|
|
result = _agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.ProductBLL_InsertForBundle.ToString(), ProductNew);
|
|
|
|
if (!result.IsSuccess)
|
|
|
|
{
|
|
|
|
MessageBox.Show(result.Msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_parentForm.Print052QRCODE(false,txtMainCode.Text);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MessageBox.Show("条码规则不符合!");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
MessageBox.Show("条码已存在!");
|
|
|
|
}
|
|
|
|
catch (Exception exception)
|
|
|
|
{
|
|
|
|
MessageBox.Show("打印失败!");
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 查找Product
|
|
|
|
/// <summary>
|
|
|
|
/// 查找Product
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public Product SelectProduct(string Products)
|
|
|
|
{
|
|
|
|
var list = new List<string>();
|
|
|
|
var ProductList = _agent.InvokeServiceFunction<Product>(B9IPCService.ProductBLL_Get.ToString(), new Product() { PRODUCTCODE = Products });
|
|
|
|
return ProductList;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 初始界面
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private void PrintForm_Load(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
if (state)
|
|
|
|
{
|
|
|
|
_bzdConfig =
|
|
|
|
_agent.InvokeServiceFunction<List<BZDConfig>>(B9IPCService.BZDConfigBLL_GetAllList.ToString(), "");
|
|
|
|
var list = new List<BZDConfig>();
|
|
|
|
foreach (var t in _bzdConfig)
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(cbLine.SelectedValue.ToString()))
|
|
|
|
{
|
|
|
|
if (t.Column2 == cbLine.SelectedValue.ToString())
|
|
|
|
{
|
|
|
|
t.MATERIALCODDE = t.MATERIALCODDE + "|" + t.ColorDetail + "|" + t.configDetail;
|
|
|
|
list.Add(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_bzdConfig = list;
|
|
|
|
LoadAssyMaterial();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 加载总成物料
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 加载总成物料
|
|
|
|
/// </summary>
|
|
|
|
private void LoadAssyMaterial()
|
|
|
|
{
|
|
|
|
|
|
|
|
//模腔号
|
|
|
|
this.cbMaterial.DataSource = _bzdConfig;
|
|
|
|
this.cbMaterial.DisplayMember = "MATERIALCODDE";
|
|
|
|
this.cbMaterial.ValueMember = "PID";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public class Lines
|
|
|
|
{
|
|
|
|
public string Code { get; set; }
|
|
|
|
public string Name { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
private void label2_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void cbLine_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
PrintForm_Load(sender,e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|