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

211 lines
7.3 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.ServicesAgent;
using QMAPP.FJC.Entity.Basic;
using QMAPP.Entity;
namespace QMAPP.WinForm.Forms.Mend
{
public partial class MainCodeChangeEditForm : Form
{
Main main = new Main();
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
public MainCodeChangeEditForm()
{
InitializeComponent();
}
#region 回车事件
/// <summary>
/// 回车事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtMainCode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)//如果输入的是回车键
{
//窗体数据校验
string errorMessae = CheckChangeCode();
if (errorMessae != "")
{
this.labelError.Text = errorMessae;
return;
}
ChangeAndSaveCode();
}
}
#endregion
/// <summary>
/// 确认
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSave_Click(object sender, EventArgs e)
{
//窗体数据校验
string errorMessae = CheckChangeCode();
if (errorMessae != "")
{
this.labelError.Text = errorMessae;
return;
}
ChangeAndSaveCode();
}
#region 校验
/// <summary>
/// 校验
/// </summary>
private string CheckChangeCode()
{
string strMessage = "";
if (string.IsNullOrEmpty(this.txtMainCode.Text) == false)
{
main = agent.InvokeServiceFunction<Main>(B9IPCService.MainBLL_Get.ToString(), new Main() { MAINCODE = this.txtMainCode.Text });
if (main == null)
{
strMessage += "不存在此总成条码信息!" + "\r\n";
return strMessage;
}
if (main.EPIDERMISCODE == "")
{
strMessage += "此总成条码已完成替换操作!" + "\r\n";
}
else
{
//不为空则校验去product表中
Product pro = new Product();
pro.PRODUCTCODE = main.EPIDERMISCODE;
pro.MATERIAL_CODE = main.MATERIAL_CODE;
Product Product = agent.InvokeServiceFunction<Product>(B9IPCService.ProductBLL_Get.ToString(), pro);
if (Product.OUTFLAG == "1")
{
strMessage += "此总成条码未进行入库操作,请先入库!" + "\r\n";
}
}
}
else
{
strMessage += "请输入总成条码!" + "\r\n";
}
return strMessage;
}
#endregion
#region 替换\保存\打印
/// <summary>
/// 替换和保存
/// </summary>
private void ChangeAndSaveCode()
{
//Main main = agent.InvokeServiceFunction<Main>(B9IPCService.MainBLL_GetByCondition.ToString(), new Main() { EPIDERMISCODE = selectKey });
if (main == null)
{
MessageBox.Show("获取总成条码异常!");
return;
}
//生产新总成条码
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);
this.labelError.Text = "替换成功!";
this.txtMainCode.Text = "";
//打印
PrintProcessLabel(main);
}
#endregion
/// <summary>
/// 打印
/// </summary>
/// <param name="processcode"></param>
private void PrintProcessLabel(Main main)
{
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;
}
string selectKey = main.EPIDERMISCODE;
#region 总成装配打印
//string xmlPath = System.Configuration.ConfigurationSettings.AppSettings["XmlName"].ToString(); ;
//BarcodeLib.BarCodeGenerate g = new BarcodeLib.BarCodeGenerate(xmlPath);
//bool b = g.PrintBarCode(main.MAINCODE);
QM.Assist.LabelInfo ll = new QM.Assist.LabelInfo();
ll.BarCode = main.MAINCODE + "," + main.MATERIAL_CODE + ",";
ll.BarCode += mcinit.HB;
ll.BarCode += mcinit.COLOR;
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
// ());
#endregion
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnBack_Click(object sender, EventArgs e)
{
this.Close();
}
}
}