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

414 lines
16 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.FJC.Entity.Operation;
using QMAPP.Entity;
using QMAPP.ServicesAgent;
using QMAPP.MD.Entity;
using QMAPP.FJC.Entity.Basic;
namespace QMAPP.WinForm.Forms.Operation
{
public partial class PrintForm : Form
{
//获取服务代理
QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent();
List<BarcodeRules> _barcodeRules=null;
List<Material> cbsource = null;
Product _CurrentProduct=null;
public PrintForm()
{
InitializeComponent();
txtProcessCode.Focus();
infolabel.Text = "";
infolabel.ForeColor = Color.Red;
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (_CurrentProduct == null)
{
infolabel.Text = "请先输入仪表板表皮条码!";
txtProcessCode.SelectAll();
txtProcessCode.Focus();
return;
}
if (string.IsNullOrWhiteSpace(cbMaterial.Text))
{
infolabel.Text = "请选择总成零件号!";
cbMaterial.Focus();
return;
}
if (cbMaterial.Enabled)
{
DataResult<Main> result = _agent.InvokeServiceFunction<DataResult<Main>>(B9IPCService.MainBLL_CreateMain.ToString(), _CurrentProduct.PRODUCTCODE, txtMaterialCode.Text);
}
else
{
var main = _agent.InvokeServiceFunction<Main>(B9IPCService.MainBLL_GetByCondition.ToString(), new Main() { EPIDERMISCODE = _CurrentProduct.PRODUCTCODE });
main.COLOR = "";
main.HB = "";
//生产新总成条码
string materialCode = main.MATERIAL_CODE;
var dataResult = _agent.InvokeServiceFunction<DataResult<string>>("MainCodeChangeBLL_Generate", materialCode);
string MAINCODE = dataResult.Result.ToString();
//更新
Main upMian = (Main)main.Clone();
upMian.EPIDERMISCODE = "";
int UpdateCount = _agent.InvokeServiceFunction<int>(B9IPCService.MainBLL_Update.ToString(), upMian);
//插入T_AW_MAINCODECHANGE表
MainCodeChange mainchange = new MainCodeChange();
mainchange.ORIGMAINCODE = main.MAINCODE;
mainchange.NEWMAINCODE = MAINCODE;
mainchange.MATERIALCODE = main.MATERIAL_CODE;
mainchange.PRODUCELINE = main.PRODUCELINE;
mainchange.PRODUCTCODE = main.EPIDERMISCODE;
int InsertCount2 = _agent.InvokeServiceFunction<int>(B9IPCService.MainCodeChangeBLL_Insert.ToString(), mainchange);
//插入Main表
main.MAINCODE = MAINCODE;
int InsertCount1 = _agent.InvokeServiceFunction<int>(B9IPCService.MainBLL_Insert.ToString(), main);
}
PrintAssemblyLabel(_CurrentProduct.PRODUCTCODE);
txtProcessCode.SelectAll();
txtProcessCode.Focus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
_CurrentProduct = null;
txtProcessCode.Text = "";
infolabel.Text = "";
}
#region
//DataResult<Main> result = _agent.InvokeServiceFunction<DataResult<Main>>(B9BasicService.MainOperationBLL_GetPrintCode.ToString(), product);
//#region 总成装配打印
//txtMainCode.Text = result.Result.MAINCODE;
//QM.Assist.LabelInfo ll = new QM.Assist.LabelInfo();
//ll.BarCode = result.Result.MAINCODE + ",*" + result.Result.MAINCODE + "*,";
//if (barcode.Substring(12, 1).Equals("H"))
//{
// ll.BarCode += "高";
//}
//else
//{
// ll.BarCode += "低";
//}
//if (barcode.Substring(13, 1).Equals("1"))
//{
// ll.BarCode += "黑";
//}
//else if (barcode.Substring(13, 1).Equals("2"))
//{
// ll.BarCode += "米";
//}
//else
//{
// ll.BarCode += "灰";
//}
//ll.BarCode += System.Configuration.ConfigurationManager.AppSettings["ZCZP"].ToString();
//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["ZCtemPath"].ToString
// (), System.Configuration.ConfigurationManager.AppSettings["ZCdataPath"].ToString
// ());
//txtProcessCode.Text = "";
//txtProcessCode.Focus();
//#endregion
#endregion
}
private void PrintAssemblyLabel(string processcode)
{
Main main = _agent.InvokeServiceFunction<Main>(B9IPCService.MainBLL_GetByCondition.ToString(), new Main() { EPIDERMISCODE = processcode });
if (main == null)
{
MessageBox.Show("获取总成条码异常!");
return;
}
MaterialCodeInit mcinit = _agent.InvokeServiceFunction<MaterialCodeInit>(B9IPCService.MainBLL_GetMaterialSetByCondition.ToString(), new MaterialCodeInit() { MATERIAL_CODE = main.MATERIAL_CODE, WORKCELL_CODE = "LS_ASSEMBLE_VW371" });
if (mcinit == null)
{
MessageBox.Show("获取总成条码异常!");
return;
}
#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();
ll.BarCode = main.MAINCODE + "," + main.MATERIAL_CODE + ",";
ll.BarCode += mcinit.HB;
//if (selectKey.ToUpper().Substring(12, 1) == "H")
//{
// ll.BarCode += "高";
//}
//else
//{
// ll.BarCode += "低";
//}
ll.BarCode += mcinit.COLOR;
//if (selectKey.Substring(13, 1) == "1")
//{
// ll.BarCode += "黑";
//}
//else if (selectKey.Substring(13, 1) == "2")
//{
// ll.BarCode += "灰";
//}
//else
//{
// ll.BarCode += "米";
//}
ll.BarCode += " ";// +mcinit.PRODUCT_TYPES;
//ll.BarCode += "\r\n" + ll.BarCode;//总成标签一式两份
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["ZCtemPath"].ToString
(), System.Configuration.ConfigurationManager.AppSettings["ZCdataPath"].ToString
());
///总成标签一式两份
//pu.PrintLabel2(System.Configuration.ConfigurationManager.AppSettings["proPath"].ToString
// (), System.Configuration.ConfigurationManager.AppSettings["ZCtemPath"].ToString
// (), System.Configuration.ConfigurationManager.AppSettings["ZCdataPath"].ToString
// ());
txtMainCode.Text = main.MAINCODE;
_CurrentProduct = null;
txtProcessCode.Text = "";
#endregion
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter)//如果输入的是回车键
{
return;
}
LoadProduct();
}
private void LoadProduct()
{
txtMainCode.Text = "";
_CurrentProduct = null;
cbMaterial.SelectedIndex = 0;
cbMaterial.Enabled = true;
txtMaterialCode.Text = "";
if(string.IsNullOrWhiteSpace(txtProcessCode.Text.Trim()))
{
infolabel.Text="请输入仪表板表皮条码!";
txtProcessCode.SelectAll();
txtProcessCode.Focus();
return;
}
//Product product = _agent.InvokeServiceFunction<Product>(B9BasicService.ProductBLL_GetProductInfo.ToString(), txtProcessCode.Text.Trim());
Product product = _agent.InvokeServiceFunction<Product>(B9BasicService.ProductBLL_GetProductInfo.ToString(), new Product { PRODUCTCODE = txtProcessCode.Text.Trim() });
if(product==null)
{
infolabel.Text = "输入的产品码不存在!";
txtProcessCode.SelectAll();
txtProcessCode.Focus();
return;
}
//if (product.MATERIAL_TYPE != "IP_SKIN")
//{
// infolabel.Text="输入的条码并非仪表板表皮条码!";
// txtProcessCode.SelectAll();
// txtProcessCode.Focus();
// return;
//}
if (product.CAPACITY > 1)
{
infolabel.Text = "无法通过零件批次码/箱码确定唯一产品!";
txtProcessCode.SelectAll();
txtProcessCode.Focus();
return;
}
if (product.USINGSTATE == "2")
{
product = _agent.InvokeServiceFunction<Product>("ProductBLL_GetProductByPartID", product.PID);
}
IList<Material> materialList= cbMaterial.DataSource as IList<Material>;
var material= materialList.FirstOrDefault(p=>p.MATERIAL_CODE==product.MATERIAL_CODE);
if(material==null)
{
if (cbForce.Enabled)
{
infolabel.Text = "当前输入的仪表板条码没有总成装配的加工记录!\n\r请手工选择总成零件号";
List<Pbom> boms = _agent.InvokeServiceFunction<List<Pbom>>("PbomBLL_GetFinalPbom", product.MATERIAL_CODE);
if (boms.Count > 0)
{
var filterlist = cbsource.Where(p => boms.Exists(b => b.MATERIAL_CODE == p.MATERIAL_CODE)).ToList();
if (filterlist.Count > 0)
{
filterlist.Insert(0, new Material { MATERIAL_NAME = "", MATERIAL_CODE = "" });
cbMaterial.DataSource = filterlist;
}
}
cbMaterial.Focus();
}
else
{
infolabel.Text = "当前输入的仪表板条码没有总成装配的加工记录!";
txtProcessCode.SelectAll();
txtProcessCode.Focus();
cbMaterial.Enabled = false;
return;
}
}
else
{
infolabel.Text = "";
cbMaterial.SelectedItem=material;
cbMaterial.Enabled = false;
}
_CurrentProduct = product;
}
public void ss()
{
string barcode = txtProcessCode.Text.Trim().ToUpper();
if (string.IsNullOrEmpty(barcode))
{
infolabel.Text = "请扫描条码!";
return;
}
Product product = new Product();
product.PRODUCTCODE = barcode;
for (int i = 0; i < 1; i++)
{
i++;
DataResult<Main> result = _agent.InvokeServiceFunction<DataResult<Main>>(B9BasicService.MainOperationBLL_GetPrintCode.ToString(), product);
#region 总成装配打印
txtMainCode.Text = result.Result.MAINCODE;
QM.Assist.LabelInfo ll = new QM.Assist.LabelInfo();
ll.BarCode = result.Result.MAINCODE + ",*" + result.Result.MAINCODE + "*,";
//if (barcode.Substring(12, 1).Equals("H"))
//{
// ll.BarCode += "高";
//}
//else
//{
// ll.BarCode += "低";
//}
//if (barcode.Substring(13, 1).Equals("1"))
//{
// ll.BarCode += "黑";
//}
//else if (barcode.Substring(13, 1).Equals("2"))
//{
// ll.BarCode += "米";
//}
//else
//{
// ll.BarCode += "灰";
//}
//ll.BarCode += System.Configuration.ConfigurationManager.AppSettings["ZCZP"].ToString();
string printUrl = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
QM.Assist.PrintUtil.LabelList2.Add(ll);
QM.Assist.PrintUtil pu = new QM.Assist.PrintUtil();
pu.PrintLabel2(System.Configuration.ConfigurationManager.AppSettings["proPath"].ToString
(), printUrl + "zczp.qdf", printUrl + "zczp.txt");
//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["ZCtemPath"].ToString
// (), System.Configuration.ConfigurationManager.AppSettings["ZCdataPath"].ToString
// ());
#endregion
}
txtProcessCode.Text = "";
txtProcessCode.Focus();
}
private void PrintForm_Load(object sender, EventArgs e)
{
//cbProductType.SelectedIndex = 0;
_barcodeRules = _agent.InvokeServiceFunction<List<BarcodeRules>>(B9BasicService.BarcodeRulesBLL_GetAllList.ToString());
LoadAssyMaterial();
}
/// <summary>
/// 加载总成物料
/// </summary>
private void LoadAssyMaterial()
{
var ipassy = _agent.InvokeServiceFunction<List<Material>>
("MaterialBLL_GetMaterialForInjectOrder", "DASHBOARD");
ipassy = ipassy.OrderBy(p => p.MATERIAL_CODE).ToList();
cbsource = ipassy;
cbsource.Insert(0, new Material { MATERIAL_NAME = "", MATERIAL_CODE = "" });
cbMaterial.DisplayMember = "MATERIAL_NAME";
cbMaterial.ValueMember = "MATERIAL_CODE";
cbMaterial.DataSource = cbsource;
}
private void cbMaterial_SelectedIndexChanged(object sender, EventArgs e)
{
txtMaterialCode.Text = cbMaterial.SelectedValue.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
LoadProduct();
}
}
}