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.
293 lines
12 KiB
293 lines
12 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using QM.Common;
|
|
using QMAPP.FJC.Entity;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QMAPP.FJC.Entity.Operation;
|
|
using QMAPP.ServicesAgent;
|
|
using QMAPP.WinForm.Common;
|
|
using QMAPP.Entity;
|
|
using System.Drawing;
|
|
|
|
namespace QMAPP.WinForm.Forms.Injection
|
|
{
|
|
/// <summary>
|
|
/// 模块编号:M11-2
|
|
/// 作 用:搪塑条码打印
|
|
/// 作 者:王庆男
|
|
/// 编写日期:2015年05月28日
|
|
///</summary>
|
|
public partial class SlushMoldingPrintLotForm : Form
|
|
{
|
|
Product recorder = new Product();
|
|
QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent();
|
|
/// <summary>
|
|
/// 新建
|
|
/// </summary>
|
|
public SlushMoldingPrintLotForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
/// <param name="pid"></param>
|
|
public SlushMoldingPrintLotForm(string pid)
|
|
{
|
|
recorder.PID = pid;
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗体加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Form_Load(object sender, EventArgs e)
|
|
{
|
|
#region 绑定下拉列表
|
|
BasicData basicData = new BasicData();
|
|
//加载搪塑设备列表
|
|
this.comMachineCode.DataSource = basicData.GetMachineInfoList(new string[] { EnumGeter.ProcessType_M.Slush.GetHashCode().ToString() }, true);
|
|
this.comMachineCode.DisplayMember = "MACHINENAME";
|
|
this.comMachineCode.ValueMember = "MACHINECODDE";
|
|
//产品类型
|
|
this.comProType.DataSource = basicData.GetDictionaryList(EnumGeter.DictKind.PROTYPE.ToString());
|
|
this.comProType.DisplayMember = "VALUE";
|
|
this.comProType.ValueMember = "KEY";
|
|
//颜色
|
|
this.comColor.DataSource = basicData.GetDictionaryList(EnumGeter.DictKind.COLOR.ToString());
|
|
this.comColor.DisplayMember = "VALUE";
|
|
this.comColor.ValueMember = "KEY";
|
|
//投料口
|
|
this.comPosition.DataSource = basicData.GetDictionaryList(EnumGeter.DictKind.CAVITYTYPE.ToString());
|
|
this.comPosition.DisplayMember = "VALUE";
|
|
this.comPosition.ValueMember = "KEY";
|
|
//高低配
|
|
this.comHOrL.DataSource = basicData.GetDictionaryList(EnumGeter.DictKind.HAndL.ToString());
|
|
this.comHOrL.DisplayMember = "VALUE";
|
|
this.comHOrL.ValueMember = "KEY";
|
|
//模腔号
|
|
this.cBoxModelCode.DataSource = basicData.GetDictionaryList(EnumGeter.DictKind.MODELCODE.ToString());
|
|
this.cBoxModelCode.DisplayMember = "VALUE";
|
|
this.cBoxModelCode.ValueMember = "KEY";
|
|
#endregion
|
|
//加工日期
|
|
//this.dtpDate.Text = DateTime.Now.ToString();
|
|
|
|
#region 编辑
|
|
//判断是否为编辑加载编辑数据
|
|
if (string.IsNullOrEmpty(recorder.PID) == false)
|
|
{
|
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
|
recorder = agent.InvokeServiceFunction<Product>(B9BasicService.ProductBLL_Get.ToString(), recorder);
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗体保存事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsbSave_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
string errorMessae = ErrorCheck();
|
|
if (errorMessae != "")
|
|
{
|
|
MessageBox.Show(errorMessae, Resource1.ConfirmTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
#region 加载保存信息
|
|
int codeNum = 0;
|
|
DateTime dt = DateTime.Now;
|
|
if (!string.IsNullOrEmpty(this.dtpDate.Text.Trim()))
|
|
{
|
|
dt = Convert.ToDateTime(this.dtpDate.Text.Trim());
|
|
}
|
|
if (int.TryParse(this.txtNum.Text, out codeNum))
|
|
{
|
|
ProductAttribute productAttribute = new ProductAttribute();
|
|
//搪塑机
|
|
MachineInfo machineInfo = this.comMachineCode.SelectedItem as MachineInfo;
|
|
//搪塑机编号
|
|
productAttribute.VAL1 = machineInfo.MACHINENUM;
|
|
//产品类型
|
|
//ListItem typeItem = this.comProType.SelectedItem as ListItem;
|
|
productAttribute.VAL2 = this.comProType.SelectedValue.ToString();
|
|
//高低配
|
|
//ListItem hAndLItem = this.comHOrL.SelectedItem as ListItem;
|
|
productAttribute.VAL3 = this.comHOrL.SelectedValue.ToString();
|
|
//颜色
|
|
//ListItem colorItem = this.comColor.SelectedItem as ListItem;
|
|
productAttribute.VAL4 = this.comColor.SelectedValue.ToString();
|
|
//腔
|
|
// ListItem posiItem = this.comPosition.SelectedItem as ListItem;
|
|
productAttribute.VAL5 = this.comPosition.SelectedValue.ToString();
|
|
//模腔
|
|
productAttribute.VAL6 = this.cBoxModelCode.Text.Trim();
|
|
for (int i = 0; i < codeNum; i++)
|
|
{
|
|
//零件属性
|
|
|
|
//判断条码是否为空
|
|
|
|
productAttribute.PID = "";
|
|
|
|
|
|
dt = dt.AddMinutes(-1);
|
|
productAttribute.VAL7 = dt.ToString("yyyy-MM-dd HH:mm:ss");
|
|
string proCode = dt.ToString("yyMMddHHmm");
|
|
proCode += (productAttribute.VAL1);//设备名称
|
|
proCode += (productAttribute.VAL2);//产品类型
|
|
proCode += (productAttribute.VAL3);//高低配
|
|
proCode += (productAttribute.VAL4);//颜色
|
|
proCode += (productAttribute.VAL5);//腔
|
|
proCode += (productAttribute.VAL6);//模腔号
|
|
recorder.PRODUCTCODE = proCode;
|
|
if (this.checkBox1.Checked)
|
|
{
|
|
//产品条码表
|
|
recorder.MACHINECODDE = machineInfo.MACHINECODDE;//暂时用这个码
|
|
recorder.MACHINENAME = machineInfo.MACHINENAME;
|
|
|
|
recorder.PRODUCTATTRIBUTE = productAttribute;
|
|
|
|
recorder.PRODUCTSOURCE = EnumGeter.PRODUCTSOURCE.SELFMADE.GetHashCode().ToString();
|
|
recorder.PRODUCTTYPE = EnumGeter.ProductType.biaopi.GetHashCode().ToString();
|
|
recorder.STATUS = EnumGeter.PRODUCTSTAUTS.QUALIFIED.GetHashCode().ToString();
|
|
recorder.CURRENTPROCESS = EnumGeter.ProcessType.lengdaoruohua.GetHashCode().ToString();
|
|
recorder.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString();
|
|
recorder.OUTFLAG = EnumGeter.PRODUCTOUTFLAG.INLIBRARY.GetHashCode().ToString();
|
|
recorder.USINGSTATE = EnumGeter.PRODUCTUSESTATE.UNUSED.GetHashCode().ToString();
|
|
recorder.PRODUCESHIFTTCODE = ClientContext.produceShift.PRODUCESHIFTTCODE;
|
|
recorder.PRODUCESHIFTNAME = ClientContext.produceShift.PRODUCESHIFTNAME;
|
|
recorder.CAPACITY = 1;
|
|
recorder.USINGCOUNT = 0;
|
|
recorder.PRODUCTATTRIBUTE = productAttribute;
|
|
#region 保存
|
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
|
DataResult<List<string>> result;//判断是否成功
|
|
if (string.IsNullOrEmpty(recorder.PID) == true)
|
|
{
|
|
result = agent.InvokeServiceFunction<DataResult<List<string>>>(B9BasicService.ProductBLL_InsertEpidermis.ToString(), recorder);
|
|
}
|
|
else
|
|
{
|
|
result = agent.InvokeServiceFunction<DataResult<List<string>>>(B9BasicService.ProductBLL_Update.ToString(), recorder);
|
|
}
|
|
|
|
if (!result.IsSuccess )
|
|
{
|
|
|
|
MessageBox.Show("出错!");
|
|
return;
|
|
}
|
|
#endregion
|
|
}
|
|
//打印条码
|
|
//窗体数据校验
|
|
QM.Assist.LabelInfo ll = new QM.Assist.LabelInfo();
|
|
ll.BarCode = proCode + ",*" + proCode + "*" + "," + (productAttribute.VAL3 == "H" ? "高" : "");
|
|
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[EnumGeter.ProductType.biaopi.GetHashCode().ToString()+"temPath"].ToString
|
|
(), System.Configuration.ConfigurationManager.AppSettings[EnumGeter.ProductType.biaopi.GetHashCode().ToString() + "dataPath"].ToString
|
|
());
|
|
MessageBox.Show("成功!");
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗体关闭
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsbClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
///<summary>
|
|
///错误检测
|
|
///</summary>
|
|
///<returns></returns>
|
|
private string ErrorCheck()
|
|
{
|
|
#region
|
|
string strMessage = "";
|
|
//判断条码是否为空
|
|
|
|
//搪塑设备
|
|
if (this.comMachineCode.SelectedValue == null || this.comMachineCode.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1.SlushMachineNullValidate + "\r\n";
|
|
}
|
|
//产品类别
|
|
if (this.comProType.SelectedValue == null || this.comProType.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1.ProductTypeNullValidate + "\r\n";
|
|
}
|
|
//颜色
|
|
if (this.comColor.SelectedValue == null || this.comColor.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1.ColorNullValidate + "\r\n";
|
|
}
|
|
//高低配
|
|
if (this.comHOrL.SelectedValue == null || this.comHOrL.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1 .HLNullValidate+ "\r\n";
|
|
}
|
|
//腔
|
|
if (this.comPosition.SelectedValue == null || this.comPosition.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1.PositionNullValidate + "\r\n";
|
|
}
|
|
//模腔号
|
|
if (this.cBoxModelCode.Text == string.Empty)
|
|
{
|
|
strMessage += Resource1.ModelCodeNullValidate + "\r\n";
|
|
}
|
|
|
|
return strMessage;
|
|
#endregion
|
|
}
|
|
|
|
private void textSelectBox_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
|
|
if (e.KeyCode == Keys.Enter)//如果输入的是回车键
|
|
{
|
|
|
|
string productcode = textSelectBox.Text.Trim().ToUpper();
|
|
|
|
int result = _agent.InvokeServiceFunction<int>(B9BasicService.ProductBLL_ModifyProductCode.ToString(), productcode);
|
|
|
|
if (result == 0)
|
|
{
|
|
//未找到
|
|
textSelectBox.BackColor = Color.Red;
|
|
}
|
|
else if (result == 1)
|
|
{
|
|
//修改完成
|
|
textSelectBox.BackColor = Color.Green;
|
|
}
|
|
else
|
|
{
|
|
//找到
|
|
textSelectBox.BackColor = Color.Yellow;
|
|
}
|
|
|
|
textSelectBox.Text = "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|